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
public class NTParser extends java.lang.Object implements RDFParser
Default implementation of a
parserfor 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 Modifier and Type Field Description protected static org.slf4j.LoggerLOGGER
-
Constructor Summary
Constructors Constructor Description NTParser()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected intassertLineTerminates(IOParserContext theContext)Verifies that there is only whitespace or comments until the end of the line.RDFFormatformat()The format this parser can parsevoidparse(IOParserContext theContext)voidparse(java.io.InputStream theStream, RDFHandler theRDFHandler, Options theOptions)Parse the contentprotected intparseNodeID(IOParserContext theContext, int c, java.lang.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, java.lang.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.
-
-
-
Method Detail
-
format
@Nonnull public RDFFormat format()
The format this parser can parse
-
parse
public void parse(@Nonnull java.io.InputStream theStream, @Nonnull RDFHandler theRDFHandler, @Nonnull Options theOptions) throws java.io.IOExceptionParse the content
-
parse
public void parse(@Nonnull IOParserContext theContext) throws java.io.IOException- Throws:
java.io.IOException
-
parseSubject
protected int parseSubject(@Nonnull IOParserContext theContext, int ch) throws java.io.IOException- Throws:
java.io.IOException
-
parsePredicate
protected int parsePredicate(@Nonnull IOParserContext theContext, int ch) throws java.io.IOException- Throws:
java.io.IOException
-
parseObject
protected int parseObject(@Nonnull IOParserContext theContext, int ch) throws java.io.IOException- Throws:
java.io.IOException
-
parseUriRef
protected int parseUriRef(@Nonnull IOParserContext theContext, int ch, java.lang.StringBuilder uriRef) throws java.io.IOException- Throws:
java.io.IOException
-
parseNodeID
protected int parseNodeID(@Nonnull IOParserContext theContext, int c, @Nonnull java.lang.StringBuilder name) throws java.io.IOException- Throws:
java.io.IOException
-
assertLineTerminates
protected int assertLineTerminates(@Nonnull IOParserContext theContext) throws java.io.IOExceptionVerifies that there is only whitespace or comments until the end of the line.- Throws:
java.io.IOException
-
skipToEndOfLine
protected int skipToEndOfLine(@Nonnull IOParserContext theContext, int theChar) throws java.io.IOExceptionReads characters from reader until the first EOL has been read. The EOL character or -1 is returned.- Throws:
java.io.IOException
-
skipLine
protected int skipLine(int theChar, @Nonnull IOParserContext theContext) throws java.io.IOExceptionReads 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:
java.io.IOException
-
skipWhitespace
protected int skipWhitespace(@Nonnull IOParserContext theContext, int theChar) throws java.io.IOExceptionReads 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:
java.io.IOException
-
-