@SuppressWarnings("unchecked") @Override public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException { org.apache.stanbol.rules.manager.atoms.IsBlankAtom tmp = (org.apache.stanbol.rules.manager.atoms.IsBlankAtom) ruleAtom; IObjectAtom uriResource = tmp.getUriResource(); ClerezzaSparqlObject argumentCSO = (ClerezzaSparqlObject) adapter.adaptTo(uriResource, ConstructQuery.class); ; Object arg = argumentCSO.getClerezzaObject(); Expression argumentExpression; if (arg instanceof Variable) { argumentExpression = (Variable) arg; } else if (arg instanceof IRI) { argumentExpression = new UriRefExpression((IRI) arg); } else { throw new RuleAtomCallExeption(getClass()); } List<Expression> expressions = new ArrayList<Expression>(); expressions.add(argumentExpression); return (T) new ClerezzaSparqlObject(new BuiltInCall("isBLANK", expressions)); }
private void appendExpression(StringBuffer s, Expression e) { if (e instanceof Variable) { appendVariable(s, (Variable) e); } else if (e instanceof BinaryOperation) { BinaryOperation bo = (BinaryOperation) e; s.append("("); appendExpression(s, bo.getLhsOperand()); s.append(") ").append(bo.getOperatorString()).append(" ("); appendExpression(s, bo.getRhsOperand()); s.append(")"); } else if (e instanceof UnaryOperation) { UnaryOperation uo = (UnaryOperation) e; s.append(uo.getOperatorString()).append(" ("); appendExpression(s, uo.getOperand()); s.append(")"); } else if (e instanceof BuiltInCall) { BuiltInCall b = (BuiltInCall) e; appendCall(s, b.getName(), b.getArguements()); } else if (e instanceof FunctionCall) { FunctionCall f = (FunctionCall) e; appendCall(s, f.getName().getUnicodeString(), f.getArguements()); } else if (e instanceof LiteralExpression) { appendLiteralExpression(s, (LiteralExpression) e); } else if (e instanceof UriRefExpression) { s.append(((UriRefExpression) e).getUriRef().toString()); } }
private void appendExpression(StringBuffer s, Expression e) { if (e instanceof Variable) { appendVariable(s, (Variable) e); } else if (e instanceof BinaryOperation) { BinaryOperation bo = (BinaryOperation) e; s.append("("); appendExpression(s, bo.getLhsOperand()); s.append(") ").append(bo.getOperatorString()).append(" ("); appendExpression(s, bo.getRhsOperand()); s.append(")"); } else if (e instanceof UnaryOperation) { UnaryOperation uo = (UnaryOperation) e; s.append(uo.getOperatorString()).append(" ("); appendExpression(s, uo.getOperand()); s.append(")"); } else if (e instanceof BuiltInCall) { BuiltInCall b = (BuiltInCall) e; appendCall(s, b.getName(), b.getArguements()); } else if (e instanceof FunctionCall) { FunctionCall f = (FunctionCall) e; appendCall(s, f.getName().getUnicodeString(), f.getArguements()); } else if (e instanceof LiteralExpression) { appendLiteralExpression(s, (LiteralExpression) e); } else if (e instanceof UriRefExpression) { s.append(((UriRefExpression) e).getUriRef().toString()); } }
final private Expression IRIOrFunction() throws ParseException { IRI uriRef; List<Expression> args; uriRef = IRI(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 67: case NIL: args = ArgList(); {if (true) return new FunctionCall(uriRef, args);} break; default: jj_la1[142] = jj_gen; ; } {if (true) return new UriRefExpression(uriRef);} throw new Error("Missing return statement in function"); }
final private Expression IRIOrFunction() throws ParseException { IRI uriRef; List<Expression> args; uriRef = IRI(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 67: case NIL: args = ArgList(); {if (true) return new FunctionCall(uriRef, args);} break; default: jj_la1[142] = jj_gen; ; } {if (true) return new UriRefExpression(uriRef);} throw new Error("Missing return statement in function"); }
final private Expression IRIrefOrFunction() throws ParseException { IRI IRI; List<Expression> args; IRI = IRIref(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 46: case NIL: args = ArgList(); {if (true) return new FunctionCall(IRI, args);} break; default: jj_la1[65] = jj_gen; ; } {if (true) return new UriRefExpression(IRI);} throw new Error("Missing return statement in function"); }
final private Expression IRIrefOrFunction() throws ParseException { IRI IRI; List<Expression> args; IRI = IRIref(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 46: case NIL: args = ArgList(); {if (true) return new FunctionCall(IRI, args);} break; default: jj_la1[65] = jj_gen; ; } {if (true) return new UriRefExpression(IRI);} throw new Error("Missing return statement in function"); }