Package com.stardog.stark.io.ntriples
Class NTParser
java.lang.Object
com.stardog.stark.io.ntriples.NTParser
- All Implemented Interfaces:
RDFParser
- Direct Known Subclasses:
NQuadsParser
Default implementation of a parser for the RDF NTriples syntax
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Michael Grove
- Implementation Notes:
- non-final because it shares a lot of parsing code with nquads
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected intassertLineTerminates(IOParserContext theContext) Verifies that there is only whitespace or comments until the end of the line.format()The format this parser can parsevoidparse(IOParserContext theContext) voidparse(InputStream theStream, RDFHandler theRDFHandler, Options theOptions) Parse the contentprotected intparseNodeID(IOParserContext theContext, int c, StringBuilder name) protected intparseObject(IOParserContext theContext, int ch) protected intparsePredicate(IOParserContext theContext, int ch) protected intparseSubject(IOParserContext theContext, int ch) protected intparseUriRef(IOParserContext theContext, int ch, StringBuilder uriRef) protected intskipLine(int theChar, IOParserContext theContext) Reads characters from reader until the first EOL has been read.protected intskipToEndOfLine(IOParserContext theContext, int theChar) Reads characters from reader until the first EOL has been read.protected intskipWhitespace(IOParserContext theContext, int theChar) Reads characters from reader until it finds a character that is not a space or tab, and returns this last character code point.
-
Field Details
-
LOGGER
protected static final org.slf4j.Logger LOGGER
-
-
Constructor Details
-
NTParser
public NTParser()
-
-
Method Details
-
format
The format this parser can parse -
parse
public void parse(@Nonnull InputStream theStream, @Nonnull RDFHandler theRDFHandler, @Nonnull Options theOptions) throws IOException Parse the content- Specified by:
parsein interfaceRDFParser- Parameters:
theStream- the stream to read fromtheRDFHandler- the handler to pass parse events totheOptions- the parsing options- Throws:
IOException- if there was an error while reading from the stream
-
parse
- Throws:
IOException
-
parseSubject
- Throws:
IOException
-
parsePredicate
- Throws:
IOException
-
parseObject
- Throws:
IOException
-
parseUriRef
protected int parseUriRef(@Nonnull IOParserContext theContext, int ch, StringBuilder uriRef) throws IOException - Throws:
IOException
-
parseNodeID
protected int parseNodeID(@Nonnull IOParserContext theContext, int c, @Nonnull StringBuilder name) throws IOException - Throws:
IOException
-
assertLineTerminates
Verifies that there is only whitespace or comments until the end of the line.- Throws:
IOException
-
skipToEndOfLine
Reads characters from reader until the first EOL has been read. The EOL character or -1 is returned.- Throws:
IOException
-
skipLine
Reads characters from reader until the first EOL has been read. The first character after the EOL is returned. In case the end of the character stream has been reached, -1 is returned.- Throws:
IOException
-
skipWhitespace
Reads characters from reader until it finds a character that is not a space or tab, and returns this last character code point. In case the end of the character stream has been reached, -1 is returned.- Throws:
IOException
-