Class RdfNTriplesReader

  • Direct Known Subclasses:
    RdfTurtleReader

    public class RdfNTriplesReader
    extends RdfReader
    Handler of RDF content according to the N-Triples notation.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.io.BufferedReader br
      Internal buffered reader.
      private char[] buffer
      The reading buffer.
      private int BUFFER_SIZE
      Size of the reading buffer.
      int EOF
      End of reading buffer marker.
      private int scoutIndex
      Index that discovers the end of the current token and the beginning of the futur one.
      private int startTokenIndex
      Start index of current lexical unit.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void consumeStatement()
      Discard all read characters until the end of the statement is reached (marked by a '.').
      protected void consumeWhiteSpaces()
      Discard all read characters.
      protected void discard()
      Discard all read characters.
      protected char getChar()
      Returns the current parsed character.
      protected java.lang.String getCurrentToken()
      Returns the current token.
      java.lang.String getParsingMessage()
      Returns a message describing the current state of the parsing process.
      protected java.lang.String getParsingMessage​(char[] buffer, int startTokenIndex, int scoutIndex)
      Returns a message describing the current state of the parsing process.
      protected boolean isAlphaNum​(int c)
      Returns true if the given character is alphanumeric.
      protected boolean isDelimiter​(int c)
      Returns true if the given character is a delimiter.
      protected boolean isEndOfFile​(int c)  
      protected boolean isWhiteSpace​(int c)
      Returns true if the given character is a whitespace.
      void parse()
      Parses the current representation.
      protected void parseComment()
      Parses a comment.
      protected void parseStatement()
      Reads the current statement until its end, and parses it.
      protected java.lang.String parseToken()
      Returns the value of the current token.
      protected java.lang.String parseUri()
      Returns the value of the current URI.
      protected int step()
      Read a new character.
      protected void step​(int n)
      Steps forward.
      protected void stepBack()
      Steps back of one step.
      protected void stepBack​(int n)
      Steps back.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • br

        private java.io.BufferedReader br
        Internal buffered reader.
      • buffer

        private final char[] buffer
        The reading buffer.
      • scoutIndex

        private int scoutIndex
        Index that discovers the end of the current token and the beginning of the futur one.
      • startTokenIndex

        private int startTokenIndex
        Start index of current lexical unit.
    • Constructor Detail

      • RdfNTriplesReader

        public RdfNTriplesReader​(Representation rdfRepresentation,
                                 GraphHandler graphHandler)
                          throws java.io.IOException
        Constructor.
        Parameters:
        rdfRepresentation - The representation to read.
        graphHandler - The graph handler invoked during the parsing.
        Throws:
        java.io.IOException
    • Method Detail

      • consumeStatement

        protected void consumeStatement()
                                 throws java.io.IOException
        Discard all read characters until the end of the statement is reached (marked by a '.').
        Throws:
        java.io.IOException
      • consumeWhiteSpaces

        protected void consumeWhiteSpaces()
                                   throws java.io.IOException
        Discard all read characters. A call to getCurrentToken() will return a single character.
        Throws:
        java.io.IOException
      • discard

        protected void discard()
        Discard all read characters. A call to getCurrentToken() will return a single character.
      • getChar

        protected char getChar()
        Returns the current parsed character.
        Returns:
        The current parsed character.
      • getCurrentToken

        protected java.lang.String getCurrentToken()
        Returns the current token.
        Returns:
        The current token.
      • getParsingMessage

        public java.lang.String getParsingMessage()
        Returns a message describing the current state of the parsing process.
        Returns:
        A message describing the current state of the parsing process.
      • getParsingMessage

        protected java.lang.String getParsingMessage​(char[] buffer,
                                                     int startTokenIndex,
                                                     int scoutIndex)
        Returns a message describing the current state of the parsing process.
        Parameters:
        buffer - The current buffer.
        startTokenIndex - The start index of parsing.
        scoutIndex - The index of the probable future token.
        Returns:
      • isAlphaNum

        protected boolean isAlphaNum​(int c)
        Returns true if the given character is alphanumeric.
        Parameters:
        c - The given character to check.
        Returns:
        true if the given character is alphanumeric.
      • isDelimiter

        protected boolean isDelimiter​(int c)
        Returns true if the given character is a delimiter.
        Parameters:
        c - The given character to check.
        Returns:
        true if the given character is a delimiter.
      • isEndOfFile

        protected boolean isEndOfFile​(int c)
      • isWhiteSpace

        protected boolean isWhiteSpace​(int c)
        Returns true if the given character is a whitespace.
        Parameters:
        c - The given character to check.
        Returns:
        true if the given character is a whitespace.
      • parse

        public void parse()
                   throws java.io.IOException
        Parses the current representation.
        Specified by:
        parse in class RdfReader
        Throws:
        java.io.IOException
      • parseComment

        protected void parseComment()
                             throws java.io.IOException
        Parses a comment.
        Throws:
        java.io.IOException
      • parseStatement

        protected void parseStatement()
                               throws java.io.IOException
        Reads the current statement until its end, and parses it.
        Parameters:
        context - The current context.
        Throws:
        java.io.IOException
      • parseToken

        protected java.lang.String parseToken()
                                       throws java.io.IOException
        Returns the value of the current token.
        Returns:
        The value of the current token.
        Throws:
        java.io.IOException
      • parseUri

        protected java.lang.String parseUri()
                                     throws java.io.IOException
        Returns the value of the current URI.
        Returns:
        The value of the current URI.
        Throws:
        java.io.IOException
      • step

        protected int step()
                    throws java.io.IOException
        Read a new character.
        Returns:
        The new read character.
        Throws:
        java.io.IOException
      • step

        protected void step​(int n)
                     throws java.io.IOException
        Steps forward.
        Parameters:
        n - The number of steps to go forward.
        Throws:
        java.io.IOException
      • stepBack

        protected void stepBack()
        Steps back of one step.
      • stepBack

        protected void stepBack​(int n)
        Steps back.
        Parameters:
        n - The number of steps to go back.