Search in sources :

Example 46 with OWLDataFactory

use of org.semanticweb.owlapi.model.OWLDataFactory in project stanbol by apache.

the class GreaterThanAtom method getOWLTypedLiteral.

private OWLLiteral getOWLTypedLiteral(Object argument) {
    OWLDataFactory factory = OWLManager.createOWLOntologyManager().getOWLDataFactory();
    OWLLiteral owlLiteral;
    if (argument instanceof String) {
        owlLiteral = factory.getOWLTypedLiteral((String) argument);
    } else if (argument instanceof Integer) {
        owlLiteral = factory.getOWLTypedLiteral(((Integer) argument).intValue());
    } else if (argument instanceof Double) {
        owlLiteral = factory.getOWLTypedLiteral(((Double) argument).doubleValue());
    } else if (argument instanceof Float) {
        owlLiteral = factory.getOWLTypedLiteral(((Float) argument).floatValue());
    } else if (argument instanceof Boolean) {
        owlLiteral = factory.getOWLTypedLiteral(((Boolean) argument).booleanValue());
    } else {
        owlLiteral = factory.getOWLStringLiteral(argument.toString());
    }
    return owlLiteral;
}
Also used : OWLLiteral(org.semanticweb.owlapi.model.OWLLiteral) OWLDataFactory(org.semanticweb.owlapi.model.OWLDataFactory)

Example 47 with OWLDataFactory

use of org.semanticweb.owlapi.model.OWLDataFactory in project stanbol by apache.

the class LessEqualThanAtom method getOWLTypedLiteral.

private OWLLiteral getOWLTypedLiteral(Object argument) {
    OWLDataFactory factory = OWLManager.createOWLOntologyManager().getOWLDataFactory();
    OWLLiteral owlLiteral;
    if (argument instanceof String) {
        owlLiteral = factory.getOWLTypedLiteral((String) argument);
    } else if (argument instanceof Integer) {
        owlLiteral = factory.getOWLTypedLiteral(((Integer) argument).intValue());
    } else if (argument instanceof Double) {
        owlLiteral = factory.getOWLTypedLiteral(((Double) argument).doubleValue());
    } else if (argument instanceof Float) {
        owlLiteral = factory.getOWLTypedLiteral(((Float) argument).floatValue());
    } else if (argument instanceof Boolean) {
        owlLiteral = factory.getOWLTypedLiteral(((Boolean) argument).booleanValue());
    } else {
        owlLiteral = factory.getOWLStringLiteral(argument.toString());
    }
    return owlLiteral;
}
Also used : OWLLiteral(org.semanticweb.owlapi.model.OWLLiteral) OWLDataFactory(org.semanticweb.owlapi.model.OWLDataFactory)

Example 48 with OWLDataFactory

use of org.semanticweb.owlapi.model.OWLDataFactory in project stanbol by apache.

the class LessThanAtom method getOWLTypedLiteral.

private OWLLiteral getOWLTypedLiteral(Object argument) {
    OWLDataFactory factory = OWLManager.createOWLOntologyManager().getOWLDataFactory();
    OWLLiteral owlLiteral;
    if (argument instanceof String) {
        owlLiteral = factory.getOWLTypedLiteral((String) argument);
    } else if (argument instanceof Integer) {
        owlLiteral = factory.getOWLTypedLiteral(((Integer) argument).intValue());
    } else if (argument instanceof Double) {
        owlLiteral = factory.getOWLTypedLiteral(((Double) argument).doubleValue());
    } else if (argument instanceof Float) {
        owlLiteral = factory.getOWLTypedLiteral(((Float) argument).floatValue());
    } else if (argument instanceof Boolean) {
        owlLiteral = factory.getOWLTypedLiteral(((Boolean) argument).booleanValue());
    } else {
        owlLiteral = factory.getOWLStringLiteral(argument.toString());
    }
    return owlLiteral;
}
Also used : OWLLiteral(org.semanticweb.owlapi.model.OWLLiteral) OWLDataFactory(org.semanticweb.owlapi.model.OWLDataFactory)

Example 49 with OWLDataFactory

use of org.semanticweb.owlapi.model.OWLDataFactory in project stanbol by apache.

the class SWRLAdapter method adaptRuleTo.

@SuppressWarnings("unchecked")
@Override
protected <T> T adaptRuleTo(Rule rule, Class<T> type) throws RuleAtomCallExeption, UnsupportedTypeForExportException, UnavailableRuleObjectException {
    if (type == SWRLRule.class) {
        OWLDataFactory factory = OWLManager.getOWLDataFactory();
        Set<SWRLAtom> bodyAtoms = new HashSet<SWRLAtom>();
        Set<SWRLAtom> headAtoms = new HashSet<SWRLAtom>();
        for (RuleAtom atom : rule.getBody()) {
            bodyAtoms.add((SWRLAtom) adaptRuleAtomTo(atom, SWRLRule.class));
        }
        for (RuleAtom atom : rule.getHead()) {
            headAtoms.add((SWRLAtom) adaptRuleAtomTo(atom, SWRLRule.class));
        }
        return (T) factory.getSWRLRule(bodyAtoms, headAtoms);
    } else {
        throw new UnsupportedTypeForExportException("The adapter " + getClass() + " does not support type : " + type.getCanonicalName());
    }
}
Also used : SWRLAtom(org.semanticweb.owlapi.model.SWRLAtom) UnsupportedTypeForExportException(org.apache.stanbol.rules.base.api.UnsupportedTypeForExportException) OWLDataFactory(org.semanticweb.owlapi.model.OWLDataFactory) RuleAtom(org.apache.stanbol.rules.base.api.RuleAtom) HashSet(java.util.HashSet)

Example 50 with OWLDataFactory

use of org.semanticweb.owlapi.model.OWLDataFactory in project stanbol by apache.

the class SWRLLiteralBuilder method getSWRLLiteral.

public static SWRLLiteralArgument getSWRLLiteral(Object argument) {
    OWLDataFactory factory = OWLManager.getOWLDataFactory();
    OWLLiteral owlLiteral;
    if (argument instanceof TypedLiteralAtom) {
        TypedLiteralAtom typedLiteralAtom = (TypedLiteralAtom) argument;
        URIResource xsdType = typedLiteralAtom.getXsdType();
        if (xsdType.getURI().equals(XSD.xboolean)) {
            owlLiteral = factory.getOWLLiteral(Boolean.valueOf(argument.toString()).booleanValue());
        } else if (xsdType.getURI().equals(XSD.xdouble)) {
            owlLiteral = factory.getOWLLiteral(Double.valueOf(argument.toString()).doubleValue());
        } else if (xsdType.getURI().equals(XSD.xfloat)) {
            owlLiteral = factory.getOWLLiteral(Float.valueOf(argument.toString()).floatValue());
        } else if (xsdType.getURI().equals(XSD.xint)) {
            owlLiteral = factory.getOWLLiteral(Integer.valueOf(argument.toString()).intValue());
        } else {
            owlLiteral = factory.getOWLLiteral(argument.toString());
        }
    } else if (argument instanceof String) {
        owlLiteral = factory.getOWLLiteral((String) argument);
    } else if (argument instanceof Integer) {
        owlLiteral = factory.getOWLLiteral(((Integer) argument).intValue());
    } else if (argument instanceof Double) {
        owlLiteral = factory.getOWLLiteral(((Double) argument).doubleValue());
    } else if (argument instanceof Float) {
        owlLiteral = factory.getOWLLiteral(((Float) argument).floatValue());
    } else if (argument instanceof Boolean) {
        owlLiteral = factory.getOWLLiteral(((Boolean) argument).booleanValue());
    } else {
        owlLiteral = factory.getOWLLiteral(argument.toString());
    }
    return factory.getSWRLLiteralArgument(owlLiteral);
}
Also used : URIResource(org.apache.stanbol.rules.base.api.URIResource) OWLLiteral(org.semanticweb.owlapi.model.OWLLiteral) OWLDataFactory(org.semanticweb.owlapi.model.OWLDataFactory) TypedLiteralAtom(org.apache.stanbol.rules.manager.atoms.TypedLiteralAtom)

Aggregations

OWLDataFactory (org.semanticweb.owlapi.model.OWLDataFactory)58 OWLOntologyCreationException (org.semanticweb.owlapi.model.OWLOntologyCreationException)24 OWLOntologyManager (org.semanticweb.owlapi.model.OWLOntologyManager)23 OWLOntology (org.semanticweb.owlapi.model.OWLOntology)21 ArgumentSWRLAtom (org.apache.stanbol.rules.adapters.swrl.ArgumentSWRLAtom)18 ArrayList (java.util.ArrayList)16 SWRLAtom (org.semanticweb.owlapi.model.SWRLAtom)16 RuleAtomCallExeption (org.apache.stanbol.rules.base.api.RuleAtomCallExeption)15 SWRLDArgument (org.semanticweb.owlapi.model.SWRLDArgument)15 SWRLRule (org.semanticweb.owlapi.model.SWRLRule)15 HigherOrderSWRLAtom (org.apache.stanbol.rules.adapters.swrl.HigherOrderSWRLAtom)12 OWLClass (org.semanticweb.owlapi.model.OWLClass)12 SWRLArgument (org.semanticweb.owlapi.model.SWRLArgument)12 IRI (org.semanticweb.owlapi.model.IRI)11 OWLLiteral (org.semanticweb.owlapi.model.OWLLiteral)11 OWLIndividual (org.semanticweb.owlapi.model.OWLIndividual)10 OWLObjectProperty (org.semanticweb.owlapi.model.OWLObjectProperty)10 HashSet (java.util.HashSet)9 ExpressionAtom (org.apache.stanbol.rules.manager.atoms.ExpressionAtom)9 OWLDataProperty (org.semanticweb.owlapi.model.OWLDataProperty)9