use of org.apache.stanbol.rules.manager.atoms.NumberAtom in project stanbol by apache.
the class TypedLiteralAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption {
org.apache.stanbol.rules.manager.atoms.TypedLiteralAtom tmp = (org.apache.stanbol.rules.manager.atoms.TypedLiteralAtom) ruleAtom;
ExpressionAtom expressionAtom = tmp.getValue();
Literal literal = null;
if (expressionAtom instanceof StringAtom) {
String value = expressionAtom.toString();
literal = LiteralFactory.getInstance().createTypedLiteral(value);
} else if (expressionAtom instanceof NumberAtom) {
Number number = ((NumberAtom) expressionAtom).getNumberValue();
literal = LiteralFactory.getInstance().createTypedLiteral(number);
} else {
throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
}
LiteralExpression literalExpression = new LiteralExpression(literal);
return (T) new ClerezzaSparqlObject(literalExpression);
}
Aggregations