Class SimpleCharStream

java.lang.Object
org.tweetyproject.arg.delp.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 and encoding.
    SimpleCharStream(InputStream dstream, String encoding, int startline, int startcolumn)
    Constructs a SimpleCharStream with the specified input stream, 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, encoding, starting line, starting column, and buffer size.
    Constructs a SimpleCharStream with the specified reader.
    SimpleCharStream(Reader dstream, int startline, int startcolumn)
    Constructs a SimpleCharStream with the specified reader, starting line, and starting column.
    SimpleCharStream(Reader dstream, int startline, int startcolumn, int buffersize)
    Constructs a SimpleCharStream with the specified 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)
    Rewinds the input stream by a specified number of characters.
    char
    Start.
    void
    Reset buffer when finished.
    int
    Retrieves the column number where the current token begins.
    int
    Retrieves the line number where the current token begins.
    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 SimpleCharStream with the specified input stream.
    void
    ReInit(InputStream dstream, int startline, int startcolumn)
    Reinitializes the SimpleCharStream with the specified input stream, starting line, and starting column.
    void
    ReInit(InputStream dstream, int startline, int startcolumn, int buffersize)
    Reinitializes the SimpleCharStream with the specified input stream, starting line, starting column, and buffer size.
    void
    ReInit(InputStream dstream, String encoding)
    Reinitializes the SimpleCharStream with the specified input stream and encoding.
    void
    ReInit(InputStream dstream, String encoding, int startline, int startcolumn)
    Reinitializes the SimpleCharStream with the specified input stream, encoding, starting line, and starting column.
    void
    ReInit(InputStream dstream, String encoding, int startline, int startcolumn, int buffersize)
    Reinitializes the SimpleCharStream with the specified input stream, encoding, starting line, starting column, and buffer size.
    void
    ReInit(Reader dstream)
    Reinitializes the SimpleCharStream with the specified reader.
    void
    ReInit(Reader dstream, int startline, int startcolumn)
    Reinitializes the SimpleCharStream with the specified reader, starting line, and starting column.
    void
    ReInit(Reader dstream, int startline, int startcolumn, int buffersize)
    Reinitializes the SimpleCharStream with the specified 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 reader, starting line, starting column, and buffer size.
      Parameters:
      dstream - The input reader from which characters are read.
      startline - The line number where reading starts.
      startcolumn - The column number where reading starts.
      buffersize - The size of the character buffer.
    • SimpleCharStream

      public SimpleCharStream(Reader dstream, int startline, int startcolumn)
      Constructs a SimpleCharStream with the specified reader, starting line, and starting column. The buffer size is set to 4096 characters.
      Parameters:
      dstream - The input reader from which characters are read.
      startline - The line number where reading starts.
      startcolumn - The column number where reading starts.
    • SimpleCharStream

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

      public SimpleCharStream(InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) throws UnsupportedEncodingException
      Constructs a SimpleCharStream with the specified input stream, encoding, starting line, starting column, and buffer size.
      Parameters:
      dstream - The input stream from which characters are read.
      encoding - The character encoding to use.
      startline - The line number where reading starts.
      startcolumn - The column number where reading starts.
      buffersize - The size of the character buffer.
      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. Uses the default encoding for reading.
      Parameters:
      dstream - The input stream from which characters are read.
      startline - The line number where reading starts.
      startcolumn - The column number where reading starts.
      buffersize - The size of the character buffer.
    • SimpleCharStream

      public SimpleCharStream(InputStream dstream, String encoding, int startline, int startcolumn) throws UnsupportedEncodingException
      Constructs a SimpleCharStream with the specified input stream, encoding, starting line, and starting column. The buffer size is set to 4096 characters.
      Parameters:
      dstream - The input stream from which characters are read.
      encoding - The character encoding to use.
      startline - The line number where reading starts.
      startcolumn - The column number where reading starts.
      Throws:
      UnsupportedEncodingException - If the specified encoding is not supported.
    • 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.
      Parameters:
      dstream - The input stream from which characters are read.
      startline - The line number where reading starts.
      startcolumn - The column number where reading starts.
    • SimpleCharStream

      public SimpleCharStream(InputStream dstream, String encoding) throws UnsupportedEncodingException
      Constructs a SimpleCharStream with the specified input stream and encoding. The starting line and column are set to 1, and the buffer size is set to 4096 characters.
      Parameters:
      dstream - The input stream from which characters are read.
      encoding - The character encoding to use.
      Throws:
      UnsupportedEncodingException - If the specified encoding is not supported.
    • 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.
      Parameters:
      dstream - The input stream from which characters are read.
  • Method Details

    • BeginToken

      public char BeginToken() throws IOException
      Start.
      Returns:
      the begin token
      Throws:
      IOException - error
    • readChar

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

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

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

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

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

      public int getBeginColumn()
      Retrieves the column number where the current token begins.
      Returns:
      The column number of the beginning of the current token.
    • getBeginLine

      public int getBeginLine()
      Retrieves the line number where the current token begins.
      Returns:
      The line number of the beginning of the current token.
    • backup

      public void backup(int amount)
      Rewinds the input stream by a specified number of characters. This allows you to backtrack in the input stream if needed.
      Parameters:
      amount - The number of characters to move backwards. This should be a positive integer.
    • ReInit

      public void ReInit(Reader dstream, int startline, int startcolumn, int buffersize)
      Reinitializes the SimpleCharStream with the specified reader, starting line, starting column, and buffer size. This method also resets the internal state of the stream.
      Parameters:
      dstream - The new input reader from which characters are read.
      startline - The new line number where reading starts.
      startcolumn - The new column number where reading starts.
      buffersize - The new size of the character buffer.
    • ReInit

      public void ReInit(Reader dstream, int startline, int startcolumn)
      Reinitializes the SimpleCharStream with the specified reader, starting line, and starting column. The buffer size is set to 4096 characters.
      Parameters:
      dstream - The new input reader from which characters are read.
      startline - The new line number where reading starts.
      startcolumn - The new column number where reading starts.
    • ReInit

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

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

      public void ReInit(InputStream dstream, int startline, int startcolumn, int buffersize)
      Reinitializes the SimpleCharStream with the specified input stream, starting line, starting column, and buffer size. Uses the default encoding.
      Parameters:
      dstream - The input stream from which characters are read.
      startline - The line number where reading starts.
      startcolumn - The column number where reading starts.
      buffersize - The size of the character buffer.
    • ReInit

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

      public void ReInit(InputStream dstream)
      Reinitializes the SimpleCharStream with the specified input stream. The starting line and column are set to 1, and the buffer size is set to 4096 characters.
      Parameters:
      dstream - The input stream from which characters are read.
    • ReInit

      public void ReInit(InputStream dstream, String encoding, int startline, int startcolumn) throws UnsupportedEncodingException
      Reinitializes the SimpleCharStream with the specified input stream, encoding, starting line, and starting column. The buffer size is set to 4096 characters.
      Parameters:
      dstream - The input stream from which characters are read.
      encoding - The character encoding to use.
      startline - The line number where reading starts.
      startcolumn - The column number where reading starts.
      Throws:
      UnsupportedEncodingException - If the specified encoding is not supported.
    • ReInit

      public void ReInit(InputStream dstream, int startline, int startcolumn)
      Reinitializes the SimpleCharStream with the specified input stream, starting line, and starting column. The buffer size is set to 4096 characters. Uses the default encoding.
      Parameters:
      dstream - The input stream from which characters are read.
      startline - The line number where reading starts.
      startcolumn - The column number where reading starts.
    • GetImage

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

      public char[] GetSuffix(int len)
      Get the suffix.
      Parameters:
      len - size
      Returns:
      the suffix
    • 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 - line
      newCol - col