Search in sources :

Example 6 with TupleQueryResultHandlerException

use of org.eclipse.rdf4j.query.TupleQueryResultHandlerException in project rdf4j by eclipse.

the class AbstractSPARQLXMLWriter method handleSolution.

@Override
public void handleSolution(BindingSet bindingSet) throws TupleQueryResultHandlerException {
    try {
        if (!documentOpen) {
            startDocument();
        }
        if (!headerOpen) {
            startHeader();
        }
        if (!headerComplete) {
            endHeader();
        }
        if (!tupleVariablesFound) {
            throw new IllegalStateException("Must call startQueryResult before handleSolution");
        }
        xmlWriter.startTag(RESULT_TAG);
        for (Binding binding : bindingSet) {
            xmlWriter.setAttribute(BINDING_NAME_ATT, binding.getName());
            xmlWriter.startTag(BINDING_TAG);
            writeValue(binding.getValue());
            xmlWriter.endTag(BINDING_TAG);
        }
        xmlWriter.endTag(RESULT_TAG);
    } catch (IOException e) {
        throw new TupleQueryResultHandlerException(e);
    } catch (TupleQueryResultHandlerException e) {
        throw e;
    } catch (QueryResultHandlerException e) {
        throw new TupleQueryResultHandlerException(e);
    }
}
Also used : Binding(org.eclipse.rdf4j.query.Binding) TupleQueryResultHandlerException(org.eclipse.rdf4j.query.TupleQueryResultHandlerException) IOException(java.io.IOException) TupleQueryResultHandlerException(org.eclipse.rdf4j.query.TupleQueryResultHandlerException) QueryResultHandlerException(org.eclipse.rdf4j.query.QueryResultHandlerException)

Example 7 with TupleQueryResultHandlerException

use of org.eclipse.rdf4j.query.TupleQueryResultHandlerException in project rdf4j by eclipse.

the class AbstractSPARQLXMLWriter method startQueryResult.

@Override
public void startQueryResult(List<String> bindingNames) throws TupleQueryResultHandlerException {
    try {
        if (!documentOpen) {
            startDocument();
        }
        if (!headerOpen) {
            startHeader();
        }
        tupleVariablesFound = true;
        // Write binding names
        for (String name : bindingNames) {
            xmlWriter.setAttribute(VAR_NAME_ATT, name);
            xmlWriter.emptyElement(VAR_TAG);
        }
    } catch (IOException e) {
        throw new TupleQueryResultHandlerException(e);
    } catch (TupleQueryResultHandlerException e) {
        throw e;
    } catch (QueryResultHandlerException e) {
        throw new TupleQueryResultHandlerException(e);
    }
}
Also used : TupleQueryResultHandlerException(org.eclipse.rdf4j.query.TupleQueryResultHandlerException) IOException(java.io.IOException) TupleQueryResultHandlerException(org.eclipse.rdf4j.query.TupleQueryResultHandlerException) QueryResultHandlerException(org.eclipse.rdf4j.query.QueryResultHandlerException)

Example 8 with TupleQueryResultHandlerException

use of org.eclipse.rdf4j.query.TupleQueryResultHandlerException in project rdf4j by eclipse.

the class RDF4JProtocolSession method getNamespaces.

/*---------------------------*
	 * Get/add/remove namespaces *
	 *---------------------------*/
public TupleQueryResult getNamespaces() throws IOException, RepositoryException, UnauthorizedException, QueryInterruptedException {
    try {
        TupleQueryResultBuilder builder = new TupleQueryResultBuilder();
        getNamespaces(builder);
        return builder.getQueryResult();
    } catch (TupleQueryResultHandlerException e) {
        // Found a bug in TupleQueryResultBuilder?
        throw new RuntimeException(e);
    }
}
Also used : TupleQueryResultBuilder(org.eclipse.rdf4j.query.impl.TupleQueryResultBuilder) TupleQueryResultHandlerException(org.eclipse.rdf4j.query.TupleQueryResultHandlerException)

Example 9 with TupleQueryResultHandlerException

use of org.eclipse.rdf4j.query.TupleQueryResultHandlerException in project rdf4j by eclipse.

the class RDF4JProtocolSession method getContextIDs.

/*-------------*
	 * Context IDs *
	 *-------------*/
public TupleQueryResult getContextIDs() throws IOException, RepositoryException, UnauthorizedException, QueryInterruptedException {
    try {
        TupleQueryResultBuilder builder = new TupleQueryResultBuilder();
        getContextIDs(builder);
        return builder.getQueryResult();
    } catch (TupleQueryResultHandlerException e) {
        // Found a bug in TupleQueryResultBuilder?
        throw new RuntimeException(e);
    }
}
Also used : TupleQueryResultBuilder(org.eclipse.rdf4j.query.impl.TupleQueryResultBuilder) TupleQueryResultHandlerException(org.eclipse.rdf4j.query.TupleQueryResultHandlerException)

Example 10 with TupleQueryResultHandlerException

use of org.eclipse.rdf4j.query.TupleQueryResultHandlerException in project rdf4j by eclipse.

the class RDF4JProtocolSession method getRepositoryList.

/*-----------------*
	 * Repository list *
	 *-----------------*/
public TupleQueryResult getRepositoryList() throws IOException, RepositoryException, UnauthorizedException, QueryInterruptedException {
    try {
        TupleQueryResultBuilder builder = new TupleQueryResultBuilder();
        getRepositoryList(builder);
        return builder.getQueryResult();
    } catch (TupleQueryResultHandlerException e) {
        // Found a bug in TupleQueryResultBuilder?
        throw new RuntimeException(e);
    }
}
Also used : TupleQueryResultBuilder(org.eclipse.rdf4j.query.impl.TupleQueryResultBuilder) TupleQueryResultHandlerException(org.eclipse.rdf4j.query.TupleQueryResultHandlerException)

Aggregations

TupleQueryResultHandlerException (org.eclipse.rdf4j.query.TupleQueryResultHandlerException)24 IOException (java.io.IOException)12 QueryResultHandlerException (org.eclipse.rdf4j.query.QueryResultHandlerException)9 Value (org.eclipse.rdf4j.model.Value)6 Binding (org.eclipse.rdf4j.query.Binding)4 TupleQueryResultBuilder (org.eclipse.rdf4j.query.impl.TupleQueryResultBuilder)4 RDFHandlerException (org.eclipse.rdf4j.rio.RDFHandlerException)4 BNode (org.eclipse.rdf4j.model.BNode)2 Literal (org.eclipse.rdf4j.model.Literal)2 Resource (org.eclipse.rdf4j.model.Resource)2 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)1 HttpResponse (org.apache.http.HttpResponse)1 Graph (org.eclipse.rdf4j.model.Graph)1 IRI (org.eclipse.rdf4j.model.IRI)1 GraphImpl (org.eclipse.rdf4j.model.impl.GraphImpl)1 GraphUtilException (org.eclipse.rdf4j.model.util.GraphUtilException)1 ListBindingSet (org.eclipse.rdf4j.query.impl.ListBindingSet)1 MapBindingSet (org.eclipse.rdf4j.query.impl.MapBindingSet)1 SimpleBinding (org.eclipse.rdf4j.query.impl.SimpleBinding)1 BooleanQueryResultFormat (org.eclipse.rdf4j.query.resultio.BooleanQueryResultFormat)1