Class NTParser

java.lang.Object
com.stardog.stark.io.ntriples.NTParser
All Implemented Interfaces:
RDFParser
Direct Known Subclasses:
NQuadsParser

public class NTParser extends 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 Details

    • LOGGER

      protected static final org.slf4j.Logger LOGGER
  • Constructor Details

    • NTParser

      public NTParser()
  • Method Details

    • format

      @Nonnull public RDFFormat format()
      The format this parser can parse
      Specified by:
      format in interface RDFParser
      Returns:
      the format
    • parse

      public void parse(@Nonnull InputStream theStream, @Nonnull RDFHandler theRDFHandler, @Nonnull Options theOptions) throws IOException
      Parse the content
      Specified by:
      parse in interface RDFParser
      Parameters:
      theStream - the stream to read from
      theRDFHandler - the handler to pass parse events to
      theOptions - the parsing options
      Throws:
      IOException - if there was an error while reading from the stream
    • parse

      public void parse(@Nonnull IOParserContext theContext) throws IOException
      Throws:
      IOException
    • parseSubject

      protected int parseSubject(@Nonnull IOParserContext theContext, int ch) throws IOException
      Throws:
      IOException
    • parsePredicate

      protected int parsePredicate(@Nonnull IOParserContext theContext, int ch) throws IOException
      Throws:
      IOException
    • parseObject

      protected int parseObject(@Nonnull IOParserContext theContext, int ch) throws IOException
      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

      protected int assertLineTerminates(@Nonnull IOParserContext theContext) throws IOException
      Verifies that there is only whitespace or comments until the end of the line.
      Throws:
      IOException
    • skipToEndOfLine

      protected int skipToEndOfLine(@Nonnull IOParserContext theContext, int theChar) throws IOException
      Reads characters from reader until the first EOL has been read. The EOL character or -1 is returned.
      Throws:
      IOException
    • skipLine

      protected int skipLine(int theChar, @Nonnull IOParserContext theContext) throws 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:
      IOException
    • skipWhitespace

      protected int skipWhitespace(@Nonnull IOParserContext theContext, int theChar) throws 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:
      IOException