Search in sources :

Example 1 with BindingInputStream

use of org.apache.jena.sparql.engine.binding.BindingInputStream in project jena by apache.

the class bindings method main.

public static void main(String[] args) {
    InputStream in = System.in;
    OutputStream out = System.out;
    BindingInputStream input = new BindingInputStream(in);
    BindingOutputStream output = new BindingOutputStream(out);
    for (; input.hasNext(); ) output.send(input.next());
    output.flush();
}
Also used : BindingInputStream(org.apache.jena.sparql.engine.binding.BindingInputStream) BindingOutputStream(org.apache.jena.sparql.engine.binding.BindingOutputStream) InputStream(java.io.InputStream) BindingInputStream(org.apache.jena.sparql.engine.binding.BindingInputStream) OutputStream(java.io.OutputStream) BindingOutputStream(org.apache.jena.sparql.engine.binding.BindingOutputStream)

Example 2 with BindingInputStream

use of org.apache.jena.sparql.engine.binding.BindingInputStream in project jena by apache.

the class BIOInput method fromBIO.

public static ResultSet fromBIO(InputStream input) {
    // Scan the stream for VARS and accumulate the total variables. 
    // Trade off of guessing first line is all the VARS and coping with
    // anything possible.  -> Cope with anything possible.
    BindingInputStream bin = new BindingInputStream(input);
    List<Binding> bindings = new ArrayList<>();
    List<Var> vars = new ArrayList<>();
    while (bin.hasNext()) {
        Binding b = bin.next();
        bindings.add(b);
        for (Var v : bin.vars()) {
            if (!vars.contains(v))
                vars.add(v);
        }
    }
    QueryIterator qIter = new QueryIterPlainWrapper(bindings.iterator());
    return new ResultSetStream(Var.varNames(vars), m, qIter);
}
Also used : BindingInputStream(org.apache.jena.sparql.engine.binding.BindingInputStream) Binding(org.apache.jena.sparql.engine.binding.Binding) QueryIterPlainWrapper(org.apache.jena.sparql.engine.iterator.QueryIterPlainWrapper) QueryIterator(org.apache.jena.sparql.engine.QueryIterator) Var(org.apache.jena.sparql.core.Var) ArrayList(java.util.ArrayList) ResultSetStream(org.apache.jena.sparql.engine.ResultSetStream)

Example 3 with BindingInputStream

use of org.apache.jena.sparql.engine.binding.BindingInputStream in project jena by apache.

the class bindings method main.

public static void main(String... args) {
    InputStream in = System.in;
    OutputStream out = System.out;
    BindingInputStream input = new BindingInputStream(in);
    BindingOutputStream output = new BindingOutputStream(out);
    for (; input.hasNext(); ) output.send(input.next());
    output.flush();
}
Also used : BindingInputStream(org.apache.jena.sparql.engine.binding.BindingInputStream) BindingOutputStream(org.apache.jena.sparql.engine.binding.BindingOutputStream) InputStream(java.io.InputStream) BindingInputStream(org.apache.jena.sparql.engine.binding.BindingInputStream) OutputStream(java.io.OutputStream) BindingOutputStream(org.apache.jena.sparql.engine.binding.BindingOutputStream)

Aggregations

BindingInputStream (org.apache.jena.sparql.engine.binding.BindingInputStream)3 InputStream (java.io.InputStream)2 OutputStream (java.io.OutputStream)2 BindingOutputStream (org.apache.jena.sparql.engine.binding.BindingOutputStream)2 ArrayList (java.util.ArrayList)1 Var (org.apache.jena.sparql.core.Var)1 QueryIterator (org.apache.jena.sparql.engine.QueryIterator)1 ResultSetStream (org.apache.jena.sparql.engine.ResultSetStream)1 Binding (org.apache.jena.sparql.engine.binding.Binding)1 QueryIterPlainWrapper (org.apache.jena.sparql.engine.iterator.QueryIterPlainWrapper)1