Search in sources :

Example 1 with NumberAtom

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);
}
Also used : StringAtom(org.apache.stanbol.rules.manager.atoms.StringAtom) LiteralExpression(org.apache.clerezza.rdf.core.sparql.query.LiteralExpression) RuleAtomCallExeption(org.apache.stanbol.rules.base.api.RuleAtomCallExeption) ExpressionAtom(org.apache.stanbol.rules.manager.atoms.ExpressionAtom) NumberAtom(org.apache.stanbol.rules.manager.atoms.NumberAtom) Literal(org.apache.clerezza.commons.rdf.Literal) ClerezzaSparqlObject(org.apache.stanbol.rules.adapters.clerezza.ClerezzaSparqlObject)

Aggregations

Literal (org.apache.clerezza.commons.rdf.Literal)1 LiteralExpression (org.apache.clerezza.rdf.core.sparql.query.LiteralExpression)1 ClerezzaSparqlObject (org.apache.stanbol.rules.adapters.clerezza.ClerezzaSparqlObject)1 RuleAtomCallExeption (org.apache.stanbol.rules.base.api.RuleAtomCallExeption)1 ExpressionAtom (org.apache.stanbol.rules.manager.atoms.ExpressionAtom)1 NumberAtom (org.apache.stanbol.rules.manager.atoms.NumberAtom)1 StringAtom (org.apache.stanbol.rules.manager.atoms.StringAtom)1