Class BinaryQueryResultParser
- java.lang.Object
-
- org.eclipse.rdf4j.query.resultio.AbstractQueryResultParser
-
- org.eclipse.rdf4j.query.resultio.AbstractTupleQueryResultParser
-
- org.eclipse.rdf4j.query.resultio.binary.BinaryQueryResultParser
-
- All Implemented Interfaces:
QueryResultParser,TupleQueryResultParser
public class BinaryQueryResultParser extends AbstractTupleQueryResultParser
Reader for the binary tuple result format. The format is explained inBinaryQueryResultConstants.
-
-
Field Summary
Fields Modifier and Type Field Description private java.nio.charset.CharsetDecodercharsetDecoderprivate intformatVersionprivate java.io.DataInputStreaminprivate static intINVALID_CONTENT_LIMITprivate static org.slf4j.Loggerloggerprivate java.lang.String[]namespaceArray-
Fields inherited from class org.eclipse.rdf4j.query.resultio.AbstractQueryResultParser
handler, valueFactory
-
-
Constructor Summary
Constructors Constructor Description BinaryQueryResultParser()Creates a new parser for the binary query result format that will use an instance ofSimpleValueFactoryto create Value objects.BinaryQueryResultParser(ValueFactory valueFactory)Creates a new parser for the binary query result format that will use the supplied ValueFactory to create Value objects.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.StringextractInvalidContentAsString(int recordTypeMarker)Used when trying to parse some invalid content.TupleQueryResultFormatgetTupleQueryResultFormat()Gets the query result format that this parser can parse.voidparse(java.io.InputStream in)Parses the data from the supplied InputStream.private voidprocessError()private voidprocessNamespace()private BNodereadBnode()private ValuereadDirectValue()private LiteralreadLiteral(int recordTypeMarker)private IRIreadQName()private java.lang.StringreadString()private java.lang.StringreadStringV1()Reads a string from the version 1 format, i.e.private java.lang.StringreadStringV2()Reads a string from the version 2 format.private TriplereadTriple()private IRIreadURI()-
Methods inherited from class org.eclipse.rdf4j.query.resultio.AbstractTupleQueryResultParser
getQueryResultFormat, parseQueryResult, setTupleQueryResultHandler
-
Methods inherited from class org.eclipse.rdf4j.query.resultio.AbstractQueryResultParser
getParseErrorListener, getParseLocationListener, getParserConfig, getSupportedSettings, set, setParseErrorListener, setParseLocationListener, setParserConfig, setQueryResultHandler, setValueFactory
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.rdf4j.query.resultio.QueryResultParser
getParserConfig, getSupportedSettings, set, setParseErrorListener, setParseLocationListener, setParserConfig, setQueryResultHandler, setValueFactory
-
-
-
-
Field Detail
-
in
private java.io.DataInputStream in
-
formatVersion
private int formatVersion
-
charsetDecoder
private final java.nio.charset.CharsetDecoder charsetDecoder
-
logger
private static final org.slf4j.Logger logger
-
namespaceArray
private java.lang.String[] namespaceArray
-
INVALID_CONTENT_LIMIT
private static final int INVALID_CONTENT_LIMIT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BinaryQueryResultParser
public BinaryQueryResultParser()
Creates a new parser for the binary query result format that will use an instance ofSimpleValueFactoryto create Value objects.
-
BinaryQueryResultParser
public BinaryQueryResultParser(ValueFactory valueFactory)
Creates a new parser for the binary query result format that will use the supplied ValueFactory to create Value objects.
-
-
Method Detail
-
getTupleQueryResultFormat
public final TupleQueryResultFormat getTupleQueryResultFormat()
Description copied from interface:TupleQueryResultParserGets the query result format that this parser can parse.
-
parse
public void parse(java.io.InputStream in) throws java.io.IOException, QueryResultParseException, TupleQueryResultHandlerExceptionDescription copied from interface:TupleQueryResultParserParses the data from the supplied InputStream.- Parameters:
in- The InputStream from which to read the data.- Throws:
java.io.IOException- If an I/O error occurred while data was read from the InputStream.QueryResultParseException- If the parser has encountered an unrecoverable parse error.TupleQueryResultHandlerException- If the configured query result handler has encountered an unrecoverable error.
-
processError
private void processError() throws java.io.IOException, QueryResultParseException- Throws:
java.io.IOExceptionQueryResultParseException
-
processNamespace
private void processNamespace() throws java.io.IOException- Throws:
java.io.IOException
-
readQName
private IRI readQName() throws java.io.IOException
- Throws:
java.io.IOException
-
readURI
private IRI readURI() throws java.io.IOException
- Throws:
java.io.IOException
-
readBnode
private BNode readBnode() throws java.io.IOException
- Throws:
java.io.IOException
-
readLiteral
private Literal readLiteral(int recordTypeMarker) throws java.io.IOException, QueryResultParseException
- Throws:
java.io.IOExceptionQueryResultParseException
-
readString
private java.lang.String readString() throws java.io.IOException- Throws:
java.io.IOException
-
extractInvalidContentAsString
private java.lang.String extractInvalidContentAsString(int recordTypeMarker) throws java.io.IOExceptionUsed when trying to parse some invalid content. Reads the remaining bytes as string in order to provide more user-friendly error message. Sets the max limit of the returned string, if its length > INVALID_CONTENT_LIMIT, the returned string is trimmed and "..." is appended in order to prevent displaying too long result.- Throws:
java.io.IOException
-
readStringV1
private java.lang.String readStringV1() throws java.io.IOExceptionReads a string from the version 1 format, i.e. in Java's {@link DataInput#modified-utf-8 Modified UTF-8}.- Throws:
java.io.IOException
-
readStringV2
private java.lang.String readStringV2() throws java.io.IOExceptionReads a string from the version 2 format. Strings are encoded as UTF-8 and are preceeded by a 32-bit integer (high byte first) specifying the length of the encoded string.- Throws:
java.io.IOException
-
readTriple
private Triple readTriple() throws java.io.IOException
- Throws:
java.io.IOException
-
readDirectValue
private Value readDirectValue() throws java.io.IOException
- Throws:
java.io.IOException
-
-