@Test public void testEvaluate() { try { Literal random = rand.evaluate(f); assertNotNull(random); assertEquals(XMLSchema.DOUBLE, random.getDatatype()); double randomValue = random.doubleValue(); assertTrue(randomValue >= 0.0d); assertTrue(randomValue < 1.0d); } catch (ValueExprEvaluationException e) { e.printStackTrace(); fail(e.getMessage()); } }
@Override public Literal evaluate(ValueFactory valueFactory, Value... args) throws ValueExprEvaluationException { if (args.length != 0) { throw new ValueExprEvaluationException("RAND requires 0 arguments, got " + args.length); } Random randomGenerator = new Random(); double randomValue = randomGenerator.nextDouble(); return valueFactory.createLiteral(randomValue); }
Rand implements Function { @Override public Literal evaluate(ValueFactory valueFactory, Value... args) throws ValueExprEvaluationException { if (args.length != 0) { throw new ValueExprEvaluationException("RAND requires 0 arguments, got " + args.length); } Random randomGenerator = new Random(); double randomValue = randomGenerator.nextDouble(); return valueFactory.createLiteral(randomValue); } }
Rand implements Function { @Override public Literal evaluate(ValueFactory valueFactory, Value... args) throws ValueExprEvaluationException { if (args.length != 0) { throw new ValueExprEvaluationException("RAND requires 0 arguments, got " + args.length); } Random randomGenerator = new Random(); double randomValue = randomGenerator.nextDouble(); return valueFactory.createLiteral(randomValue); }  }
Rand implements Function { @Override public Literal evaluate(ValueFactory valueFactory, Value... args) throws ValueExprEvaluationException { if (args.length != 0) { throw new ValueExprEvaluationException("RAND requires 0 arguments, got " + args.length); } Random randomGenerator = new Random(); double randomValue = randomGenerator.nextDouble(); return valueFactory.createLiteral(randomValue); }  @Override String getURI(); @Override Literal evaluate(ValueFactory valueFactory, Value... args); }
Rand implements Function { @Override public Literal evaluate(ValueFactory valueFactory, Value... args) throws ValueExprEvaluationException { if (args.length != 0) { throw new ValueExprEvaluationException("RAND requires 0 arguments, got " + args.length); } Random randomGenerator = new Random(); double randomValue = randomGenerator.nextDouble(); return valueFactory.createLiteral(randomValue); }  @Override String getURI(); @Override Literal evaluate(ValueFactory valueFactory, Value... args);  }