org.eclipse.rdf4j.query.algebra.ValueExpr Java Examples

The following examples show how to use org.eclipse.rdf4j.query.algebra.ValueExpr. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DistanceQuerySpec.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public DistanceQuerySpec(FunctionCall distanceFunction, ValueExpr distanceExpr, String distVar, Filter filter) {
	this.distanceFunction = distanceFunction;
	this.distanceExpr = distanceExpr;
	this.distanceVar = distVar;
	this.filter = filter;
	if (distanceFunction != null) {
		List<ValueExpr> args = distanceFunction.getArgs();
		this.from = getLiteral(args.get(0));
		this.geoVar = getVarName(args.get(1));
		this.units = getURI(args.get(2));
	} else {
		this.from = null;
		this.geoVar = null;
		this.units = null;
	}
	if (distanceExpr != null) {
		Literal dist = getLiteral(distanceExpr);
		this.distance = (dist != null) ? dist.doubleValue() : Double.NaN;
	} else {
		this.distance = Double.NaN;
	}
}
 
Example #2
Source File: HalyardValueExprEvaluation.java    From Halyard with Apache License 2.0 6 votes vote down vote up
/**
 * Evaluates a function.
 */
private Value evaluate(FunctionCall node, BindingSet bindings) throws ValueExprEvaluationException, QueryEvaluationException {
    Optional<Function> function = FunctionRegistry.getInstance().get(node.getURI());
    if (!function.isPresent()) {
        throw new QueryEvaluationException("Unknown function '" + node.getURI() + "'");
    }
    // the NOW function is a special case as it needs to keep a shared return
    // value for the duration of the query.
    if (function.get() instanceof Now) {
        return evaluate((Now) function.get(), bindings);
    }
    List<ValueExpr> args = node.getArgs();
    Value[] argValues = new Value[args.size()];
    for (int i = 0; i < args.size(); i++) {
        argValues[i] = evaluate(args.get(i), bindings);
    }
    return function.get().evaluate(valueFactory, argValues);
}
 
Example #3
Source File: TupleExprBuilder.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public Object visit(ASTServiceGraphPattern node, Object data) throws VisitorException {
	GraphPattern parentGP = graphPattern;

	ValueExpr serviceRef = (ValueExpr) node.jjtGetChild(0).jjtAccept(this, null);

	graphPattern = new GraphPattern(parentGP);
	node.jjtGetChild(1).jjtAccept(this, null);
	TupleExpr serviceExpr = graphPattern.buildTupleExpr();

	if (serviceExpr instanceof SingletonSet) {
		return null; // do not add an empty service block
	}

	String serviceExpressionString = node.getPatternString();

	parentGP.addRequiredTE(new Service(mapValueExprToVar(serviceRef), serviceExpr, serviceExpressionString,
			node.getPrefixDeclarations(), node.getBaseURI(), node.isSilent()));

	graphPattern = parentGP;

	return null;
}
 
Example #4
Source File: FilterRangeVisitor.java    From rya with Apache License 2.0 6 votes vote down vote up
@Override
public void meet(final Filter node) throws Exception {
    super.meet(node);

    final ValueExpr arg = node.getCondition();
    if (arg instanceof FunctionCall) {
        final FunctionCall fc = (FunctionCall) arg;
        if (RANGE.stringValue().equals(fc.getURI())) {
            //range(?var, start, end)
            final List<ValueExpr> valueExprs = fc.getArgs();
            if (valueExprs.size() != 3) {
                throw new QueryEvaluationException("org.apache:range must have 3 parameters: variable, start, end");
            }
            final Var var = (Var) valueExprs.get(0);
            final ValueConstant startVc = (ValueConstant) valueExprs.get(1);
            final ValueConstant endVc = (ValueConstant) valueExprs.get(2);
            final Value start = startVc.getValue();
            final Value end = endVc.getValue();
            rangeValues.put(var, new RangeValue(start, end));
            node.setCondition(new ValueConstant(BooleanLiteral.TRUE));
        }
    }
}
 
Example #5
Source File: StatementMetadataExternalSetProviderTest.java    From rya with Apache License 2.0 6 votes vote down vote up
@Test
public void createSingleMongoMetadataNode() throws MalformedQueryException {

    MongoDBRdfConfiguration conf = (MongoDBRdfConfiguration) getConf(true);
    Set<RyaIRI> propertySet = new HashSet<>();
    propertySet.add(new RyaIRI("http://createdBy"));
    conf.setStatementMetadataProperties(propertySet);
    StatementMetadataExternalSetProvider metaProvider = new StatementMetadataExternalSetProvider(conf);
    SPARQLParser parser = new SPARQLParser();
    ParsedQuery pq = parser.parseQuery(query, null);

    List<QueryModelNode> patterns = new ArrayList<>();
    List<StatementMetadataNode<?>> expected = new ArrayList<>();
    Set<StatementPattern> sp = StatementMetadataTestUtils.getMetadataStatementPatterns(pq.getTupleExpr(), propertySet);

    patterns.addAll(StatementPatternCollector.process(pq.getTupleExpr()));
    JoinSegment<StatementMetadataNode<?>> segment = new JoinSegment<>(
            new HashSet<>(patterns), patterns, new HashMap<ValueExpr, Filter>());
    List<StatementMetadataNode<?>> extSets = metaProvider.getExternalSets(segment);

    expected.add(new StatementMetadataNode<>(sp,conf));

    Assert.assertEquals(expected, extSets);

}
 
Example #6
Source File: UpdateExprBuilder.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public TupleExpr visit(ASTQuadsNotTriples node, Object data) throws VisitorException {
	GraphPattern parentGP = graphPattern;
	graphPattern = new GraphPattern();

	ValueExpr contextNode = (ValueExpr) node.jjtGetChild(0).jjtAccept(this, data);

	Var contextVar = mapValueExprToVar(contextNode);
	graphPattern.setContextVar(contextVar);
	graphPattern.setStatementPatternScope(Scope.NAMED_CONTEXTS);

	for (int i = 1; i < node.jjtGetNumChildren(); i++) {
		node.jjtGetChild(i).jjtAccept(this, data);
	}

	TupleExpr result = graphPattern.buildTupleExpr();
	parentGP.addRequiredTE(result);

	graphPattern = parentGP;

	return result;
}
 
Example #7
Source File: FilterUtils.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static ValueExpr toFilter(ConjunctiveFilterExpr filterExpr) throws FilterConversionException {
	List<FilterExpr> expressions = filterExpr.getExpressions();

	if (expressions.size() == 2) {
		return new And(expressions.get(0).getExpression(), expressions.get(0).getExpression());
	}

	And and = new And();
	and.setLeftArg(expressions.get(0).getExpression());
	And tmp = and;
	int idx;
	for (idx = 1; idx < expressions.size() - 1; idx++) {
		And _a = new And();
		_a.setLeftArg(expressions.get(idx).getExpression());
		tmp.setRightArg(_a);
		tmp = _a;
	}
	tmp.setRightArg(expressions.get(idx).getExpression());

	return and;
}
 
Example #8
Source File: TupleExprBuilder.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public List<ValueExpr> visit(ASTObjectList node, Object data) throws VisitorException {
	int childCount = node.jjtGetNumChildren();
	List<ValueExpr> result = new ArrayList<>(childCount);

	for (int i = 0; i < childCount; i++) {
		Object obj = node.jjtGetChild(i).jjtAccept(this, null);
		if (obj instanceof ValueExpr) {
			result.add((ValueExpr) obj);
		} else if (obj instanceof TripleRef) {
			result.add(((TripleRef) obj).getExprVar());
		}
	}

	return result;
}
 
Example #9
Source File: StrictEvaluationStrategy.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Evaluates a function.
 */
public Value evaluate(FunctionCall node, BindingSet bindings)
		throws QueryEvaluationException {
	Function function = FunctionRegistry.getInstance()
			.get(node.getURI())
			.orElseThrow(() -> new QueryEvaluationException("Unknown function '" + node.getURI() + "'"));

	// the NOW function is a special case as it needs to keep a shared
	// return
	// value for the duration of the query.
	if (function instanceof Now) {
		return evaluate((Now) function, bindings);
	}

	List<ValueExpr> args = node.getArgs();

	Value[] argValues = new Value[args.size()];

	for (int i = 0; i < args.size(); i++) {
		argValues[i] = evaluate(args.get(i), bindings);
	}

	return function.evaluate(tripleSource.getValueFactory(), argValues);

}
 
Example #10
Source File: StrictEvaluationStrategy.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public Value evaluate(Coalesce node, BindingSet bindings) throws ValueExprEvaluationException {
	Value result = null;

	for (ValueExpr expr : node.getArguments()) {
		try {
			result = evaluate(expr, bindings);

			// return first result that does not produce an error on
			// evaluation.
			break;
		} catch (QueryEvaluationException ignored) {
		}
	}

	if (result == null) {
		throw new ValueExprEvaluationException(
				"COALESCE arguments do not evaluate to a value: " + node.getSignature());
	}

	return result;
}
 
Example #11
Source File: SeparateFilterJoinsVisitor.java    From rya with Apache License 2.0 6 votes vote down vote up
@Override
public void meet(final Filter node) throws Exception {
    super.meet(node);

    final ValueExpr condition = node.getCondition();
    final TupleExpr arg = node.getArg();
    if (!(arg instanceof Join)) {
        return;
    }

    final Join join = (Join) arg;
    final TupleExpr leftArg = join.getLeftArg();
    final TupleExpr rightArg = join.getRightArg();

    if (leftArg instanceof StatementPattern && rightArg instanceof StatementPattern) {
        final Filter left = new Filter(leftArg, condition);
        final Filter right = new Filter(rightArg, condition);
        node.replaceWith(new Join(left, right));
    }

}
 
Example #12
Source File: TupleExprBuilder.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public If visit(ASTIf node, Object data) throws VisitorException {
	If result = null;

	if (node.jjtGetNumChildren() < 3) {
		throw new VisitorException("IF construction missing required number of arguments");
	}

	ValueExpr condition = (ValueExpr) node.jjtGetChild(0).jjtAccept(this, null);
	ValueExpr resultExpr = (ValueExpr) node.jjtGetChild(1).jjtAccept(this, null);
	ValueExpr alternative = (ValueExpr) node.jjtGetChild(2).jjtAccept(this, null);

	result = new If(condition, resultExpr, alternative);

	return result;
}
 
Example #13
Source File: TupleExprBuilder.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public Object visit(ASTOptionalGraphPattern node, Object data) throws VisitorException {
	GraphPattern parentGP = graphPattern;
	graphPattern = new GraphPattern(parentGP);

	super.visit(node, null);

	// remove filter conditions from graph pattern for inclusion as conditions in the OptionalTE
	List<ValueExpr> optionalConstraints = graphPattern.removeAllConstraints();
	TupleExpr optional = graphPattern.buildTupleExpr();

	graphPattern = parentGP;
	graphPattern.addOptionalTE(optional, optionalConstraints);

	return null;
}
 
Example #14
Source File: QueryModelNormalizer.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void meet(Filter node) {
	super.meet(node);

	TupleExpr arg = node.getArg();
	ValueExpr condition = node.getCondition();

	if (arg instanceof EmptySet) {
		// see #meetUnaryTupleOperator
	} else if (condition instanceof ValueConstant) {
		boolean conditionValue;
		try {
			conditionValue = QueryEvaluationUtil.getEffectiveBooleanValue(((ValueConstant) condition).getValue());
		} catch (ValueExprEvaluationException e) {
			conditionValue = false;
		}

		if (conditionValue == false) {
			// Constraint is always false
			node.replaceWith(new EmptySet());
		} else {
			node.replaceWith(arg);
		}
	}
}
 
Example #15
Source File: RegexAsStringFunctionOptimizer.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void meet(Regex node) {
	final ValueExpr flagsArg = node.getFlagsArg();
	if (flagsArg == null || flagsArg.toString().isEmpty()) {
		// if we have no flags then we can not be in case insensitive mode
		if (node.getPatternArg() instanceof ValueConstant) {
			ValueConstant vc = (ValueConstant) node.getPatternArg();
			String regex = vc.getValue().stringValue();
			final boolean anchoredAtStart = regex.startsWith("^");
			final boolean anchoredAtEnd = regex.endsWith("$");

			if (anchoredAtStart && anchoredAtEnd) {
				equalsCandidate(node, regex);
			} else if (anchoredAtStart) {
				strstartsCandidate(node, regex);
			} else if (anchoredAtEnd) {
				strendsCandidate(node, regex);
			} else {
				containsCandidate(node, regex);
			}
		}
	}
	super.meet(node);
}
 
Example #16
Source File: QueryModelBuilder.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public Like visit(ASTLike node, Object data) throws VisitorException {
	ValueExpr expr = (ValueExpr) node.getValueExpr().jjtAccept(this, null);
	String pattern = (String) node.getPattern().jjtAccept(this, null);
	boolean caseSensitive = !node.ignoreCase();

	return new Like(expr, pattern, caseSensitive);
}
 
Example #17
Source File: GeoRelationQuerySpecBuilder.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static Filter getFilter(QueryModelNode node, String varName) {
	Filter filter = null;
	if (node instanceof Filter) {
		Filter f = (Filter) node;
		ValueExpr condition = f.getCondition();
		if (varName.equals(getVarName(condition))) {
			filter = f;
		}
	} else if (node != null) {
		filter = getFilter(node.getParentNode(), varName);
	}
	return filter;
}
 
Example #18
Source File: StatementMetadataExternalSetProviderTest.java    From rya with Apache License 2.0 5 votes vote down vote up
@Test
public void createMultipleMetadataNode() throws MalformedQueryException {

    MongoDBRdfConfiguration conf = (MongoDBRdfConfiguration) getConf(true);
    Set<RyaIRI> propertySet = new HashSet<>();
    propertySet.add(new RyaIRI("http://createdBy"));
    propertySet.add(new RyaIRI("http://createdOn"));
    conf.setStatementMetadataProperties(propertySet);
    StatementMetadataExternalSetProvider metaProvider = new StatementMetadataExternalSetProvider(conf);
    SPARQLParser parser = new SPARQLParser();
    ParsedQuery pq2 = parser.parseQuery(query2, null);
    ParsedQuery pq3 = parser.parseQuery(query3, null);
    ParsedQuery pq1 = parser.parseQuery(query, null);

    List<QueryModelNode> patterns = new ArrayList<>();
    List<StatementMetadataNode<?>> expected = new ArrayList<>();
    Set<StatementPattern> sp1 = StatementMetadataTestUtils.getMetadataStatementPatterns(pq1.getTupleExpr(), propertySet);
    Set<StatementPattern> sp3 = StatementMetadataTestUtils.getMetadataStatementPatterns(pq3.getTupleExpr(), propertySet);
    //added extra blankNode into query3 to make blankNode names line up with query2.  Need to remove it now so that
    //StatementMetadataNode doesn't blow up because all subjects aren't the same.
    removePatternWithGivenSubject(VarNameUtils.prependAnonymous("1"), sp3);

    patterns.addAll(StatementPatternCollector.process(pq2.getTupleExpr()));
    JoinSegment<StatementMetadataNode<?>> segment = new JoinSegment<>(
            new HashSet<>(patterns), patterns, new HashMap<ValueExpr, Filter>());
    List<StatementMetadataNode<?>> extSets = metaProvider.getExternalSets(segment);

    expected.add(new StatementMetadataNode<>(sp1,conf));
    expected.add(new StatementMetadataNode<>(sp3,conf));

    Assert.assertEquals(expected, extSets);
}
 
Example #19
Source File: TupleFunctionEvaluationStrategy.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(TupleFunctionCall expr,
		BindingSet bindings) throws QueryEvaluationException {
	TupleFunction func = tupleFuncRegistry.get(expr.getURI())
			.orElseThrow(() -> new QueryEvaluationException("Unknown tuple function '" + expr.getURI() + "'"));

	List<ValueExpr> args = expr.getArgs();

	Value[] argValues = new Value[args.size()];
	for (int i = 0; i < args.size(); i++) {
		argValues[i] = evaluate(args.get(i), bindings);
	}

	return evaluate(func, expr.getResultVars(), bindings, tripleSource.getValueFactory(), argValues);
}
 
Example #20
Source File: QueryModelNormalizer.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void meet(LeftJoin leftJoin) {
	super.meet(leftJoin);

	TupleExpr leftArg = leftJoin.getLeftArg();
	TupleExpr rightArg = leftJoin.getRightArg();
	ValueExpr condition = leftJoin.getCondition();

	if (leftArg instanceof EmptySet) {
		leftJoin.replaceWith(leftArg);
	} else if (rightArg instanceof EmptySet) {
		leftJoin.replaceWith(leftArg);
	} else if (rightArg instanceof SingletonSet) {
		leftJoin.replaceWith(leftArg);
	} else if (condition instanceof ValueConstant) {
		boolean conditionValue;
		try {
			conditionValue = QueryEvaluationUtil.getEffectiveBooleanValue(((ValueConstant) condition).getValue());
		} catch (ValueExprEvaluationException e) {
			conditionValue = false;
		}

		if (conditionValue == false) {
			// Constraint is always false
			leftJoin.replaceWith(leftArg);
		} else {
			leftJoin.setCondition(null);
		}
	}
}
 
Example #21
Source File: QueryModelBuilder.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public CompareAny visit(ASTCompareAny node, Object data) throws VisitorException {
	ValueExpr valueExpr = (ValueExpr) node.getLeftOperand().jjtAccept(this, null);
	TupleExpr tupleExpr = (TupleExpr) node.getRightOperand().jjtAccept(this, null);
	CompareOp op = node.getOperator().getValue();

	return new CompareAny(valueExpr, tupleExpr, op);
}
 
Example #22
Source File: TupleExprBuilder.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Retrieve the associated Value (if any) for the given valueExpr.
 *
 * @param valueExpr
 * @return the value of the given ValueExpr, or null if no value exists.
 * @throws IllegalArgumentException if the supplied ValueExpr is null or of an unexpected type.
 */
protected Value getValueForExpr(ValueExpr valueExpr) {
	if (valueExpr instanceof Var) {
		return ((Var) valueExpr).getValue();
	} else if (valueExpr instanceof ValueConstant) {
		ValueConstant vc = (ValueConstant) valueExpr;
		return vc.getValue();
	} else if (valueExpr == null) {
		throw new IllegalArgumentException("valueExpr is null");
	} else {
		throw new IllegalArgumentException("valueExpr is a: " + valueExpr.getClass());
	}
}
 
Example #23
Source File: HalyardValueExprEvaluation.java    From Halyard with Apache License 2.0 5 votes vote down vote up
/**
 * Determines the "effective boolean value" of the {@link Value} returned by evaluating the expression.
 * See {@link QueryEvaluationUtil#getEffectiveBooleanValue(Value)} for the definition of "effective boolean value.
 * @param expr
 * @param bindings the set of named value bindings
 * @return
 * @throws QueryEvaluationException
 */
boolean isTrue(ValueExpr expr, BindingSet bindings) throws QueryEvaluationException {
    try {
        Value value = evaluate(expr, bindings);
        return QueryEvaluationUtil.getEffectiveBooleanValue(value);
    } catch (ValueExprEvaluationException e) {
        return false;
    }
}
 
Example #24
Source File: PeriodicQueryUtil.java    From rya with Apache License 2.0 5 votes vote down vote up
/**
 * 
 * @param values - Values extracted from FunctionCall representing the PeriodicQuery Filter
 * @param arg - Argument of the PeriodicQueryNode that will be created (PeriodicQueryNode is a UnaryTupleOperator)
 * @return - PeriodicQueryNode to be inserted in place of the original FunctionCall
 * @throws Exception
 */
private static PeriodicQueryNode parseAndSetValues(List<ValueExpr> values, TupleExpr arg) throws Exception {
    // general validation of input
    Preconditions.checkArgument(values.size() == 4);
    Preconditions.checkArgument(values.get(0) instanceof Var);
    Preconditions.checkArgument(values.get(1) instanceof ValueConstant);
    Preconditions.checkArgument(values.get(2) instanceof ValueConstant);
    Preconditions.checkArgument(values.get(3) instanceof ValueConstant);

    // get temporal variable
    Var var = (Var) values.get(0);
    Preconditions.checkArgument(var.getValue() == null);
    String tempVar = var.getName();

    // get TimeUnit
    TimeUnit unit = getTimeUnit((ValueConstant) values.get(3));

    // get window and period durations
    double windowDuration = parseTemporalDuration((ValueConstant) values.get(1));
    double periodDuration = parseTemporalDuration((ValueConstant) values.get(2));
    long windowMillis = convertToMillis(windowDuration, unit);
    long periodMillis = convertToMillis(periodDuration, unit);
    // period must evenly divide window at least once
    Preconditions.checkArgument(windowMillis > periodMillis);
    Preconditions.checkArgument(windowMillis % periodMillis == 0, "Period duration does not evenly divide window duration.");

    // create PeriodicMetadata.Builder
    return new PeriodicQueryNode(windowMillis, periodMillis, TimeUnit.MILLISECONDS, tempVar, arg);
}
 
Example #25
Source File: DistanceQuerySpec.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
static Literal getLiteral(ValueExpr v) {
	Value value = getValue(v);
	if (value instanceof Literal) {
		return (Literal) value;
	}
	return null;
}
 
Example #26
Source File: FlattenedOptional.java    From rya with Apache License 2.0 5 votes vote down vote up
@Override
public boolean equals(Object other) {
    if (other instanceof FlattenedOptional) {
        FlattenedOptional ljDec = (FlattenedOptional) other;
        ValueExpr oCond = ljDec.getCondition();
        return nullEquals(condition, oCond) && ljDec.getRightArgs().equals(rightArgs);
    }
    return false;
}
 
Example #27
Source File: ParallelLeftJoinCursor.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public String toString() {
	String left = leftIter.toString().replace("\n", LF_TAB);
	CloseableIteration<BindingSet, QueryEvaluationException> nextRightIter = rightIter;
	String right = (null == nextRightIter) ? join.getRightArg().toString() : nextRightIter.toString();
	ValueExpr condition = join.getCondition();
	String filter = (null == condition) ? "" : condition.toString().trim().replace("\n", LF_TAB);
	return "ParallelLeftJoin " + filter + LF_TAB + left + LF_TAB + right.replace("\n", LF_TAB);
}
 
Example #28
Source File: DistanceQuerySpec.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
static String getVarName(ValueExpr v) {
	if (v instanceof Var) {
		Var var = (Var) v;
		if (!var.isConstant()) {
			return var.getName();
		}
	}
	return null;
}
 
Example #29
Source File: GeoRelationQuerySpecBuilder.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static Value getValue(ValueExpr v) {
	Value value = null;
	if (v instanceof ValueConstant) {
		value = ((ValueConstant) v).getValue();
	} else if (v instanceof Var) {
		value = ((Var) v).getValue();
	}
	return value;
}
 
Example #30
Source File: GeoRelationQuerySpecBuilder.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static Literal getLiteral(ValueExpr v) {
	Value value = getValue(v);
	if (value instanceof Literal) {
		return (Literal) value;
	}
	return null;
}