2ronwalf/*
2ronwalf * Created on Apr 6, 2005
2ronwalf */
2ronwalfpackage impl.swrl;
2ronwalf
2ronwalfimport java.net.URI;
2ronwalf
2ronwalfimport org.mindswap.owl.OWLClass;
2ronwalfimport org.mindswap.owl.OWLDataProperty;
2ronwalfimport org.mindswap.owl.OWLIndividual;
2ronwalfimport org.mindswap.owl.OWLObjectProperty;
2ronwalfimport org.mindswap.owl.OWLOntology;
2ronwalfimport org.mindswap.owl.OWLValue;
2ronwalfimport org.mindswap.owl.vocabulary.SWRL;
2ronwalfimport org.mindswap.owl.vocabulary.SWRLB;
2ronwalfimport org.mindswap.swrl.Atom;
2ronwalfimport org.mindswap.swrl.AtomList;
2ronwalfimport org.mindswap.swrl.BuiltinAtom;
2ronwalfimport org.mindswap.swrl.ClassAtom;
2ronwalfimport org.mindswap.swrl.DataPropertyAtom;
2ronwalfimport org.mindswap.swrl.DifferentIndividualsAtom;
2ronwalfimport org.mindswap.swrl.IndividualPropertyAtom;
2ronwalfimport org.mindswap.swrl.SWRLDataObject;
2ronwalfimport org.mindswap.swrl.SWRLDataVariable;
2ronwalfimport org.mindswap.swrl.SWRLFactory;
2ronwalfimport org.mindswap.swrl.SWRLIndividualObject;
2ronwalfimport org.mindswap.swrl.SWRLIndividualVariable;
2ronwalfimport org.mindswap.swrl.SameIndividualAtom;
2ronwalf
2ronwalf/**
2ronwalf * @author Evren Sirin
2ronwalf *
2ronwalf */
2ronwalfpublic class SWRLFactoryImpl implements SWRLFactory {
2ronwalf private OWLOntology ont;
2ronwalf
2ronwalf public SWRLFactoryImpl( OWLOntology ont ) {
2ronwalf this.ont = ont;
2ronwalf }
2ronwalf
2ronwalf public OWLOntology getOntology() {
2ronwalf return ont;
2ronwalf }
2ronwalf
2ronwalf public AtomList createList() {
2ronwalf return (AtomList) ont.createList(SWRL.AtomListVocabulary).castTo(AtomList.class);
2ronwalf }
2ronwalf
2ronwalf public AtomList createList(Atom atom) {
2ronwalf return (AtomList) ont.createList(SWRL.AtomListVocabulary, atom).castTo(AtomList.class);
2ronwalf }
2ronwalf
2ronwalf public SWRLIndividualVariable createIndividualVariable(URI uri) {
2ronwalf return new SWRLIndividualVariableImpl(ont.createInstance(SWRL.Variable, uri));
2ronwalf }
2ronwalf
2ronwalf public SWRLDataVariable createDataVariable(URI uri) {
2ronwalf return new SWRLDataVariableImpl(ont.createInstance(SWRL.Variable, uri));
2ronwalf }
2ronwalf
2ronwalf public ClassAtom createAtom(OWLClass c, OWLIndividual arg) {
2ronwalf return createClassAtom( c, (SWRLIndividualObject) arg.castTo( SWRLIndividualObject.class ) );
2ronwalf }
2ronwalf
2ronwalf public ClassAtom createClassAtom(OWLClass c, OWLIndividual arg) {
2ronwalf return createClassAtom( c, (SWRLIndividualObject) arg.castTo( SWRLIndividualObject.class ) );
2ronwalf }
2ronwalf
2ronwalf public ClassAtom createClassAtom(OWLClass c, SWRLIndividualObject arg) {
2ronwalf ClassAtom atom = (ClassAtom) ont.createInstance( SWRL.ClassAtom ).castTo( ClassAtom.class );
2ronwalf atom.setClassPredicate( c );
2ronwalf atom.setArgument1( arg );
2ronwalf
2ronwalf return atom;
2ronwalf }
2ronwalf
2ronwalf public IndividualPropertyAtom createAtom(OWLObjectProperty p, OWLIndividual arg1, OWLIndividual arg2) {
2ronwalf return createIndividualPropertyAtom(p,
2ronwalf (SWRLIndividualObject) arg1.castTo( SWRLIndividualObject.class ),
2ronwalf (SWRLIndividualObject) arg2.castTo( SWRLIndividualObject.class ) );
2ronwalf }
2ronwalf
2ronwalf public IndividualPropertyAtom createIndividualPropertyAtom(OWLObjectProperty p, OWLIndividual arg1, OWLIndividual arg2) {
2ronwalf return createIndividualPropertyAtom(p,
2ronwalf (SWRLIndividualObject) arg1.castTo( SWRLIndividualObject.class ),
2ronwalf (SWRLIndividualObject) arg2.castTo( SWRLIndividualObject.class ) );
2ronwalf }
2ronwalf
2ronwalf public IndividualPropertyAtom createIndividualPropertyAtom(OWLObjectProperty p, SWRLIndividualObject arg1, SWRLIndividualObject arg2) {
2ronwalf IndividualPropertyAtom atom = (IndividualPropertyAtom)
2ronwalf ont.createInstance( SWRL.IndividualPropertyAtom ).castTo( IndividualPropertyAtom.class );
2ronwalf atom.setPropertyPredicate( p );
2ronwalf atom.setArgument1( arg1 );
2ronwalf atom.setArgument2( arg2 );
2ronwalf
2ronwalf return atom;
2ronwalf }
2ronwalf
2ronwalf public DataPropertyAtom createAtom(OWLDataProperty p, OWLIndividual arg1, OWLValue arg2) {
2ronwalf return createDataPropertyAtom(p,
2ronwalf (SWRLIndividualObject) arg1.castTo( SWRLIndividualObject.class ),
2ronwalf (SWRLDataObject) arg2.castTo( SWRLDataObject.class ) );
2ronwalf }
2ronwalf
2ronwalf public DataPropertyAtom createDataPropertyAtom(OWLDataProperty p, OWLIndividual arg1, OWLValue arg2) {
2ronwalf return createDataPropertyAtom(p,
2ronwalf (SWRLIndividualObject) arg1.castTo( SWRLIndividualObject.class ),
2ronwalf (SWRLDataObject) arg2.castTo( SWRLDataObject.class ) );
2ronwalf }
2ronwalf
2ronwalf public DataPropertyAtom createDataPropertyAtom(OWLDataProperty p, SWRLIndividualObject arg1, SWRLDataObject arg2) {
2ronwalf DataPropertyAtom atom = (DataPropertyAtom)
2ronwalf ont.createInstance( SWRL.DatavaluedPropertyAtom ).castTo( DataPropertyAtom.class );
2ronwalf atom.setPropertyPredicate( p );
2ronwalf atom.setArgument1( arg1 );
2ronwalf atom.setArgument2( arg2 );
2ronwalf
2ronwalf return atom;
2ronwalf }
2ronwalf
2ronwalf public SameIndividualAtom createSameIndividualAtom(OWLIndividual arg1, OWLIndividual arg2) {
2ronwalf return createSameIndividualAtom(
2ronwalf (SWRLIndividualObject) arg1.castTo( SWRLIndividualObject.class ),
2ronwalf (SWRLIndividualObject) arg2.castTo( SWRLIndividualObject.class ) );
2ronwalf }
2ronwalf
2ronwalf public SameIndividualAtom createSameIndividualAtom(SWRLIndividualObject arg1, SWRLIndividualObject arg2) {
2ronwalf SameIndividualAtom atom = (SameIndividualAtom)
2ronwalf ont.createInstance( SWRL.SameIndividualAtom ).castTo( SameIndividualAtom.class );
2ronwalf atom.setArgument1( arg1 );
2ronwalf atom.setArgument2( arg2 );
2ronwalf
2ronwalf return atom;
2ronwalf }
2ronwalf
2ronwalf public DifferentIndividualsAtom createDifferentIndividualsAtom(OWLIndividual arg1, OWLIndividual arg2) {
2ronwalf return createDifferentIndividualsAtom(
2ronwalf (SWRLIndividualObject) arg1.castTo( SWRLIndividualObject.class ),
2ronwalf (SWRLIndividualObject) arg2.castTo( SWRLIndividualObject.class ) );
2ronwalf }
2ronwalf
2ronwalf public DifferentIndividualsAtom createDifferentIndividualsAtom(SWRLIndividualObject arg1, SWRLIndividualObject arg2) {
2ronwalf DifferentIndividualsAtom atom = (DifferentIndividualsAtom)
2ronwalf ont.createInstance( SWRL.DifferentIndividualsAtom ).castTo( DifferentIndividualsAtom.class );
2ronwalf atom.setArgument1( arg1 );
2ronwalf atom.setArgument2( arg2 );
2ronwalf
2ronwalf return atom;
2ronwalf }
2ronwalf
2ronwalf public BuiltinAtom createEqual(SWRLDataObject arg1, SWRLDataObject arg2) {
2ronwalf BuiltinAtom atom = (BuiltinAtom) ont.createInstance( SWRL.BuiltinAtom ).castTo( BuiltinAtom.class );
2ronwalf atom.setBuiltin( SWRLB.equal );
2ronwalf atom.setArgument( 0, arg1 );
2ronwalf atom.setArgument( 1, arg2 );
2ronwalf
2ronwalf return atom;
2ronwalf }
2ronwalf
2ronwalf public BuiltinAtom createNotEqual(SWRLDataObject arg1, SWRLDataObject arg2) {
2ronwalf BuiltinAtom atom = (BuiltinAtom) ont.createInstance( SWRL.BuiltinAtom ).castTo( BuiltinAtom.class );
2ronwalf atom.setBuiltin( SWRLB.notEqual );
2ronwalf atom.setArgument( 0, arg1 );
2ronwalf atom.setArgument( 1, arg2 );
2ronwalf
2ronwalf return atom;
2ronwalf }
2ronwalf
2ronwalf public BuiltinAtom createLessThan(SWRLDataObject arg1, SWRLDataObject arg2) {
2ronwalf BuiltinAtom atom = (BuiltinAtom) ont.createInstance( SWRL.BuiltinAtom ).castTo( BuiltinAtom.class );
2ronwalf atom.setBuiltin( SWRLB.lessThan );
2ronwalf atom.setArgument( 0, arg1 );
2ronwalf atom.setArgument( 1, arg2 );
2ronwalf
2ronwalf return atom;
2ronwalf }
2ronwalf
2ronwalf public BuiltinAtom createLessThanOrEqual(SWRLDataObject arg1, SWRLDataObject arg2) {
2ronwalf BuiltinAtom atom = (BuiltinAtom) ont.createInstance( SWRL.BuiltinAtom ).castTo( BuiltinAtom.class );
2ronwalf atom.setBuiltin( SWRLB.lessThanOrEqual );
2ronwalf atom.setArgument( 0, arg1 );
2ronwalf atom.setArgument( 1, arg2 );
2ronwalf
2ronwalf return atom;
2ronwalf }
2ronwalf
2ronwalf public BuiltinAtom createGreaterThan(SWRLDataObject arg1, SWRLDataObject arg2) {
2ronwalf BuiltinAtom atom = (BuiltinAtom) ont.createInstance( SWRL.BuiltinAtom ).castTo( BuiltinAtom.class );
2ronwalf atom.setBuiltin( SWRLB.greaterThan );
2ronwalf atom.setArgument( 0, arg1 );
2ronwalf atom.setArgument( 1, arg2 );
2ronwalf
2ronwalf return atom;
2ronwalf }
2ronwalf
2ronwalf public BuiltinAtom createGreaterThanOrEqual(SWRLDataObject arg1, SWRLDataObject arg2) {
2ronwalf BuiltinAtom atom = (BuiltinAtom) ont.createInstance( SWRL.BuiltinAtom ).castTo( BuiltinAtom.class );
2ronwalf atom.setBuiltin( SWRLB.greaterThanOrEqual );
2ronwalf atom.setArgument( 0, arg1 );
2ronwalf atom.setArgument( 1, arg2 );
2ronwalf
2ronwalf return atom;
2ronwalf }
2ronwalf
2ronwalf public BuiltinAtom createAdd(OWLValue result, OWLValue arg1, OWLValue arg2) {
2ronwalf BuiltinAtom atom = (BuiltinAtom) ont.createInstance( SWRL.BuiltinAtom ).castTo( BuiltinAtom.class );
2ronwalf atom.setBuiltin( SWRLB.add );
2ronwalf atom.setArgument( 0, (SWRLDataObject) result.castTo( SWRLDataObject.class ) );
2ronwalf atom.setArgument( 1, (SWRLDataObject) arg1.castTo( SWRLDataObject.class ) );
2ronwalf atom.setArgument( 2, (SWRLDataObject) arg2.castTo( SWRLDataObject.class ) );
2ronwalf
2ronwalf return atom;
2ronwalf }
2ronwalf
2ronwalf public BuiltinAtom createSubtract(OWLValue result, OWLValue arg1, OWLValue arg2) {
2ronwalf BuiltinAtom atom = (BuiltinAtom) ont.createInstance( SWRL.BuiltinAtom ).castTo( BuiltinAtom.class );
2ronwalf atom.setBuiltin( SWRLB.subtract );
2ronwalf atom.setArgument( 0, (SWRLDataObject) result.castTo( SWRLDataObject.class ) );
2ronwalf atom.setArgument( 1, (SWRLDataObject) arg1.castTo( SWRLDataObject.class ) );
2ronwalf atom.setArgument( 2, (SWRLDataObject) arg2.castTo( SWRLDataObject.class ) );
2ronwalf
2ronwalf return atom;
2ronwalf }
2ronwalf
2ronwalf public BuiltinAtom createMultiply(OWLValue result, OWLValue arg1, OWLValue arg2) {
2ronwalf BuiltinAtom atom = (BuiltinAtom) ont.createInstance( SWRL.BuiltinAtom ).castTo( BuiltinAtom.class );
2ronwalf atom.setBuiltin( SWRLB.multiply );
2ronwalf atom.setArgument( 0, (SWRLDataObject) result.castTo( SWRLDataObject.class ) );
2ronwalf atom.setArgument( 1, (SWRLDataObject) arg1.castTo( SWRLDataObject.class ) );
2ronwalf atom.setArgument( 2, (SWRLDataObject) arg2.castTo( SWRLDataObject.class ) );
2ronwalf
2ronwalf return atom;
2ronwalf }
2ronwalf
2ronwalf public BuiltinAtom createDivide(OWLValue result, OWLValue arg1, OWLValue arg2) {
2ronwalf BuiltinAtom atom = (BuiltinAtom) ont.createInstance( SWRL.BuiltinAtom ).castTo( BuiltinAtom.class );
2ronwalf atom.setBuiltin( SWRLB.divide );
2ronwalf atom.setArgument( 0, (SWRLDataObject) result.castTo( SWRLDataObject.class ) );
2ronwalf atom.setArgument( 1, (SWRLDataObject) arg1.castTo( SWRLDataObject.class ) );
2ronwalf atom.setArgument( 2, (SWRLDataObject) arg2.castTo( SWRLDataObject.class ) );
2ronwalf
2ronwalf return atom;
2ronwalf }
2ronwalf
2ronwalf}