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
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 Modifier and Type Field Description protected static org.slf4j.Logger
LOGGER
-
Constructor Summary
Constructors Constructor Description NTParser()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
assertLineTerminates(IOParserContext theContext)
Verifies that there is only whitespace or comments until the end of the line.RDFFormat
format()
The format this parser can parsevoid
parse(IOParserContext theContext)
void
parse(java.io.InputStream theStream, RDFHandler theRDFHandler, Options theOptions)
Parse the contentprotected int
parseNodeID(IOParserContext theContext, int c, java.lang.StringBuilder name)
protected int
parseObject(IOParserContext theContext, int ch)
protected int
parsePredicate(IOParserContext theContext, int ch)
protected int
parseSubject(IOParserContext theContext, int ch)
protected int
parseUriRef(IOParserContext theContext, int ch, java.lang.StringBuilder uriRef)
protected int
skipLine(int theChar, IOParserContext theContext)
Reads characters from reader until the first EOL has been read.protected int
skipToEndOfLine(IOParserContext theContext, int theChar)
Reads characters from reader until the first EOL has been read.protected int
skipWhitespace(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.IOException
Parse 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.IOException
Verifies 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.IOException
Reads 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.IOException
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:
java.io.IOException
-
skipWhitespace
protected int skipWhitespace(@Nonnull IOParserContext theContext, int theChar) throws java.io.IOException
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:
java.io.IOException
-
-