2ronwalf/*
2ronwalf * Created on Aug 30, 2004
2ronwalf */
22daenzeroramapackage impl.owls.process.binding;
2ronwalf
2ronwalfimport impl.owl.WrappedIndividual;
2ronwalf
2ronwalfimport org.mindswap.exceptions.NotImplementedException;
2ronwalfimport org.mindswap.owl.OWLDataValue;
2ronwalfimport org.mindswap.owl.OWLIndividual;
2ronwalfimport org.mindswap.owl.OWLValue;
2ronwalfimport org.mindswap.owls.process.Binding;
10daenzeroramaimport org.mindswap.owls.process.Parameter;
2ronwalfimport org.mindswap.owls.process.ParameterValue;
2ronwalfimport org.mindswap.owls.process.ValueData;
2ronwalfimport org.mindswap.owls.process.ValueOf;
2ronwalfimport org.mindswap.owls.vocabulary.OWLS;
2ronwalf
2ronwalf/**
2ronwalf * @author Evren Sirin
2ronwalf */
2ronwalfpublic abstract class BindingImpl extends WrappedIndividual implements Binding {
2ronwalf public BindingImpl(OWLIndividual ind) {
2ronwalf super(ind);
2ronwalf }
2ronwalf
2ronwalf public ParameterValue getValue() {
2ronwalf ParameterValue value =
2ronwalf (ParameterValue) getPropertyAs(OWLS.Process.valueSource, ValueOf.class);
2ronwalf
2ronwalf if(value == null) {
2ronwalf OWLDataValue dataValue = getProperty(OWLS.Process.valueData);
2ronwalf if(dataValue != null) {
2ronwalf// Parameter param = getParameter();
2ronwalf// OWLType paramType = (param == null) ? null : param.getParamType();
2ronwalf// OWLValue owlValue = null;
2ronwalf// if((paramType == null) || paramType.isDataType())
2ronwalf// owlValue = dataValue;
2ronwalf// else {
2ronwalf// String literalValue = dataValue.getLexicalValue().trim();
2ronwalf// String rdf = literalValue.indexOf("rdf:RDF") == -1
2ronwalf// ? RDFUtils.addRDFTag( literalValue )
2ronwalf// : literalValue;
2ronwalf// owlValue = getOntology().parseLiteral( rdf );
2ronwalf// }
2ronwalf//
2ronwalf// return getKB().createValueData(owlValue);
2ronwalf return getKB().createValueData(dataValue);
2ronwalf }
2ronwalf }
2ronwalf
2ronwalf OWLIndividual owlValue = getProperty(OWLS.Process.valueObject);
2ronwalf if(owlValue != null) {
2ronwalf return getKB().createValueData(owlValue);
2ronwalf }
2ronwalf
2ronwalf// if(value == null)
2ronwalf// value = (ParameterValue) getProperty(OWLS.Process.valueForm);
2ronwalf//
2ronwalf// if(value == null)
2ronwalf// value = (ParameterValue) getPropertyAs(OWLS.Process.valueType, ParameterValue.class);
2ronwalf//
2ronwalf// if(value == null)
2ronwalf// value = (ParameterValue) getPropertyAs(OWLS.Process.valueSpecifier, ValueOf.class);
2ronwalf//
2ronwalf// if(value == null)
2ronwalf// value = (ParameterValue) getPropertyAs(OWLS.Process.valueFunction, ValueFunction.class);
2ronwalf
2ronwalf
2ronwalf return value;
2ronwalf }
2ronwalf
2ronwalf /* (non-Javadoc)
2ronwalf * @see org.mindswap.owls.process.Binding#setValue(org.mindswap.owls.process.ParameterValue)
2ronwalf */
2ronwalf public void setValue(ParameterValue paramValue) {
2ronwalf if(paramValue instanceof ValueOf)
2ronwalf setProperty(OWLS.Process.valueSource, (ValueOf) paramValue);
2ronwalf else if (paramValue instanceof ValueData) {
2ronwalf OWLValue value = ((ValueData) paramValue).getData();
2ronwalf if( value.isDataValue() )
2ronwalf setProperty(OWLS.Process.valueData, (OWLDataValue) value);
2ronwalf else {
2ronwalf// String str = ((OWLIndividual) value).toRDF(true);
2ronwalf// setProperty(OWLS.Process.valueData, EntityFactory.createDataValue( str, RDF.XMLLiteral ) );
2ronwalf setProperty(OWLS.Process.valueObject, (OWLIndividual) value);
2ronwalf }
2ronwalf }
2ronwalf else
2ronwalf throw new NotImplementedException("Only ValueOf parameter values are implemented!");
2ronwalf }
10daenzerorama
10daenzerorama public Parameter getParameter() {
10daenzerorama return (Parameter) getPropertyAs(OWLS.Process.toParam, Parameter.class);
10daenzerorama }
2ronwalf
2ronwalf}