org.eclipse.rdf4j.query.resultio.sparqljson.SPARQLBooleanJSONWriter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rdf4j-queryresultio-sparqljson Show documentation
Show all versions of rdf4j-queryresultio-sparqljson Show documentation
Query result writer implementation for the SPARQL Query Results JSON Format.
The newest version!
/*******************************************************************************
* Copyright (c) 2015 Eclipse RDF4J contributors, Aduna, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Distribution License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/
package org.eclipse.rdf4j.query.resultio.sparqljson;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;
import org.eclipse.rdf4j.query.QueryResultHandlerException;
import org.eclipse.rdf4j.query.resultio.BooleanQueryResultFormat;
import org.eclipse.rdf4j.query.resultio.BooleanQueryResultWriter;
/**
* A BooleanQueryResultWriter that writes query results in the
* SPARQL Query Results JSON Format.
*/
public class SPARQLBooleanJSONWriter extends AbstractSPARQLJSONWriter implements BooleanQueryResultWriter {
/*--------------*
* Constructors *
*--------------*/
public SPARQLBooleanJSONWriter(OutputStream out) {
super(out);
}
public SPARQLBooleanJSONWriter(Writer writer) {
super(writer);
}
/*---------*
* Methods *
*---------*/
@Override
public final BooleanQueryResultFormat getBooleanQueryResultFormat() {
return BooleanQueryResultFormat.JSON;
}
@Override
public final BooleanQueryResultFormat getQueryResultFormat() {
return getBooleanQueryResultFormat();
}
@Override
public void write(boolean value) throws IOException {
try {
handleBoolean(value);
} catch (QueryResultHandlerException e) {
if (e.getCause() != null && e.getCause() instanceof IOException) {
throw (IOException) e.getCause();
} else {
throw new IOException(e);
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy