use of org.apache.jena.sparql.expr.nodevalue.NodeValueString in project jena by apache.
the class ExprFactoryTest method asListTest.
@Test
public void asListTest() {
ExprList lst = factory.asList("?foo", "http://example.com", Converters.quoted("hello"), 1, 5L, 3.14f, 6.28d, Var.alloc("bar"), null, factory.rand());
assertEquals(10, lst.size());
assertEquals(new ExprVar("foo"), lst.get(0));
// assertEquals( new ExprVar( "foo" ), lst.get(0));
assertEquals(new NodeValueString("hello"), lst.get(2));
assertEquals(1, lst.get(3).getConstant().asNode().getLiteralValue());
assertEquals(5, lst.get(4).getConstant().asNode().getLiteralValue());
assertEquals(3.14f, lst.get(5).getConstant().asNode().getLiteralValue());
assertEquals(6.28, lst.get(6).getConstant().asNode().getLiteralValue());
assertEquals(new ExprVar("bar"), lst.get(7));
assertEquals(Expr.NONE, lst.get(8));
assertEquals(new E_Random(), lst.get(9));
}
use of org.apache.jena.sparql.expr.nodevalue.NodeValueString in project webofneeds by researchstudio-sat.
the class SparqlMatcherUtils method createSearchQuery.
public static Op createSearchQuery(String searchString, Var resultName, int hops, boolean disjunctive, boolean tokenize) {
Var textSearchTarget = Var.alloc("textSearchTarget");
Optional<Op> union = IntStream.range(1, hops + 1).mapToObj(hopCount -> makePathBGPPattern(resultName, textSearchTarget, hopCount, op -> {
Expr filterExpression = Arrays.stream(tokenize ? searchString.toLowerCase().split(" ") : new String[] { searchString.toLowerCase() }).<Expr>map(searchPart -> new E_StrContains(new E_StrLowerCase(new ExprVar(textSearchTarget)), new NodeValueString(searchPart))).reduce((left, right) -> disjunctive ? new E_LogicalOr(left, right) : new E_LogicalAnd(left, right)).orElse(new NodeValueBoolean(true));
return OpFilter.filterBy(new ExprList(filterExpression), op);
})).reduce((op1, op2) -> new OpUnion(op1, op2));
Op maintriple = new OpTriple(new Triple(resultName, RDF.type.asNode(), WON.Atom.asNode()));
Op mainOp = union.isPresent() ? OpJoin.create(maintriple, union.get()) : maintriple;
return mainOp;
}
Aggregations