org.eclipse.rdf4j.query.algebra.evaluation.ValueExprEvaluationException Java Examples
The following examples show how to use
org.eclipse.rdf4j.query.algebra.evaluation.ValueExprEvaluationException.
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: TemporalInstantRelationFunction.java From rya with Apache License 2.0 | 6 votes |
@Override public Value evaluate(final ValueFactory valueFactory, final Value... args) throws ValueExprEvaluationException { if (args.length != 2) { throw new ValueExprEvaluationException(getURI() + " requires exactly 2 arguments, got " + args.length); } try { final ZonedDateTime date1 = ZonedDateTime.parse(args[0].stringValue()); final ZonedDateTime date2 = ZonedDateTime.parse(args[1].stringValue()); final boolean result = relation(date1, date2); return valueFactory.createLiteral(result); } catch (final DateTimeParseException e) { throw new ValueExprEvaluationException("Date/Times provided must be of the ISO-8601 format. Example: 2007-04-05T14:30Z"); } }
Example #2
Source File: HalyardValueExprEvaluation.java From Halyard with Apache License 2.0 | 6 votes |
/** * Evaluate a {@link Str} node * @param node the node to evaluate * @param bindings the set of named value bindings * @return a literal representation of the evaluation: a URI, the value of a simple literal or the label of any other literal * @throws ValueExprEvaluationException * @throws QueryEvaluationException */ private Value evaluate(Str node, BindingSet bindings) throws ValueExprEvaluationException, QueryEvaluationException { Value argValue = evaluate(node.getArg(), bindings); if (argValue instanceof URI) { return valueFactory.createLiteral(argValue.toString()); } else if (argValue instanceof Literal) { Literal literal = (Literal) argValue; if (QueryEvaluationUtil.isSimpleLiteral(literal)) { return literal; } else { return valueFactory.createLiteral(literal.getLabel()); } } else { throw new ValueExprEvaluationException(); } }
Example #3
Source File: TimezoneTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testEvaluate1() { try { Literal result = timezone.evaluate(f, f.createLiteral("2011-01-10T14:45:13.815-05:00", XMLSchema.DATETIME)); assertNotNull(result); assertEquals(XMLSchema.DAYTIMEDURATION, result.getDatatype()); assertEquals("-PT5H", result.getLabel()); } catch (ValueExprEvaluationException e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #4
Source File: HalyardValueExprEvaluation.java From Halyard with Apache License 2.0 | 6 votes |
/** * Evaluate an {@link In} node * @param node the node to evaluate * @param bindings the set of named value bindings * @return * @throws ValueExprEvaluationException * @throws QueryEvaluationException */ private Value evaluate(In node, BindingSet bindings) throws ValueExprEvaluationException, QueryEvaluationException { Value leftValue = evaluate(node.getArg(), bindings); // Result is false until a match has been found boolean result = false; // Use first binding name from tuple expr to compare values String bindingName = node.getSubQuery().getBindingNames().iterator().next(); try (CloseableIteration<BindingSet, QueryEvaluationException> iter = parentStrategy.evaluate(node.getSubQuery(), bindings)) { while (result == false && iter.hasNext()) { BindingSet bindingSet = iter.next(); Value rightValue = bindingSet.getValue(bindingName); result = leftValue == null && rightValue == null || leftValue != null && leftValue.equals(rightValue); } } return BooleanLiteral.valueOf(result); }
Example #5
Source File: HalyardValueExprEvaluation.java From Halyard with Apache License 2.0 | 6 votes |
/** * 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 #6
Source File: SHA512.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public Literal evaluate(ValueFactory valueFactory, Value... args) throws ValueExprEvaluationException { if (args.length != 1) { throw new ValueExprEvaluationException("SHA512 requires exactly 1 argument, got " + args.length); } if (args[0] instanceof Literal) { Literal literal = (Literal) args[0]; if (QueryEvaluationUtil.isSimpleLiteral(literal) || XMLSchema.STRING.equals(literal.getDatatype())) { String lexValue = literal.getLabel(); try { return valueFactory.createLiteral(hash(lexValue, "SHA-512")); } catch (NoSuchAlgorithmException e) { // SHA512 should always be available. throw new RuntimeException(e); } } else { throw new ValueExprEvaluationException("Invalid argument for SHA512: " + literal); } } else { throw new ValueExprEvaluationException("Invalid argument for SHA512: " + args[0]); } }
Example #7
Source File: StrBeforeTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testEvaluate3() { Literal leftArg = f.createLiteral("foobar", "en"); Literal rightArg = f.createLiteral("b"); try { Literal result = strBeforeFunc.evaluate(f, leftArg, rightArg); assertEquals("foo", result.getLabel()); assertEquals("en", result.getLanguage().orElse(null)); assertEquals(RDF.LANGSTRING, result.getDatatype()); } catch (ValueExprEvaluationException e) { fail(e.getMessage()); } }
Example #8
Source File: CastFunction.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public Literal evaluate(ValueFactory valueFactory, Value... args) throws ValueExprEvaluationException { if (args.length != 1) { throw new ValueExprEvaluationException( getXsdName() + " cast requires exactly 1 argument, got " + args.length); } if (args[0] instanceof Literal) { Literal literal = (Literal) args[0]; IRI datatype = literal.getDatatype(); if (QueryEvaluationUtil.isStringLiteral(literal)) { String lexicalValue = XMLDatatypeUtil.collapseWhiteSpace(literal.getLabel()); if (isValidForDatatype(lexicalValue)) { return valueFactory.createLiteral(lexicalValue, getXsdDatatype()); } } else if (datatype != null) { if (datatype.equals(getXsdDatatype())) { return literal; } } return convert(valueFactory, literal); } else { return convert(valueFactory, args[0]); } }
Example #9
Source File: XMLDatatypeMathUtil.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Computes the result of applying the supplied math operator on the supplied left and right operand. * * @param leftLit a datatype literal * @param rightLit a datatype literal * @param op a mathematical operator, as definied by MathExpr.MathOp. * @return a datatype literal */ public static Literal compute(Literal leftLit, Literal rightLit, MathOp op) throws ValueExprEvaluationException { IRI leftDatatype = leftLit.getDatatype(); IRI rightDatatype = rightLit.getDatatype(); if (XMLDatatypeUtil.isNumericDatatype(leftDatatype) && XMLDatatypeUtil.isNumericDatatype(rightDatatype)) { return MathUtil.compute(leftLit, rightLit, op); } else if (XMLDatatypeUtil.isDurationDatatype(leftDatatype) && XMLDatatypeUtil.isDurationDatatype(rightDatatype)) { return operationsBetweenDurations(leftLit, rightLit, op); } else if (XMLDatatypeUtil.isDecimalDatatype(leftDatatype) && XMLDatatypeUtil.isDurationDatatype(rightDatatype)) { return operationsBetweenDurationAndDecimal(rightLit, leftLit, op); } else if (XMLDatatypeUtil.isDurationDatatype(leftDatatype) && XMLDatatypeUtil.isDecimalDatatype(rightDatatype)) { return operationsBetweenDurationAndDecimal(leftLit, rightLit, op); } else if (XMLDatatypeUtil.isCalendarDatatype(leftDatatype) && XMLDatatypeUtil.isDurationDatatype(rightDatatype)) { return operationsBetweenCalendarAndDuration(leftLit, rightLit, op); } else if (XMLDatatypeUtil.isDurationDatatype(leftDatatype) && XMLDatatypeUtil.isCalendarDatatype(rightDatatype)) { return operationsBetweenDurationAndCalendar(leftLit, rightLit, op); } else { throw new ValueExprEvaluationException("Mathematical operators are not supported on these operands"); } }
Example #10
Source File: ConvertSpinRDFToString.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public Value evaluate(ValueFactory valueFactory, Value... args) throws ValueExprEvaluationException { if (args.length < 1 || args.length > 2) { throw new ValueExprEvaluationException("Incorrect number of arguments"); } if (!(args[0] instanceof Resource)) { throw new ValueExprEvaluationException("First argument must be the root of a SPIN RDF query"); } if (args.length == 2 && !(args[1] instanceof Literal)) { throw new ValueExprEvaluationException("Second argument must be a string"); } Resource q = (Resource) args[0]; boolean useHtml = (args.length == 2) ? ((Literal) args[1]).booleanValue() : false; String sparqlString; try { ParsedOperation op = parser.parse(q, getCurrentQueryPreparer().getTripleSource()); sparqlString = new SPARQLQueryRenderer().render((ParsedQuery) op); } catch (Exception e) { throw new ValueExprEvaluationException(e); } return valueFactory.createLiteral(sparqlString); }
Example #11
Source File: DateTimeWithinPeriodTest.java From rya with Apache License 2.0 | 6 votes |
@Test public void testSeconds() throws DatatypeConfigurationException, ValueExprEvaluationException { DatatypeFactory dtf = DatatypeFactory.newInstance(); ZonedDateTime zTime = testThisTimeDate; String time = zTime.format(DateTimeFormatter.ISO_INSTANT); ZonedDateTime zTime1 = zTime.minusSeconds(1); String time1 = zTime1.format(DateTimeFormatter.ISO_INSTANT); Literal now = VF.createLiteral(dtf.newXMLGregorianCalendar(time)); Literal nowMinusOne = VF.createLiteral(dtf.newXMLGregorianCalendar(time1)); DateTimeWithinPeriod func = new DateTimeWithinPeriod(); assertEquals(TRUE, func.evaluate(VF, now, now, VF.createLiteral(1), OWLTime.SECONDS_URI)); assertEquals(FALSE, func.evaluate(VF, now, nowMinusOne,VF.createLiteral(1), OWLTime.SECONDS_URI)); assertEquals(TRUE, func.evaluate(VF, now, nowMinusOne,VF.createLiteral(2), OWLTime.SECONDS_URI)); }
Example #12
Source File: GroupIterator.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
private Aggregate create(AggregateOperator operator) throws ValueExprEvaluationException, QueryEvaluationException { if (operator instanceof Count) { return new CountAggregate((Count) operator); } else if (operator instanceof Min) { return new MinAggregate((Min) operator); } else if (operator instanceof Max) { return new MaxAggregate((Max) operator); } else if (operator instanceof Sum) { return new SumAggregate((Sum) operator); } else if (operator instanceof Avg) { return new AvgAggregate((Avg) operator); } else if (operator instanceof Sample) { return new SampleAggregate((Sample) operator); } else if (operator instanceof GroupConcat) { return new ConcatAggregate((GroupConcat) operator); } return null; }
Example #13
Source File: FilterIterator.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override protected boolean accept(BindingSet bindings) throws QueryEvaluationException { try { // Limit the bindings to the ones that are in scope for this filter QueryBindingSet scopeBindings = new QueryBindingSet(bindings); // FIXME J1 scopeBindingNames should include bindings from superquery if the filter // is part of a subquery. This is a workaround: we should fix the settings of scopeBindingNames, // rather than skipping the limiting of bindings. if (!isPartOfSubQuery(filter)) { scopeBindings.retainAll(scopeBindingNames); } return strategy.isTrue(filter.getCondition(), scopeBindings); } catch (ValueExprEvaluationException e) { // failed to evaluate condition return false; } }
Example #14
Source File: EncodeURL.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public Value evaluate(ValueFactory valueFactory, Value... args) throws ValueExprEvaluationException { if (args.length < 1 || args.length > 2) { throw new ValueExprEvaluationException("Incorrect number of arguments"); } if (!(args[0] instanceof Literal)) { throw new ValueExprEvaluationException("First argument must be a string"); } if (args.length == 2 && !(args[1] instanceof Literal)) { throw new ValueExprEvaluationException("Second argument must be a string"); } Literal s = (Literal) args[0]; String encoding = (args.length == 2) ? ((Literal) args[1]).getLabel() : "UTF-8"; try { return valueFactory.createLiteral(URLEncoder.encode(s.getLabel(), encoding)); } catch (UnsupportedEncodingException e) { throw new ValueExprEvaluationException(e); } }
Example #15
Source File: Distance.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public Value evaluate(ValueFactory valueFactory, Value... args) throws ValueExprEvaluationException { if (args.length != 3) { throw new ValueExprEvaluationException(getURI() + " requires exactly 3 arguments, got " + args.length); } SpatialContext geoContext = SpatialSupport.getSpatialContext(); Point p1 = FunctionArguments.getPoint(this, args[0], geoContext); Point p2 = FunctionArguments.getPoint(this, args[1], geoContext); IRI units = FunctionArguments.getUnits(this, args[2]); double distDegs = geoContext.calcDistance(p1, p2); double distUom = FunctionArguments.convertFromDegrees(distDegs, units); return valueFactory.createLiteral(distUom); }
Example #16
Source File: DateTimeWithinPeriodTest.java From rya with Apache License 2.0 | 6 votes |
@Test public void testMinutes() throws DatatypeConfigurationException, ValueExprEvaluationException { DatatypeFactory dtf = DatatypeFactory.newInstance(); ZonedDateTime zTime = testThisTimeDate; String time = zTime.format(DateTimeFormatter.ISO_INSTANT); ZonedDateTime zTime1 = zTime.minusMinutes(1); String time1 = zTime1.format(DateTimeFormatter.ISO_INSTANT); Literal now = VF.createLiteral(dtf.newXMLGregorianCalendar(time)); Literal nowMinusOne = VF.createLiteral(dtf.newXMLGregorianCalendar(time1)); DateTimeWithinPeriod func = new DateTimeWithinPeriod(); assertEquals(TRUE, func.evaluate(VF, now, now,VF.createLiteral(1),OWLTime.MINUTES_URI)); assertEquals(FALSE, func.evaluate(VF, now, nowMinusOne,VF.createLiteral(1),OWLTime.MINUTES_URI)); assertEquals(TRUE, func.evaluate(VF, now, nowMinusOne,VF.createLiteral(2),OWLTime.MINUTES_URI)); }
Example #17
Source File: AbstractStringReplacer.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public Value evaluate(ValueFactory valueFactory, Value... args) throws ValueExprEvaluationException { if (args.length < 1 || args.length > 2) { throw new ValueExprEvaluationException("Incorrect number of arguments"); } if (!(args[0] instanceof Literal)) { throw new ValueExprEvaluationException("First argument must be a string"); } if (args.length == 2 && !(args[1] instanceof Literal)) { throw new ValueExprEvaluationException("Second argument must be a string"); } String s = ((Literal) args[0]).getLabel(); String regex = (args.length == 2) ? ((Literal) args[1]).getLabel() : "."; StringBuffer buf = new StringBuffer(s.length()); Matcher matcher = Pattern.compile(regex).matcher(s); while (matcher.find()) { String g = matcher.group(); matcher.appendReplacement(buf, transform(g)); } matcher.appendTail(buf); return valueFactory.createLiteral(buf.toString()); }
Example #18
Source File: DecodeURL.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public Value evaluate(ValueFactory valueFactory, Value... args) throws ValueExprEvaluationException { if (args.length < 1 || args.length > 2) { throw new ValueExprEvaluationException("Incorrect number of arguments"); } if (!(args[0] instanceof Literal)) { throw new ValueExprEvaluationException("First argument must be a string"); } if (args.length == 2 && !(args[1] instanceof Literal)) { throw new ValueExprEvaluationException("Second argument must be a string"); } Literal s = (Literal) args[0]; String encoding = (args.length == 2) ? ((Literal) args[1]).getLabel() : "UTF-8"; try { return valueFactory.createLiteral(URLDecoder.decode(s.getLabel(), encoding)); } catch (UnsupportedEncodingException e) { throw new ValueExprEvaluationException(e); } }
Example #19
Source File: GroupIterator.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
private Map<String, Aggregate> getAggregates() throws ValueExprEvaluationException, QueryEvaluationException { Map<String, Aggregate> result = aggregates; if (result == null) { synchronized (this) { result = aggregates; if (result == null) { result = aggregates = new LinkedHashMap<>(); for (GroupElem ge : group.getGroupElements()) { Aggregate create = create(ge.getOperator()); if (create != null) { aggregates.put(ge.getName(), create); } } } } } return result; }
Example #20
Source File: DateTimeWithinPeriod.java From rya with Apache License 2.0 | 6 votes |
/** * Determines whether two datetimes occur within a specified period of time of one another. This method expects four * values, where the first two values are the datetimes, the third value is an integer indicating the period, and * the fourth value is an IRI indicating the time unit of the period. The IRI must be of Type DurationDescription in * the OWL-Time ontology (see <a href ="https://www.w3.org/TR/owl-time/">https://www.w3.org/TR/owl-time/</a>). * Examples of valid time unit IRIs can be found in the class {@link OWLTime} and below * <ul> * <li>http://www.w3.org/2006/time#days</li> * <li>http://www.w3.org/2006/time#hours</li> * <li>http://www.w3.org/2006/time#minutes</li> * <li>http://www.w3.org/2006/time#seconds</li> * </ul> * * @param valueFactory - factory for creating values (not null) * @param values - array of Value arguments for this Function (not null). */ @Override public Value evaluate(ValueFactory valueFactory, Value... values) throws ValueExprEvaluationException { checkNotNull(valueFactory); checkNotNull(values); try { // general validation of input checkArgument(values.length == 4); checkArgument(values[0] instanceof Literal); checkArgument(values[1] instanceof Literal); checkArgument(values[2] instanceof Literal); checkArgument(values[3] instanceof IRI); Instant dateTime1 = convertToInstant((Literal) values[0]); Instant dateTime2 = convertToInstant((Literal) values[1]); long periodMillis = convertPeriodToMillis((Literal) values[2], (IRI) values[3]); long timeBetween = Math.abs(Duration.between(dateTime1, dateTime2).toMillis()); return valueFactory.createLiteral(timeBetween < periodMillis); } catch (Exception e) { throw new ValueExprEvaluationException(e); } }
Example #21
Source File: XMLDatatypeMathUtil.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
private static Literal operationsBetweenDurations(Literal leftLit, Literal rightLit, MathOp op) { Duration left = XMLDatatypeUtil.parseDuration(leftLit.getLabel()); Duration right = XMLDatatypeUtil.parseDuration(rightLit.getLabel()); try { switch (op) { case PLUS: // op:add-yearMonthDurations and op:add-dayTimeDurations return buildLiteral(left.add(right)); case MINUS: // op:subtract-yearMonthDurations and op:subtract-dayTimeDurations return buildLiteral(left.subtract(right)); case MULTIPLY: throw new ValueExprEvaluationException("Multiplication is not defined on xsd:duration."); case DIVIDE: throw new ValueExprEvaluationException("Division is not defined on xsd:duration."); default: throw new IllegalArgumentException("Unknown operator: " + op); } } catch (IllegalStateException e) { throw new ValueExprEvaluationException(e); } }
Example #22
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 #23
Source File: UnCamelCase.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override protected Value evaluate(ValueFactory valueFactory, Value arg) throws ValueExprEvaluationException { if (!(arg instanceof Literal)) { throw new ValueExprEvaluationException("Argument must be a string"); } String s = ((Literal) arg).getLabel(); StringBuilder buf = new StringBuilder(s.length() + 10); char prev = '\0'; for (int i = 0; i < s.length(); i++) { char ch = s.charAt(i); if (Character.isLowerCase(prev) && Character.isUpperCase(ch)) { buf.append(' '); buf.append(Character.toLowerCase(ch)); } else if (ch == '_') { buf.append(' '); } else { buf.append(ch); } prev = ch; } return valueFactory.createLiteral(buf.toString()); }
Example #24
Source File: RegexTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testEvaluate3() throws QueryEvaluationException { Literal pattern = vf.createLiteral("FooBar"); Literal startIndex = vf.createLiteral(4); try { evaluate(pattern, startIndex, startIndex, startIndex); fail("illegal number of parameters"); } catch (ValueExprEvaluationException e) { // do nothing, expected } }
Example #25
Source File: GroupIterator.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void bindSolution(QueryBindingSet sol) throws QueryEvaluationException { for (String name : getAggregates().keySet()) { try { Value value = getAggregates().get(name).getValue(); if (value != null) { // Potentially overwrites bindings from super sol.setBinding(name, value); } } catch (ValueExprEvaluationException ex) { // There was a type error when calculating the value of the aggregate. We silently ignore the error, // resulting in no result value being bound. } } }
Example #26
Source File: EvaluationStrategyImpl.java From semagrow with Apache License 2.0 | 5 votes |
protected Value evaluate(BindingSet s) throws QueryEvaluationException { try { return evaluateValue(getArg(), s); } catch (ValueExprEvaluationException var3) { return null; } }
Example #27
Source File: TestStringCast.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testCastIntegerLiteral() { Literal intLit = f.createLiteral(10); try { Literal result = stringCast.evaluate(f, intLit); assertNotNull(result); assertEquals(XMLSchema.STRING, result.getDatatype()); assertFalse(result.getLanguage().isPresent()); assertEquals("10", result.getLabel()); } catch (ValueExprEvaluationException e) { fail(e.getMessage()); } }
Example #28
Source File: StrAfterTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testEvaluate6() { Literal leftArg = f.createLiteral(10); Literal rightArg = f.createLiteral("b"); try { Literal result = strAfterFunc.evaluate(f, leftArg, rightArg); fail("operand with incompatible datatype, should have resulted in error"); } catch (ValueExprEvaluationException e) { assertEquals("incompatible operands for STRAFTER: \"10\"^^<http://www.w3.org/2001/XMLSchema#int>, \"b\"", e.getMessage()); } }
Example #29
Source File: EvalFunction.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
protected static void addArguments(Query query, Value... args) throws ValueExprEvaluationException { for (int i = 1; i < args.length; i += 2) { if (!(args[i] instanceof URI)) { throw new ValueExprEvaluationException("Argument " + i + " must be a URI"); } query.setBinding(((URI) args[i]).getLocalName(), args[i + 1]); } }
Example #30
Source File: GroupIterator.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public Value getValue() throws ValueExprEvaluationException { if (typeError != null) { // a type error occurred while processing the aggregate, throw it // now. throw typeError; } if (count == 0) { return vf.createLiteral("0", XMLSchema.INTEGER); } Literal sizeLit = vf.createLiteral(count); return MathUtil.compute(sum, sizeLit, MathOp.DIVIDE); }