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 Detail

      • IOParserContext

        public IOParserContext​(@Nonnull
                               java.io.Reader theReader,
                               @Nonnull
                               RDFHandler theHandler,
                               @Nonnull
                               Options theOptions)
    • Method Detail

      • langBuffer

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

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

        public java.lang.StringBuilder resetSB()
      • trimSB

        public java.lang.StringBuilder trimSB()
      • peekCodePoint

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

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

        public void unread​(int theCodePoint)
                    throws java.io.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:
        java.io.IOException
      • unread

        public void unread​(@Nonnull
                           java.lang.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:
        java.io.UncheckedIOException
      • verifyCharacterOrFail

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

        public int verifyCharacterOrFail​(@Nonnull
                                         char expected)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • verifyCharacterOrFail

        public int verifyCharacterOrFail​(int codePoint,
                                         @Nonnull
                                         java.lang.String expected)
                                  throws InvalidRDF
        Throws:
        InvalidRDF