DataPropertyAtomImpl.java revision 2
1666N/A/*
98N/A * Created on Dec 28, 2004
1592N/A */
98N/Apackage impl.swrl;
98N/A
919N/Aimport org.mindswap.owl.OWLDataProperty;
919N/Aimport org.mindswap.owl.OWLIndividual;
919N/Aimport org.mindswap.owl.vocabulary.SWRL;
919N/Aimport org.mindswap.swrl.DataPropertyAtom;
919N/Aimport org.mindswap.swrl.SWRLDataObject;
919N/Aimport org.mindswap.swrl.SWRLDataValue;
919N/Aimport org.mindswap.swrl.SWRLDataVariable;
919N/Aimport org.mindswap.swrl.SWRLIndividualObject;
919N/Aimport org.mindswap.swrl.SWRLObject;
919N/A
919N/A/**
919N/A * @author Evren Sirin
919N/A *
919N/A */
919N/Apublic class DataPropertyAtomImpl extends AtomImpl implements DataPropertyAtom {
919N/A public DataPropertyAtomImpl(OWLIndividual ind) {
919N/A super(ind);
98N/A }
98N/A
98N/A public OWLDataProperty getPropertyPredicate() {
493N/A return (OWLDataProperty) getPropertyAs(SWRL.propertyPredicate, OWLDataProperty.class);
493N/A }
98N/A
970N/A public void setPropertyPredicate(OWLDataProperty p) {
970N/A setProperty(SWRL.propertyPredicate, (OWLIndividual) p.castTo(OWLIndividual.class));
970N/A }
970N/A
970N/A public SWRLIndividualObject getArgument1() {
970N/A return (SWRLIndividualObject) getPropertyAs(SWRL.argument1, SWRLIndividualObject.class);
970N/A }
1003N/A
1356N/A public SWRLDataObject getArgument2() {
1666N/A SWRLDataObject arg = (SWRLDataVariable) getPropertyAs(SWRL.argument2, SWRLDataVariable.class);
970N/A if( arg == null )
970N/A arg = (SWRLDataValue) getPropertyAs(SWRL._argument2, SWRLDataValue.class);
970N/A
970N/A return arg;
1391N/A }
1391N/A
1549N/A public int getArgumentCount() {
1549N/A return 2;
1666N/A }
1666N/A
970N/A public SWRLObject getArgument(int index) {
98N/A if( index == 0 )
1666N/A return getArgument1();
98N/A
911N/A if( index == 1 )
1666N/A return getArgument2();
1666N/A
1666N/A throw new IndexOutOfBoundsException("Illegal argument index: "+index+" for a DataPropertyAtom");
911N/A }
98N/A
1666N/A public void setArgument(int index, SWRLObject obj) {
493N/A if( index > 1 )
98N/A throw new IndexOutOfBoundsException("Illegal argument index: "+index+" for a DataPropertyAtom");
98N/A
1089N/A
156N/A if( index == 0 ) {
493N/A if(obj instanceof SWRLIndividualObject)
493N/A setArgument1((SWRLIndividualObject) obj);
493N/A else
493N/A throw new IllegalArgumentException(
493N/A "First argument of a DataPropertyAtom should be an SWRLIndividiualObject");
493N/A }
98N/A else {
98N/A if(obj instanceof SWRLDataObject)
1666N/A setArgument2((SWRLDataObject) obj);
1549N/A else
606N/A throw new IllegalArgumentException(
1466N/A "Second argument of a DataPropertyAtom should be an SWRLDataObject");
1466N/A }
1466N/A }
1466N/A
1466N/A public void setArgument1(SWRLIndividualObject obj) {
1466N/A setProperty(SWRL.argument1, obj);
606N/A }
1333N/A
606N/A public void setArgument2(SWRLDataObject obj) {
606N/A if(obj.isDataValue())
1666N/A setProperty(SWRL._argument2, obj);
1666N/A else
606N/A setProperty(SWRL.argument2, (SWRLDataVariable) obj);
1666N/A }
1666N/A
1666N/A public String toString() {
1666N/A return
1666N/A "(" + getArgument1() + " " +
1666N/A getPropertyPredicate().getQName() +
1666N/A " " + getArgument2() + ")";
1666N/A }
1666N/A}
606N/A