Search in sources :

Example 1 with ListBindingSet

use of org.eclipse.rdf4j.query.impl.ListBindingSet in project rdf4j by eclipse.

the class SPARQLTSVCustomTest method testSES2126QuotedLiteralIntegerAsStringExplicitType.

/**
 * Only Literals with the XML Schema numeric types should be simplified.
 * <p>
 * NOTE: This will fail when using RDF-1.1, as the datatype {@link XMLSchema#STRING} is implied and hence
 * is not generally represented.
 *
 * @throws Exception
 */
@Ignore("This test does not work with RDF-1.1")
@Test
public void testSES2126QuotedLiteralIntegerAsStringExplicitType() throws Exception {
    List<String> bindingNames = Arrays.asList("test");
    TupleQueryResult tqr = new IteratingTupleQueryResult(bindingNames, Arrays.asList(new ListBindingSet(bindingNames, SimpleValueFactory.getInstance().createLiteral("1", XMLSchema.STRING))));
    String result = writeTupleResult(tqr);
    assertEquals("?test\n\"1\"^^<http://www.w3.org/2001/XMLSchema#string>\n", result);
}
Also used : ListBindingSet(org.eclipse.rdf4j.query.impl.ListBindingSet) IteratingTupleQueryResult(org.eclipse.rdf4j.query.impl.IteratingTupleQueryResult) IteratingTupleQueryResult(org.eclipse.rdf4j.query.impl.IteratingTupleQueryResult) TupleQueryResult(org.eclipse.rdf4j.query.TupleQueryResult) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with ListBindingSet

use of org.eclipse.rdf4j.query.impl.ListBindingSet in project rdf4j by eclipse.

the class TupleExprBuilder method visit.

@Override
public BindingSet visit(ASTBindingSet node, Object data) throws VisitorException {
    @SuppressWarnings("unchecked") List<Var> vars = (List<Var>) data;
    List<String> names = new ArrayList<String>(vars.size());
    for (Var var : vars) {
        names.add(var.getName());
    }
    int numberOfBindingValues = node.jjtGetNumChildren();
    if (numberOfBindingValues != vars.size()) {
        throw new VisitorException("number of values in bindingset does not match variables in BINDINGS clause");
    }
    Value[] values = new Value[numberOfBindingValues];
    for (int i = 0; i < numberOfBindingValues; i++) {
        ValueExpr ve = (ValueExpr) node.jjtGetChild(i).jjtAccept(this, null);
        if (ve != null) {
            Value v = getValueForExpr(ve);
            values[i] = v;
        }
    }
    BindingSet result = new ListBindingSet(names, values);
    return result;
}
Also used : ValueExpr(org.eclipse.rdf4j.query.algebra.ValueExpr) ListBindingSet(org.eclipse.rdf4j.query.impl.ListBindingSet) BindingSet(org.eclipse.rdf4j.query.BindingSet) ListBindingSet(org.eclipse.rdf4j.query.impl.ListBindingSet) Var(org.eclipse.rdf4j.query.algebra.Var) ArrayList(java.util.ArrayList) Value(org.eclipse.rdf4j.model.Value) List(java.util.List) ArrayList(java.util.ArrayList) ProjectionElemList(org.eclipse.rdf4j.query.algebra.ProjectionElemList)

Example 3 with ListBindingSet

use of org.eclipse.rdf4j.query.impl.ListBindingSet in project rdf4j by eclipse.

the class QueryResultsTest method testBNodeBindingSet3.

@Test
public void testBNodeBindingSet3() throws QueryEvaluationException {
    tqr1.append(new ListBindingSet(twoBindingNames, foo, bnode1));
    tqr1.append(new ListBindingSet(twoBindingNames, foo, bnode2));
    tqr2.append(new ListBindingSet(twoBindingNames, foo, bnode1));
    tqr2.append(new ListBindingSet(twoBindingNames, foo, bnode1));
    assertFalse(QueryResults.equals(tqr1, tqr2));
}
Also used : ListBindingSet(org.eclipse.rdf4j.query.impl.ListBindingSet) Test(org.junit.Test)

Example 4 with ListBindingSet

use of org.eclipse.rdf4j.query.impl.ListBindingSet in project rdf4j by eclipse.

the class QueryResultsTest method testBNodeBindingSet6.

@Test
public void testBNodeBindingSet6() throws QueryEvaluationException {
    tqr3.append(new ListBindingSet(threeBindingNames, foo, bnode2, bnode1));
    tqr1.append(new ListBindingSet(twoBindingNames, foo, bnode2));
    assertFalse(QueryResults.equals(tqr3, tqr1));
}
Also used : ListBindingSet(org.eclipse.rdf4j.query.impl.ListBindingSet) Test(org.junit.Test)

Example 5 with ListBindingSet

use of org.eclipse.rdf4j.query.impl.ListBindingSet in project rdf4j by eclipse.

the class QueryResultsTest method testNonBNodeBindingSet2.

@Test
public void testNonBNodeBindingSet2() throws QueryEvaluationException {
    tqr1.append(new ListBindingSet(twoBindingNames, foo, lit1));
    tqr2.append(new ListBindingSet(twoBindingNames, foo, lit2));
    assertFalse(QueryResults.equals(tqr1, tqr2));
}
Also used : ListBindingSet(org.eclipse.rdf4j.query.impl.ListBindingSet) Test(org.junit.Test)

Aggregations

ListBindingSet (org.eclipse.rdf4j.query.impl.ListBindingSet)20 Test (org.junit.Test)15 ArrayList (java.util.ArrayList)6 Value (org.eclipse.rdf4j.model.Value)5 IRI (org.eclipse.rdf4j.model.IRI)3 BindingSet (org.eclipse.rdf4j.query.BindingSet)3 IOException (java.io.IOException)2 InputStreamReader (java.io.InputStreamReader)2 List (java.util.List)2 TupleQueryResult (org.eclipse.rdf4j.query.TupleQueryResult)2 EmptyBindingSet (org.eclipse.rdf4j.query.impl.EmptyBindingSet)2 IteratingTupleQueryResult (org.eclipse.rdf4j.query.impl.IteratingTupleQueryResult)2 MutableTupleQueryResult (org.eclipse.rdf4j.query.impl.MutableTupleQueryResult)2 CSVReader (com.opencsv.CSVReader)1 BufferedReader (java.io.BufferedReader)1 DataInputStream (java.io.DataInputStream)1 Arrays (java.util.Arrays)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 AbstractCloseableIteration (org.eclipse.rdf4j.common.iteration.AbstractCloseableIteration)1