use of org.apache.stanbol.rules.manager.atoms.VariableAtom in project stanbol by apache.
the class LetAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
org.apache.stanbol.rules.manager.atoms.LetAtom tmp = (org.apache.stanbol.rules.manager.atoms.LetAtom) ruleAtom;
StringFunctionAtom parameterFunctionAtom = tmp.getParameterFunctionAtom();
URIResource variableUriResource = tmp.getVariable();
ClerezzaSparqlObject iriArgument;
iriArgument = (ClerezzaSparqlObject) adapter.adaptTo(parameterFunctionAtom, ConstructQuery.class);
List<Expression> iriArgumentExpressions = new ArrayList<Expression>();
iriArgumentExpressions.add((Expression) iriArgument.getClerezzaObject());
BuiltInCall iriBuiltInCall = new BuiltInCall("IRI", iriArgumentExpressions);
if (variableUriResource instanceof VariableAtom) {
String variableName = ((VariableAtom) variableUriResource).getVariableName();
Variable variable = new Variable(variableName);
List<Expression> bindArgumentExpressions = new ArrayList<Expression>();
bindArgumentExpressions.add(iriBuiltInCall);
bindArgumentExpressions.add(variable);
BuiltInCall bindBuiltInCall = new BuiltInCall("BIND", iriArgumentExpressions);
return (T) new ClerezzaSparqlObject(bindBuiltInCall);
} else {
throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
}
}
use of org.apache.stanbol.rules.manager.atoms.VariableAtom in project stanbol by apache.
the class RuleParserImpl method variable.
public final IObjectAtom variable() throws ParseException {
Token t;
String var;
switch((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
case NOTEX:
jj_consume_token(NOTEX);
jj_consume_token(LPAR);
t = jj_consume_token(VARIABLE);
jj_consume_token(RPAR);
var = t.image;
var = kb.getPrefixURI("var") + var.substring(1);
try {
{
if (true)
return new VariableAtom(new URI(var), true);
}
} catch (URISyntaxException e) {
e.printStackTrace();
{
if (true)
return null;
}
}
break;
case VARIABLE:
t = jj_consume_token(VARIABLE);
var = t.image;
var = kb.getPrefixURI("var") + var.substring(1);
try {
{
if (true)
return new VariableAtom(new URI(var), false);
}
} catch (URISyntaxException e) {
e.printStackTrace();
{
if (true)
return null;
}
}
break;
case BNODE:
t = jj_consume_token(BNODE);
var = t.image;
{
if (true)
return new RuleBlankNode(var);
}
break;
default:
jj_la1[15] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
throw new Error("Missing return statement in function");
}
Aggregations