Java源码示例:org.eclipse.rdf4j.query.algebra.Bound
示例1
@Override
public void meet(Bound node) throws RDFHandlerException {
Resource currentSubj = subject;
flushPendingStatement();
handler.handleStatement(valueFactory.createStatement(subject, RDF.TYPE, SP.BOUND));
predicate = SP.ARG1_PROPERTY;
node.getArg().visit(this);
subject = currentSubj;
predicate = null;
}
示例2
public Value evaluate(Bound node, BindingSet bindings) throws QueryEvaluationException {
try {
Value argValue = evaluate(node.getArg(), bindings);
return BooleanLiteral.valueOf(argValue != null);
} catch (ValueExprEvaluationException e) {
return BooleanLiteral.FALSE;
}
}
示例3
@Override
public void meet(Bound bound) {
super.meet(bound);
if (bound.getArg().hasValue()) {
// variable is always bound
bound.replaceWith(new ValueConstant(BooleanLiteral.TRUE));
}
}
示例4
/**
* @inheritDoc
*/
@Override
public void meet(Bound theOp) throws Exception {
mBuffer.append(" bound(");
theOp.getArg().visit(this);
mBuffer.append(")");
}
示例5
/**
* @inheritDoc
*/
@Override
public void meet(Bound theOp) throws Exception {
mBuffer.append(" bound(");
theOp.getArg().visit(this);
mBuffer.append(")");
}
示例6
/**
* Evaluate a {@link Bound} node
* @param node the node to evaluate
* @param bindings the set of named value bindings
* @return {@link BooleanLiteral#TRUE} if the node can be evaluated or {@link BooleanLiteral#FALSE} if an exception occurs
* @throws QueryEvaluationException
*/
private Value evaluate(Bound node, BindingSet bindings) throws QueryEvaluationException {
try {
evaluate(node.getArg(), bindings);
return BooleanLiteral.TRUE;
} catch (ValueExprEvaluationException e) {
return BooleanLiteral.FALSE;
}
}
示例7
/**
* @inheritDoc
*/
@Override
public void meet(Bound theOp)
throws Exception
{
mBuffer.append(" bound(");
theOp.getArg().visit(this);
mBuffer.append(")");
}
示例8
@Override
public Value evaluate(ValueExpr expr, BindingSet bindings)
throws QueryEvaluationException {
if (expr instanceof Var) {
return evaluate((Var) expr, bindings);
} else if (expr instanceof ValueConstant) {
return evaluate((ValueConstant) expr, bindings);
} else if (expr instanceof BNodeGenerator) {
return evaluate((BNodeGenerator) expr, bindings);
} else if (expr instanceof Bound) {
return evaluate((Bound) expr, bindings);
} else if (expr instanceof Str) {
return evaluate((Str) expr, bindings);
} else if (expr instanceof Label) {
return evaluate((Label) expr, bindings);
} else if (expr instanceof Lang) {
return evaluate((Lang) expr, bindings);
} else if (expr instanceof LangMatches) {
return evaluate((LangMatches) expr, bindings);
} else if (expr instanceof Datatype) {
return evaluate((Datatype) expr, bindings);
} else if (expr instanceof Namespace) {
return evaluate((Namespace) expr, bindings);
} else if (expr instanceof LocalName) {
return evaluate((LocalName) expr, bindings);
} else if (expr instanceof IsResource) {
return evaluate((IsResource) expr, bindings);
} else if (expr instanceof IsURI) {
return evaluate((IsURI) expr, bindings);
} else if (expr instanceof IsBNode) {
return evaluate((IsBNode) expr, bindings);
} else if (expr instanceof IsLiteral) {
return evaluate((IsLiteral) expr, bindings);
} else if (expr instanceof IsNumeric) {
return evaluate((IsNumeric) expr, bindings);
} else if (expr instanceof IRIFunction) {
return evaluate((IRIFunction) expr, bindings);
} else if (expr instanceof Regex) {
return evaluate((Regex) expr, bindings);
} else if (expr instanceof Coalesce) {
return evaluate((Coalesce) expr, bindings);
} else if (expr instanceof Like) {
return evaluate((Like) expr, bindings);
} else if (expr instanceof FunctionCall) {
return evaluate((FunctionCall) expr, bindings);
} else if (expr instanceof And) {
return evaluate((And) expr, bindings);
} else if (expr instanceof Or) {
return evaluate((Or) expr, bindings);
} else if (expr instanceof Not) {
return evaluate((Not) expr, bindings);
} else if (expr instanceof SameTerm) {
return evaluate((SameTerm) expr, bindings);
} else if (expr instanceof Compare) {
return evaluate((Compare) expr, bindings);
} else if (expr instanceof MathExpr) {
return evaluate((MathExpr) expr, bindings);
} else if (expr instanceof In) {
return evaluate((In) expr, bindings);
} else if (expr instanceof CompareAny) {
return evaluate((CompareAny) expr, bindings);
} else if (expr instanceof CompareAll) {
return evaluate((CompareAll) expr, bindings);
} else if (expr instanceof Exists) {
return evaluate((Exists) expr, bindings);
} else if (expr instanceof If) {
return evaluate((If) expr, bindings);
} else if (expr instanceof ListMemberOperator) {
return evaluate((ListMemberOperator) expr, bindings);
} else if (expr instanceof ValueExprTripleRef) {
return evaluate((ValueExprTripleRef) expr, bindings);
} else if (expr == null) {
throw new IllegalArgumentException("expr must not be null");
} else {
throw new QueryEvaluationException("Unsupported value expr type: " + expr.getClass());
}
}
示例9
@Override
public void meet(Bound node) throws X {
meetNode(node);
}
示例10
public GroupBuilder<T, E> bound(String theVar) {
return filter(new Bound(new Var(theVar)));
}
示例11
public static Bound bound(String theVar) {
return new Bound(new Var(theVar));
}
示例12
@Override
public ValueExpr visit(ASTBound node, Object data) throws VisitorException {
Var var = (Var) node.getArg().jjtAccept(this, null);
return new Bound(var);
}
示例13
@Override
public Bound visit(ASTBound node, Object data) throws VisitorException {
return new Bound((Var) super.visit(node, data));
}
示例14
/**
* Determines which evaluate method to call based on the type of {@link ValueExpr}
* @param expr the expression to evaluate
* @param bindings the set of named value bindings the set of named value bindings
* @return the {@link Value} resulting from the evaluation
* @throws ValueExprEvaluationException
* @throws QueryEvaluationException
*/
Value evaluate(ValueExpr expr, BindingSet bindings) throws ValueExprEvaluationException, QueryEvaluationException {
if (expr instanceof Var) {
return evaluate((Var) expr, bindings);
} else if (expr instanceof ValueConstant) {
return evaluate((ValueConstant) expr, bindings);
} else if (expr instanceof BNodeGenerator) {
return evaluate((BNodeGenerator) expr, bindings);
} else if (expr instanceof Bound) {
return evaluate((Bound) expr, bindings);
} else if (expr instanceof Str) {
return evaluate((Str) expr, bindings);
} else if (expr instanceof Label) {
return evaluate((Label) expr, bindings);
} else if (expr instanceof Lang) {
return evaluate((Lang) expr, bindings);
} else if (expr instanceof LangMatches) {
return evaluate((LangMatches) expr, bindings);
} else if (expr instanceof Datatype) {
return evaluate((Datatype) expr, bindings);
} else if (expr instanceof Namespace) {
return evaluate((Namespace) expr, bindings);
} else if (expr instanceof LocalName) {
return evaluate((LocalName) expr, bindings);
} else if (expr instanceof IsResource) {
return evaluate((IsResource) expr, bindings);
} else if (expr instanceof IsURI) {
return evaluate((IsURI) expr, bindings);
} else if (expr instanceof IsBNode) {
return evaluate((IsBNode) expr, bindings);
} else if (expr instanceof IsLiteral) {
return evaluate((IsLiteral) expr, bindings);
} else if (expr instanceof IsNumeric) {
return evaluate((IsNumeric) expr, bindings);
} else if (expr instanceof IRIFunction) {
return evaluate((IRIFunction) expr, bindings);
} else if (expr instanceof Regex) {
return evaluate((Regex) expr, bindings);
} else if (expr instanceof Coalesce) {
return evaluate((Coalesce) expr, bindings);
} else if (expr instanceof Like) {
return evaluate((Like) expr, bindings);
} else if (expr instanceof FunctionCall) {
return evaluate((FunctionCall) expr, bindings);
} else if (expr instanceof And) {
return evaluate((And) expr, bindings);
} else if (expr instanceof Or) {
return evaluate((Or) expr, bindings);
} else if (expr instanceof Not) {
return evaluate((Not) expr, bindings);
} else if (expr instanceof SameTerm) {
return evaluate((SameTerm) expr, bindings);
} else if (expr instanceof Compare) {
return evaluate((Compare) expr, bindings);
} else if (expr instanceof MathExpr) {
return evaluate((MathExpr) expr, bindings);
} else if (expr instanceof In) {
return evaluate((In) expr, bindings);
} else if (expr instanceof CompareAny) {
return evaluate((CompareAny) expr, bindings);
} else if (expr instanceof CompareAll) {
return evaluate((CompareAll) expr, bindings);
} else if (expr instanceof Exists) {
return evaluate((Exists) expr, bindings);
} else if (expr instanceof If) {
return evaluate((If) expr, bindings);
} else if (expr instanceof ListMemberOperator) {
return evaluate((ListMemberOperator) expr, bindings);
} else if (expr == null) {
throw new IllegalArgumentException("expr must not be null");
} else {
throw new QueryEvaluationException("Unsupported value expr type: " + expr.getClass());
}
}