Class SimpleCharStream

java.lang.Object
org.tweetyproject.lp.asp.parser.SimpleCharStream

public class SimpleCharStream extends Object
An implementation of interface CharStream, where the stream is assumed to contain only ASCII characters (without unicode processing).
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    int
    Position in buffer.
    static final boolean
    Whether parser is static.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a SimpleCharStream with the specified input stream.
    SimpleCharStream(InputStream dstream, int startline, int startcolumn)
    Constructs a SimpleCharStream with the specified input stream, starting line, and starting column.
    SimpleCharStream(InputStream dstream, int startline, int startcolumn, int buffersize)
    Constructs a SimpleCharStream with the specified input stream, starting line, starting column, and buffer size.
    SimpleCharStream(InputStream dstream, String encoding)
    Constructs a SimpleCharStream with the specified input stream, character encoding, and a default buffer size of 4096 characters.
    SimpleCharStream(InputStream dstream, String encoding, int startline, int startcolumn)
    Constructs a SimpleCharStream with the specified input stream, character encoding, starting line, and starting column.
    SimpleCharStream(InputStream dstream, String encoding, int startline, int startcolumn, int buffersize)
    Constructs a SimpleCharStream with the specified input stream, character encoding, starting line, starting column, and buffer size.
    Constructs a SimpleCharStream with the specified input reader.
    SimpleCharStream(Reader dstream, int startline, int startcolumn)
    Constructs a SimpleCharStream with the specified input reader, starting line, and starting column.
    SimpleCharStream(Reader dstream, int startline, int startcolumn, int buffersize)
    Constructs a SimpleCharStream with the specified input reader, starting line, starting column, and buffer size.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    adjustBeginLineColumn(int newLine, int newCol)
    Method to adjust line and column numbers for the start of a token.
    void
    backup(int amount)
    backup by amount
    char
    Return begin
    void
    Reset buffer when finished.
    int
    Get token beginning column number
    int
    Get token beginning line number
    int
    Deprecated. 
    int
    Get token end column number
    int
    Get token end line number
    Get token literal value.
    int
    Deprecated. 
    char[]
    GetSuffix(int len)
    Get the suffix.
    char
    Read a character
    void
    Reinitializes the character stream with the specified input stream.
    void
    ReInit(InputStream dstream, int startline, int startcolumn)
    Reinitializes the character stream with the specified input stream, starting line, and starting column.
    void
    ReInit(InputStream dstream, int startline, int startcolumn, int buffersize)
    Reinitializes the character stream with the specified input stream, starting line, starting column, and buffer size.
    void
    ReInit(InputStream dstream, String encoding)
    Reinitializes the character stream with the specified input stream and character encoding.
    void
    ReInit(InputStream dstream, String encoding, int startline, int startcolumn)
    Reinitializes the character stream with the specified input stream, character encoding, starting line, and starting column.
    void
    ReInit(InputStream dstream, String encoding, int startline, int startcolumn, int buffersize)
    Reinitializes the character stream with the specified input stream, character encoding, starting line, starting column, and buffer size.
    void
    ReInit(Reader dstream)
    Reinitializes this SimpleCharStream with a new input reader.
    void
    ReInit(Reader dstream, int startline, int startcolumn)
    Reinitializes this SimpleCharStream with a new input reader, starting line, and starting column.
    void
    ReInit(Reader dstream, int startline, int startcolumn, int buffersize)
    Reinitializes this SimpleCharStream with a new input reader, starting line, starting column, and buffer size.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • staticFlag

      public static final boolean staticFlag
      Whether parser is static.
      See Also:
    • bufpos

      public int bufpos
      Position in buffer.
  • Constructor Details

    • SimpleCharStream

      public SimpleCharStream(Reader dstream, int startline, int startcolumn, int buffersize)
      Constructs a SimpleCharStream with the specified input reader, starting line, starting column, and buffer size.
      Parameters:
      dstream - The Reader to read character data from.
      startline - The line number to start reading from (1-based).
      startcolumn - The column number to start reading from (1-based).
      buffersize - The size of the buffer used to read characters.
    • SimpleCharStream

      public SimpleCharStream(Reader dstream, int startline, int startcolumn)
      Constructs a SimpleCharStream with the specified input reader, starting line, and starting column. The buffer size is set to 4096 characters by default.
      Parameters:
      dstream - The Reader to read character data from.
      startline - The line number to start reading from (1-based).
      startcolumn - The column number to start reading from (1-based).
    • SimpleCharStream

      public SimpleCharStream(Reader dstream)
      Constructs a SimpleCharStream with the specified input reader. The starting line and column are set to 1, and the buffer size is set to 4096 characters by default.
      Parameters:
      dstream - The Reader to read character data from.
    • SimpleCharStream

      public SimpleCharStream(InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) throws UnsupportedEncodingException
      Constructs a SimpleCharStream with the specified input stream, character encoding, starting line, starting column, and buffer size.
      Parameters:
      dstream - The InputStream to read character data from.
      encoding - The character encoding to use. If null, the default encoding is used.
      startline - The line number to start reading from (1-based).
      startcolumn - The column number to start reading from (1-based).
      buffersize - The size of the buffer used to read characters.
      Throws:
      UnsupportedEncodingException - If the specified encoding is not supported.
    • SimpleCharStream

      public SimpleCharStream(InputStream dstream, int startline, int startcolumn, int buffersize)
      Constructs a SimpleCharStream with the specified input stream, starting line, starting column, and buffer size. The character encoding is set to the platform's default.
      Parameters:
      dstream - The InputStream to read character data from.
      startline - The line number to start reading from (1-based).
      startcolumn - The column number to start reading from (1-based).
      buffersize - The size of the buffer used to read characters.
    • SimpleCharStream

      public SimpleCharStream(InputStream dstream, int startline, int startcolumn)
      Constructs a SimpleCharStream with the specified input stream, starting line, and starting column. The buffer size is set to 4096 characters by default. The character encoding is set to the platform's default.
      Parameters:
      dstream - The InputStream to read character data from.
      startline - The line number to start reading from (1-based).
      startcolumn - The column number to start reading from (1-based).
    • SimpleCharStream

      public SimpleCharStream(InputStream dstream)
      Constructs a SimpleCharStream with the specified input stream. The starting line and column are set to 1, and the buffer size is set to 4096 characters by default. The character encoding is set to the platform's default.
      Parameters:
      dstream - The InputStream to read character data from.
    • SimpleCharStream

      public SimpleCharStream(InputStream dstream, String encoding, int startline, int startcolumn) throws UnsupportedEncodingException
      Constructs a SimpleCharStream with the specified input stream, character encoding, starting line, and starting column. The buffer size is set to 4096 characters by default.
      Parameters:
      dstream - The InputStream to read character data from.
      encoding - The character encoding to use. If null, the default encoding is used.
      startline - The line number to start reading from (1-based).
      startcolumn - The column number to start reading from (1-based).
      Throws:
      UnsupportedEncodingException - If the specified encoding is not supported.
    • SimpleCharStream

      public SimpleCharStream(InputStream dstream, String encoding) throws UnsupportedEncodingException
      Constructs a SimpleCharStream with the specified input stream, character encoding, and a default buffer size of 4096 characters. The starting line and column are set to 1.
      Parameters:
      dstream - The InputStream to read character data from.
      encoding - The character encoding to use. If null, the default encoding is used.
      Throws:
      UnsupportedEncodingException - If the specified encoding is not supported.
  • Method Details

    • BeginToken

      public char BeginToken() throws IOException
      Return begin
      Returns:
      a char
      Throws:
      IOException - error
    • readChar

      public char readChar() throws IOException
      Read a character
      Returns:
      a character
      Throws:
      IOException - error
    • getColumn

      @Deprecated public int getColumn()
      Deprecated.
      Returns:
      a column
      See Also:
    • getLine

      @Deprecated public int getLine()
      Deprecated.
      Returns:
      a line
      See Also:
    • getEndColumn

      public int getEndColumn()
      Get token end column number
      Returns:
      token end column number
    • getEndLine

      public int getEndLine()
      Get token end line number
      Returns:
      token end line number
    • getBeginColumn

      public int getBeginColumn()
      Get token beginning column number
      Returns:
      Get token beginning column number
    • getBeginLine

      public int getBeginLine()
      Get token beginning line number
      Returns:
      Get token beginning line number
    • backup

      public void backup(int amount)
      backup by amount
      Parameters:
      amount - the amount
    • ReInit

      public void ReInit(Reader dstream, int startline, int startcolumn, int buffersize)
      Reinitializes this SimpleCharStream with a new input reader, starting line, starting column, and buffer size.
      Parameters:
      dstream - The Reader to read character data from.
      startline - The line number to start reading from (1-based).
      startcolumn - The column number to start reading from (1-based).
      buffersize - The size of the buffer used to read characters.
    • ReInit

      public void ReInit(Reader dstream, int startline, int startcolumn)
      Reinitializes this SimpleCharStream with a new input reader, starting line, and starting column. The buffer size is set to 4096 characters by default.
      Parameters:
      dstream - The Reader to read character data from.
      startline - The line number to start reading from (1-based).
      startcolumn - The column number to start reading from (1-based).
    • ReInit

      public void ReInit(Reader dstream)
      Reinitializes this SimpleCharStream with a new input reader. The starting line and column are set to 1, and the buffer size is set to 4096 characters by default.
      Parameters:
      dstream - The Reader to read character data from.
    • ReInit

      public void ReInit(InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) throws UnsupportedEncodingException
      Reinitializes the character stream with the specified input stream, character encoding, starting line, starting column, and buffer size.
      Parameters:
      dstream - The InputStream to read character data from.
      encoding - The character encoding to use. If null, the default encoding is used.
      startline - The line number to start reading from (1-based).
      startcolumn - The column number to start reading from (1-based).
      buffersize - The size of the buffer used to read characters.
      Throws:
      UnsupportedEncodingException - If the specified encoding is not supported.
    • ReInit

      public void ReInit(InputStream dstream, int startline, int startcolumn, int buffersize)
      Reinitializes the character stream with the specified input stream, starting line, starting column, and buffer size. The character encoding is set to the platform's default.
      Parameters:
      dstream - The InputStream to read character data from.
      startline - The line number to start reading from (1-based).
      startcolumn - The column number to start reading from (1-based).
      buffersize - The size of the buffer used to read characters.
    • ReInit

      public void ReInit(InputStream dstream, String encoding) throws UnsupportedEncodingException
      Reinitializes the character stream with the specified input stream and character encoding. The starting line and column are set to 1, and the buffer size is set to 4096 characters by default.
      Parameters:
      dstream - The InputStream to read character data from.
      encoding - The character encoding to use. If null, the default encoding is used.
      Throws:
      UnsupportedEncodingException - If the specified encoding is not supported.
    • ReInit

      public void ReInit(InputStream dstream)
      Reinitializes the character stream with the specified input stream. The starting line and column are set to 1, and the buffer size is set to 4096 characters by default. The character encoding is set to the platform's default.
      Parameters:
      dstream - The InputStream to read character data from.
    • ReInit

      public void ReInit(InputStream dstream, String encoding, int startline, int startcolumn) throws UnsupportedEncodingException
      Reinitializes the character stream with the specified input stream, character encoding, starting line, and starting column. The buffer size is set to 4096 characters by default.
      Parameters:
      dstream - The InputStream to read character data from.
      encoding - The character encoding to use. If null, the default encoding is used.
      startline - The line number to start reading from (1-based).
      startcolumn - The column number to start reading from (1-based).
      Throws:
      UnsupportedEncodingException - If the specified encoding is not supported.
    • ReInit

      public void ReInit(InputStream dstream, int startline, int startcolumn)
      Reinitializes the character stream with the specified input stream, starting line, and starting column. The buffer size is set to 4096 characters by default and the character encoding is set to the platform's default.
      Parameters:
      dstream - The InputStream to read character data from.
      startline - The line number to start reading from (1-based).
      startcolumn - The column number to start reading from (1-based).
    • GetImage

      public String GetImage()
      Get token literal value.
      Returns:
      image
    • GetSuffix

      public char[] GetSuffix(int len)
      Get the suffix.
      Parameters:
      len - length
      Returns:
      char
    • Done

      public void Done()
      Reset buffer when finished.
    • adjustBeginLineColumn

      public void adjustBeginLineColumn(int newLine, int newCol)
      Method to adjust line and column numbers for the start of a token.
      Parameters:
      newLine - new line
      newCol - the column