Class SimpleCharStream

java.lang.Object
org.tweetyproject.logics.rpcl.parser.rpclcondensedprobabilitydistributionparser.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
    static int
    Position in buffer.
    static final boolean
    Whether parser is static.
  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    static void
    adjustBeginLineColumn(int newLine, int newCol)
    Method to adjust line and column numbers for the start of a token.
    static void
    backup(int amount)
    Backup a number of characters.
    static char
    Start.
    static void
    Reset buffer when finished.
    static int
    Get token beginning column number.
    static int
    Get token beginning line number.
    static int
    Deprecated. 
    static int
    Get token end column number.
    static int
    Get token end line number.
    static String
    Get token literal value.
    static int
    Deprecated. 
    static char[]
    GetSuffix(int len)
    Get the suffix.
    static char
    Read a character.
    void
    Reinitializes the SimpleCharStream with the specified input stream, using default values for the starting line (1), starting column (1), buffer size (4096), and character encoding.
    void
    ReInit(InputStream dstream, int startline, int startcolumn)
    Reinitializes the SimpleCharStream with the specified input stream, starting line, and starting column, using default values for the buffer size (4096) and character encoding.
    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, using the default character encoding.
    void
    ReInit(InputStream dstream, String encoding)
    Reinitializes the SimpleCharStream
    void
    ReInit(InputStream dstream, String encoding, int startline, int startcolumn)
    Reinitializes the SimpleCharStream with the specified input stream, character encoding, starting line, and starting column, using a default buffer size of 4096.
    void
    ReInit(InputStream dstream, String encoding, int startline, int startcolumn, int buffersize)
    Reinitializes the SimpleCharStream with the specified input stream, character encoding, starting line, starting column, and buffer size.
    void
    ReInit(Reader dstream)
    Reinitializes the SimpleCharStream instance with a new Reader, using default values for the starting line, starting column, and buffer size.
    void
    ReInit(Reader dstream, int startline, int startcolumn)
    Reinitializes the SimpleCharStream instance with a new Reader, starting line, and starting column, using a default buffer size of 4096.
    void
    ReInit(Reader dstream, int startline, int startcolumn, int buffersize)
    Reinitializes the SimpleCharStream instance with a new 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 static int bufpos
      Position in buffer.
  • Constructor Details

    • SimpleCharStream

      public SimpleCharStream(Reader dstream, int startline, int startcolumn, int buffersize)
      Constructs a new SimpleCharStream instance with the specified input stream, start line, start column, and buffer size.

      This constructor initializes the character stream with the provided Reader and sets up the internal buffer and tracking information based on the given parameters. If the inputStream is already initialized, it throws an Error indicating that the constructor should not be called again. This behavior is intended to prevent multiple initializations of a static instance of SimpleCharStream.

      Parameters:
      dstream - The Reader from which characters will be read.
      startline - The line number where reading starts (1-based index).
      startcolumn - The column number where reading starts (1-based index).
      buffersize - The size of the buffer to use for reading characters.
      Throws:
      Error - If this constructor is called more than once, indicating a misuse of the static instance.
    • SimpleCharStream

      public SimpleCharStream(Reader dstream, int startline, int startcolumn)
      Constructs a new SimpleCharStream instance with the specified input stream, start line, and start column, using a default buffer size of 4096.
      Parameters:
      dstream - The Reader from which characters will be read.
      startline - The line number where reading starts (1-based index).
      startcolumn - The column number where reading starts (1-based index).
    • SimpleCharStream

      public SimpleCharStream(Reader dstream)
      Constructs a new SimpleCharStream instance with the specified input stream, using default values for the start line, start column, and buffer size.
      Parameters:
      dstream - The Reader from which characters will be read.
    • SimpleCharStream

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

      public SimpleCharStream(InputStream dstream, int startline, int startcolumn, int buffersize)
      Constructs a new SimpleCharStream instance with the specified input stream, starting line, starting column, and buffer size, using the default character encoding.
      Parameters:
      dstream - The InputStream from which characters will be read.
      startline - The line number where reading starts (1-based index).
      startcolumn - The column number where reading starts (1-based index).
      buffersize - The size of the buffer to use for reading characters.
    • SimpleCharStream

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

      public SimpleCharStream(InputStream dstream, int startline, int startcolumn)
      Constructs a new SimpleCharStream instance with the specified input stream, starting line, and starting column, using a default buffer size of 4096 and the default character encoding.
      Parameters:
      dstream - The InputStream from which characters will be read.
      startline - The line number where reading starts (1-based index).
      startcolumn - The column number where reading starts (1-based index).
    • SimpleCharStream

      public SimpleCharStream(InputStream dstream, String encoding) throws UnsupportedEncodingException
      Constructs a new SimpleCharStream instance with the specified input stream and character encoding, using default values for the starting line, starting column, and buffer size.
      Parameters:
      dstream - The InputStream from which characters will be read.
      encoding - The character encoding to use. If null, the default encoding will be used.
      Throws:
      UnsupportedEncodingException - If the specified encoding is not supported.
    • SimpleCharStream

      public SimpleCharStream(InputStream dstream)
      Constructs a new SimpleCharStream instance with the specified input stream, using default values for the starting line, starting column, buffer size, and character encoding.
      Parameters:
      dstream - The InputStream from which characters will be read.
  • Method Details

    • BeginToken

      public static char BeginToken() throws IOException
      Start.
      Returns:
      chars
      Throws:
      IOException - error
    • readChar

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

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

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

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

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

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

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

      public static void backup(int amount)
      Backup a number of characters.
      Parameters:
      amount - the amount
    • ReInit

      public void ReInit(Reader dstream, int startline, int startcolumn, int buffersize)
      Reinitializes the SimpleCharStream instance with a new Reader, starting line, starting column, and buffer size. This method clears the existing buffer and sets up a new buffer if necessary.

      This method updates the internal state of the character stream to reflect the new input stream and reinitializes the buffer and tracking variables. If the buffer size changes, a new buffer is allocated. This method should be used when you need to reuse the same SimpleCharStream instance with different input or buffer settings.

      Parameters:
      dstream - The new Reader from which characters will be read.
      startline - The line number where reading starts (1-based index).
      startcolumn - The column number where reading starts (1-based index).
      buffersize - The size of the buffer to use for reading characters.
    • ReInit

      public void ReInit(Reader dstream, int startline, int startcolumn)
      Reinitializes the SimpleCharStream instance with a new Reader, starting line, and starting column, using a default buffer size of 4096.
      Parameters:
      dstream - The new Reader from which characters will be read.
      startline - The line number where reading starts (1-based index).
      startcolumn - The column number where reading starts (1-based index).
    • ReInit

      public void ReInit(Reader dstream)
      Reinitializes the SimpleCharStream instance with a new Reader, using default values for the starting line, starting column, and buffer size.
      Parameters:
      dstream - The new Reader from which characters will be 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, character encoding, starting line, starting column, and buffer size.
      Parameters:
      dstream - The InputStream from which characters will be read.
      encoding - The character encoding to use. If null, the default encoding will be used.
      startline - The line number where reading starts (1-based index).
      startcolumn - The column number where reading starts (1-based index).
      buffersize - The size of the buffer to use for reading characters.
      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, using the default character encoding.
      Parameters:
      dstream - The InputStream from which characters will be read.
      startline - The line number where reading starts (1-based index).
      startcolumn - The column number where reading starts (1-based index).
      buffersize - The size of the buffer to use for reading characters.
    • ReInit

      public void ReInit(InputStream dstream, String encoding) throws UnsupportedEncodingException
      Reinitializes the SimpleCharStream
      Parameters:
      dstream - The InputStream from which characters will be read.
      encoding - The character encoding to use. If null, the default encoding will be used.
      Throws:
      UnsupportedEncodingException - If the specified encoding is not supported.
    • ReInit

      public void ReInit(InputStream dstream)
      Reinitializes the SimpleCharStream with the specified input stream, using default values for the starting line (1), starting column (1), buffer size (4096), and character encoding.
      Parameters:
      dstream - The InputStream from which characters will be read.
    • ReInit

      public void ReInit(InputStream dstream, String encoding, int startline, int startcolumn) throws UnsupportedEncodingException
      Reinitializes the SimpleCharStream with the specified input stream, character encoding, starting line, and starting column, using a default buffer size of 4096.
      Parameters:
      dstream - The InputStream from which characters will be read.
      encoding - The character encoding to use. If null, the default encoding will be used.
      startline - The line number where reading starts (1-based index).
      startcolumn - The column number where reading starts (1-based index).
      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, using default values for the buffer size (4096) and character encoding.
      Parameters:
      dstream - The InputStream from which characters will be read.
      startline - The line number where reading starts (1-based index).
      startcolumn - The column number where reading starts (1-based index).
    • GetImage

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

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

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

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