abstract class BinaryOperation { public abstract int apply(int a, int b); public UnaryOperation partial(final int a) { return new UnaryOperation() { public int apply(int b) { return BinaryOperation.this.apply(a, b); } }; } }
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()); } }
@SuppressWarnings("unchecked") @Override public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException { org.apache.stanbol.rules.manager.atoms.LowerCaseAtom tmp = (org.apache.stanbol.rules.manager.atoms.LowerCaseAtom) ruleAtom; StringFunctionAtom argument = tmp.getStringFunctionAtom(); ClerezzaSparqlObject argument1 = (ClerezzaSparqlObject) adapter.adaptTo(argument, ConstructQuery.class); List<Expression> argumentExpressions = new ArrayList<Expression>(); argumentExpressions.add((Expression) argument1.getClerezzaObject()); BuiltInCall builtInCall = new BuiltInCall("BOUND", argumentExpressions); UnaryOperation unaryOperation = new UnaryOperation("!", builtInCall); return (T) new ClerezzaSparqlObject(unaryOperation); }
jj_consume_token(64); e = PrimaryExpression(); {if (true) return new UnaryOperation("!", e);} break; case 61: jj_consume_token(61); e = PrimaryExpression(); {if (true) return new UnaryOperation("+", e);} break; case 62: jj_consume_token(62); e = PrimaryExpression(); {if (true) return new UnaryOperation("-", e);} break; case STR:
jj_consume_token(83); e = PrimaryExpression(); {if (true) return new UnaryOperation("!", e);} break; case 82: jj_consume_token(82); e = PrimaryExpression(); {if (true) return new UnaryOperation("+", e);} break; case 94: jj_consume_token(94); e = PrimaryExpression(); {if (true) return new UnaryOperation("-", e);} break; case GROUP_CONCAT:
jj_consume_token(64); e = PrimaryExpression(); {if (true) return new UnaryOperation("!", e);} break; case 61: jj_consume_token(61); e = PrimaryExpression(); {if (true) return new UnaryOperation("+", e);} break; case 62: jj_consume_token(62); e = PrimaryExpression(); {if (true) return new UnaryOperation("-", e);} break; case STR:
jj_consume_token(83); e = PrimaryExpression(); {if (true) return new UnaryOperation("!", e);} break; case 82: jj_consume_token(82); e = PrimaryExpression(); {if (true) return new UnaryOperation("+", e);} break; case 94: jj_consume_token(94); e = PrimaryExpression(); {if (true) return new UnaryOperation("-", e);} break; case GROUP_CONCAT: