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;
}
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;
}
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;
}
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());
}
}
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);
}
Aggregations