Java Code Examples for org.eclipse.rdf4j.model.impl.BooleanLiteral#FALSE
The following examples show how to use
org.eclipse.rdf4j.model.impl.BooleanLiteral#FALSE .
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: FederationEvalStrategy.java From CostFed with GNU Affero General Public License v3.0 | 6 votes |
public Value evaluate(ConjunctiveFilterExpr node, BindingSet bindings) { ValueExprEvaluationException error = null; for (FilterExpr expr : node.getExpressions()) { try { Value v = evaluate(expr.getExpression(), bindings); if (QueryEvaluationUtil.getEffectiveBooleanValue(v) == false) { return BooleanLiteral.FALSE; } } catch (ValueExprEvaluationException e) { error = e; } } if (error!=null) throw error; return BooleanLiteral.TRUE; }
Example 2
Source File: FederationEvalStrategy.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
public Value evaluate(ConjunctiveFilterExpr node, BindingSet bindings) throws ValueExprEvaluationException, QueryEvaluationException { ValueExprEvaluationException error = null; for (FilterExpr expr : node.getExpressions()) { try { Value v = evaluate(expr.getExpression(), bindings); if (QueryEvaluationUtil.getEffectiveBooleanValue(v) == false) { return BooleanLiteral.FALSE; } } catch (ValueExprEvaluationException e) { error = e; } } if (error != null) { throw error; } return BooleanLiteral.TRUE; }
Example 3
Source File: HasAllObjects.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public Value evaluate(ValueFactory valueFactory, Value... args) throws ValueExprEvaluationException { QueryPreparer qp = getCurrentQueryPreparer(); if (args.length != 3) { throw new ValueExprEvaluationException( String.format("%s requires 3 argument, got %d", getURI(), args.length)); } Resource subj = (Resource) args[0]; IRI pred = (IRI) args[1]; Resource list = (Resource) args[2]; try { Iteration<Value, QueryEvaluationException> iter = TripleSources.list(list, qp.getTripleSource()); while (iter.hasNext()) { Value obj = iter.next(); if (TripleSources.single(subj, pred, obj, qp.getTripleSource()) == null) { return BooleanLiteral.FALSE; } } } catch (QueryEvaluationException e) { throw new ValueExprEvaluationException(e); } return BooleanLiteral.TRUE; }
Example 4
Source File: StrictEvaluationStrategy.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
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; } }
Example 5
Source File: StrictEvaluationStrategy.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Determines whether the operand (a variable) contains a numeric datatyped literal, i.e. a literal with datatype * xsd:float, xsd:double, xsd:decimal, or a derived datatype of xsd:decimal. * * @return <tt>true</tt> if the operand contains a numeric datatyped literal, <tt>false</tt> otherwise. */ public Value evaluate(IsNumeric node, BindingSet bindings) throws QueryEvaluationException { Value argValue = evaluate(node.getArg(), bindings); if (argValue instanceof Literal) { Literal lit = (Literal) argValue; IRI datatype = lit.getDatatype(); return BooleanLiteral.valueOf(XMLDatatypeUtil.isNumericDatatype(datatype)); } else { return BooleanLiteral.FALSE; } }
Example 6
Source File: HalyardValueExprEvaluation.java From Halyard with Apache License 2.0 | 5 votes |
/** * 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; } }
Example 7
Source File: HalyardValueExprEvaluation.java From Halyard with Apache License 2.0 | 5 votes |
/** * Determines whether the operand (a variable) contains a numeric datatyped literal, i.e. a literal with datatype xsd:float, xsd:double, xsd:decimal, or a * derived datatype of xsd:decimal. * * @return <tt>true</tt> if the operand contains a numeric datatyped literal, * <tt>false</tt> otherwise. */ private Value evaluate(IsNumeric node, BindingSet bindings) throws ValueExprEvaluationException, QueryEvaluationException { Value argValue = evaluate(node.getArg(), bindings); if (argValue instanceof Literal) { Literal lit = (Literal) argValue; IRI datatype = lit.getDatatype(); return BooleanLiteral.valueOf(XMLDatatypeUtil.isNumericDatatype(datatype)); } else { return BooleanLiteral.FALSE; } }
Example 8
Source File: StrictEvaluationStrategy.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Determines whether the two operands match according to the <code>like</code> operator. The operator is defined as * a string comparison with the possible use of an asterisk (*) at the end and/or the start of the second operand to * indicate substring matching. * * @return <tt>true</tt> if the operands match according to the <tt>like</tt> operator, <tt>false</tt> otherwise. */ public Value evaluate(Like node, BindingSet bindings) throws QueryEvaluationException { Value val = evaluate(node.getArg(), bindings); String strVal = null; if (val instanceof IRI) { strVal = val.toString(); } else if (val instanceof Literal) { strVal = ((Literal) val).getLabel(); } if (strVal == null) { throw new ValueExprEvaluationException(); } if (!node.isCaseSensitive()) { // Convert strVal to lower case, just like the pattern has been done strVal = strVal.toLowerCase(); } int valIndex = 0; int prevPatternIndex = -1; int patternIndex = node.getOpPattern().indexOf('*'); if (patternIndex == -1) { // No wildcards return BooleanLiteral.valueOf(node.getOpPattern().equals(strVal)); } String snippet; if (patternIndex > 0) { // Pattern does not start with a wildcard, first part must match snippet = node.getOpPattern().substring(0, patternIndex); if (!strVal.startsWith(snippet)) { return BooleanLiteral.FALSE; } valIndex += snippet.length(); prevPatternIndex = patternIndex; patternIndex = node.getOpPattern().indexOf('*', patternIndex + 1); } while (patternIndex != -1) { // Get snippet between previous wildcard and this wildcard snippet = node.getOpPattern().substring(prevPatternIndex + 1, patternIndex); // Search for the snippet in the value valIndex = strVal.indexOf(snippet, valIndex); if (valIndex == -1) { return BooleanLiteral.FALSE; } valIndex += snippet.length(); prevPatternIndex = patternIndex; patternIndex = node.getOpPattern().indexOf('*', patternIndex + 1); } // Part after last wildcard snippet = node.getOpPattern().substring(prevPatternIndex + 1); if (snippet.length() > 0) { // Pattern does not end with a wildcard. // Search last occurence of the snippet. valIndex = strVal.indexOf(snippet, valIndex); int i; while ((i = strVal.indexOf(snippet, valIndex + 1)) != -1) { // A later occurence was found. valIndex = i; } if (valIndex == -1) { return BooleanLiteral.FALSE; } valIndex += snippet.length(); if (valIndex < strVal.length()) { // Some characters were not matched return BooleanLiteral.FALSE; } } return BooleanLiteral.TRUE; }
Example 9
Source File: HalyardValueExprEvaluation.java From Halyard with Apache License 2.0 | 4 votes |
/** * Determines whether the two operands match according to the <code>like</code> operator. The operator is defined as a string comparison with the possible * use of an asterisk (*) at the end and/or the start of the second operand to indicate substring matching. * * @return <tt>true</tt> if the operands match according to the * <tt>like</tt> * operator, <tt>false</tt> otherwise. */ private Value evaluate(Like node, BindingSet bindings) throws ValueExprEvaluationException, QueryEvaluationException { Value val = evaluate(node.getArg(), bindings); String strVal = null; if (val instanceof URI) { strVal = ((URI) val).toString(); } else if (val instanceof Literal) { strVal = ((Literal) val).getLabel(); } if (strVal == null) { throw new ValueExprEvaluationException(); } if (!node.isCaseSensitive()) { // Convert strVal to lower case, just like the pattern has been done strVal = strVal.toLowerCase(Locale.ROOT); } int valIndex = 0; int prevPatternIndex = -1; int patternIndex = node.getOpPattern().indexOf('*'); if (patternIndex == -1) { // No wildcards return BooleanLiteral.valueOf(node.getOpPattern().equals(strVal)); } String snippet; if (patternIndex > 0) { // Pattern does not start with a wildcard, first part must match snippet = node.getOpPattern().substring(0, patternIndex); if (!strVal.startsWith(snippet)) { return BooleanLiteral.FALSE; } valIndex += snippet.length(); prevPatternIndex = patternIndex; patternIndex = node.getOpPattern().indexOf('*', patternIndex + 1); } while (patternIndex != -1) { // Get snippet between previous wildcard and this wildcard snippet = node.getOpPattern().substring(prevPatternIndex + 1, patternIndex); // Search for the snippet in the value valIndex = strVal.indexOf(snippet, valIndex); if (valIndex == -1) { return BooleanLiteral.FALSE; } valIndex += snippet.length(); prevPatternIndex = patternIndex; patternIndex = node.getOpPattern().indexOf('*', patternIndex + 1); } // Part after last wildcard snippet = node.getOpPattern().substring(prevPatternIndex + 1); if (snippet.length() > 0) { // Pattern does not end with a wildcard. // Search last occurence of the snippet. valIndex = strVal.indexOf(snippet, valIndex); int i; while ((i = strVal.indexOf(snippet, valIndex + 1)) != -1) { // A later occurence was found. valIndex = i; } if (valIndex == -1) { return BooleanLiteral.FALSE; } valIndex += snippet.length(); if (valIndex < strVal.length()) { // Some characters were not matched return BooleanLiteral.FALSE; } } return BooleanLiteral.TRUE; }