Package com.stardog.stark.io
Class IOParserContext
- java.lang.Object
-
- com.stardog.stark.io.AbstractRDFHandler
-
- com.stardog.stark.io.ParserContext
-
- com.stardog.stark.io.IOParserContext
-
- All Implemented Interfaces:
RDFHandler
- Direct Known Subclasses:
LineSupplierParserContext
,TurtleParserContext
public class IOParserContext extends ParserContext
Extended parser state that wraps the stream to be parsed to provide common IO operations for most of the basic text RDF formats.
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Michael Grove, Arjohn Kampman
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.stardog.stark.io.ParserContext
ParserContext.ParseError
-
-
Field Summary
-
Fields inherited from class com.stardog.stark.io.ParserContext
BNODE_ID_PREFIX, caseInsensitiveDirectives, mBaseIRI, mColumnNumber, mContext, mLineNumber, mNamespaces, mObject, mPredicate, mSubject
-
-
Constructor Summary
Constructors Constructor Description IOParserContext(java.io.Reader theReader, RDFHandler theHandler, Options theOptions)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringBuilder
datatypeBuffer()
Reset the buffer for parsing datatypes and return itjava.lang.StringBuilder
langBuffer()
Rest the buffer that can be used for parsing language tags and return itint
peekCodePoint()
Peeks at the next Unicode code point without advancing the reader, and returns its value.int
readCodePoint()
Reads the next Unicode code point.java.lang.StringBuilder
resetSB()
java.lang.StringBuilder
trimSB()
void
unread(int theCodePoint)
Pushes back a single code point by copying it to the front of the buffer.void
unread(java.lang.String theStr)
Pushes back the supplied string by copying it to the front of the buffer.int
verifyCharacterOrFail(char expected)
int
verifyCharacterOrFail(int codePoint, java.lang.String expected)
int
verifyCharacterOrFail(java.lang.String expected)
Verifies that the supplied character code point codePoint is one of the expected characters specified in expected.-
Methods inherited from class com.stardog.stark.io.ParserContext
createBNode, createBNode, createLiteral, currentStatement, end, error, error, getRandomBnodeIdPrefix, handle, is, namespace, namespace, reportStatement, resetStatement, resolveURI, start
-
-
-
-
Constructor Detail
-
IOParserContext
public IOParserContext(@Nonnull java.io.Reader theReader, @Nonnull RDFHandler theHandler, @Nonnull Options theOptions)
-
-
Method Detail
-
langBuffer
public java.lang.StringBuilder langBuffer()
Rest the buffer that can be used for parsing language tags and return it- Returns:
- the buffer
-
datatypeBuffer
public java.lang.StringBuilder datatypeBuffer()
Reset the buffer for parsing datatypes and return it- Returns:
- the buffer
-
resetSB
public java.lang.StringBuilder resetSB()
-
trimSB
public java.lang.StringBuilder trimSB()
-
peekCodePoint
public int peekCodePoint() throws java.io.IOException
Peeks at the next Unicode code point without advancing the reader, and returns its value.- Returns:
- the next Unicode code point, or -1 if the end of the stream has been reached.
- Throws:
java.io.IOException
-
readCodePoint
public int readCodePoint() throws java.io.IOException
Reads the next Unicode code point.- Returns:
- the next Unicode code point, or -1 if the end of the stream has been reached.
- Throws:
java.io.IOException
-
unread
public void unread(int theCodePoint) throws java.io.IOException
Pushes back a single code point by copying it to the front of the buffer. After this method returns, a call toreadCodePoint()
will return the same code point c again.- Parameters:
theCodePoint
- a single Unicode code point.- Throws:
java.io.IOException
-
unread
public void unread(@Nonnull java.lang.String theStr)
Pushes back the supplied string by copying it to the front of the buffer. After this method returns, successive calls toreadCodePoint()
will return the code points in the supplied string again, starting at the first in the String..- Parameters:
theStr
- the string to un-read.- Throws:
java.io.UncheckedIOException
-
verifyCharacterOrFail
public int verifyCharacterOrFail(@Nonnull java.lang.String expected) throws java.io.IOException
Verifies that the supplied character code point codePoint is one of the expected characters specified in expected. This method will throw a ParseException if this is not the case.- Throws:
java.io.IOException
-
verifyCharacterOrFail
public int verifyCharacterOrFail(@Nonnull char expected) throws java.io.IOException
- Throws:
java.io.IOException
-
verifyCharacterOrFail
public int verifyCharacterOrFail(int codePoint, @Nonnull java.lang.String expected) throws InvalidRDF
- Throws:
InvalidRDF
-
-