Class 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
  • Constructor Details

    • IOParserContext

      public IOParserContext(@Nonnull Reader theReader, @Nonnull RDFHandler theHandler, @Nonnull Options theOptions)
  • Method Details

    • langBuffer

      public StringBuilder langBuffer()
      Rest the buffer that can be used for parsing language tags and return it
      Returns:
      the buffer
    • datatypeBuffer

      public StringBuilder datatypeBuffer()
      Reset the buffer for parsing datatypes and return it
      Returns:
      the buffer
    • resetSB

      public StringBuilder resetSB()
    • trimSB

      public StringBuilder trimSB()
    • peekCodePoint

      public int peekCodePoint() throws 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:
      IOException
    • readCodePoint

      public int readCodePoint() throws 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:
      IOException
    • unread

      public void unread(int theCodePoint) throws IOException
      Pushes back a single code point by copying it to the front of the buffer. After this method returns, a call to readCodePoint() will return the same code point c again.
      Parameters:
      theCodePoint - a single Unicode code point.
      Throws:
      IOException
    • unread

      public void unread(@Nonnull String theStr)
      Pushes back the supplied string by copying it to the front of the buffer. After this method returns, successive calls to readCodePoint() 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:
      UncheckedIOException
    • verifyCharacterOrFail

      public int verifyCharacterOrFail(@Nonnull String expected) throws 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:
      IOException
    • verifyCharacterOrFail

      public int verifyCharacterOrFail(@Nonnull char expected) throws IOException
      Throws:
      IOException
    • verifyCharacterOrFail

      public int verifyCharacterOrFail(int codePoint, @Nonnull String expected) throws InvalidRDF
      Throws:
      InvalidRDF