Class SimpleCharStream
java.lang.Object
org.tweetyproject.logics.rpcl.parser.rpclcondensedprobabilitydistributionparser.SimpleCharStream
An implementation of interface CharStream, where the stream is assumed to
contain only ASCII characters (without unicode processing).
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic intPosition in buffer.static final booleanWhether parser is static. -
Constructor Summary
ConstructorsConstructorDescriptionSimpleCharStream(InputStream dstream) Constructs a newSimpleCharStreaminstance 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 newSimpleCharStreaminstance 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 newSimpleCharStreaminstance with the specified input stream, starting line, starting column, and buffer size, using the default character encoding.SimpleCharStream(InputStream dstream, String encoding) Constructs a newSimpleCharStreaminstance 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 newSimpleCharStreaminstance 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 newSimpleCharStreaminstance with the specified input stream, character encoding, starting line, starting column, and buffer size.SimpleCharStream(Reader dstream) Constructs a newSimpleCharStreaminstance 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 newSimpleCharStreaminstance 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 newSimpleCharStreaminstance with the specified input stream, start line, start column, and buffer size. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidadjustBeginLineColumn(int newLine, int newCol) Method to adjust line and column numbers for the start of a token.static voidbackup(int amount) Backup a number of characters.static charStart.static voidDone()Reset buffer when finished.static intGet token beginning column number.static intGet token beginning line number.static intDeprecated.static intGet token end column number.static intGet token end line number.static StringGetImage()Get token literal value.static intgetLine()Deprecated.static char[]GetSuffix(int len) Get the suffix.static charreadChar()Read a character.voidReInit(InputStream dstream) Reinitializes theSimpleCharStreamwith the specified input stream, using default values for the starting line (1), starting column (1), buffer size (4096), and character encoding.voidReInit(InputStream dstream, int startline, int startcolumn) Reinitializes theSimpleCharStreamwith the specified input stream, starting line, and starting column, using default values for the buffer size (4096) and character encoding.voidReInit(InputStream dstream, int startline, int startcolumn, int buffersize) Reinitializes theSimpleCharStreamwith the specified input stream, starting line, starting column, and buffer size, using the default character encoding.voidReInit(InputStream dstream, String encoding) Reinitializes theSimpleCharStreamvoidReInit(InputStream dstream, String encoding, int startline, int startcolumn) Reinitializes theSimpleCharStreamwith the specified input stream, character encoding, starting line, and starting column, using a default buffer size of 4096.voidReInit(InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) Reinitializes theSimpleCharStreamwith the specified input stream, character encoding, starting line, starting column, and buffer size.voidReinitializes theSimpleCharStreaminstance with a newReader, using default values for the starting line, starting column, and buffer size.voidReinitializes theSimpleCharStreaminstance with a newReader, starting line, and starting column, using a default buffer size of 4096.voidReinitializes theSimpleCharStreaminstance with a newReader, starting line, starting column, and buffer size.
-
Field Details
-
staticFlag
public static final boolean staticFlagWhether parser is static.- See Also:
-
bufpos
public static int bufposPosition in buffer.
-
-
Constructor Details
-
SimpleCharStream
Constructs a newSimpleCharStreaminstance with the specified input stream, start line, start column, and buffer size.This constructor initializes the character stream with the provided
Readerand sets up the internal buffer and tracking information based on the given parameters. If theinputStreamis already initialized, it throws anErrorindicating that the constructor should not be called again. This behavior is intended to prevent multiple initializations of a static instance ofSimpleCharStream.- Parameters:
dstream- TheReaderfrom 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
Constructs a newSimpleCharStreaminstance with the specified input stream, start line, and start column, using a default buffer size of 4096.- Parameters:
dstream- TheReaderfrom 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
Constructs a newSimpleCharStreaminstance with the specified input stream, using default values for the start line, start column, and buffer size.- Parameters:
dstream- TheReaderfrom which characters will be read.
-
SimpleCharStream
public SimpleCharStream(InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) throws UnsupportedEncodingException Constructs a newSimpleCharStreaminstance with the specified input stream, character encoding, starting line, starting column, and buffer size.- Parameters:
dstream- TheInputStreamfrom which characters will be read.encoding- The character encoding to use. Ifnull, 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
Constructs a newSimpleCharStreaminstance with the specified input stream, starting line, starting column, and buffer size, using the default character encoding.- Parameters:
dstream- TheInputStreamfrom 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 newSimpleCharStreaminstance with the specified input stream, character encoding, starting line, and starting column, using a default buffer size of 4096.- Parameters:
dstream- TheInputStreamfrom which characters will be read.encoding- The character encoding to use. Ifnull, 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
Constructs a newSimpleCharStreaminstance with the specified input stream, starting line, and starting column, using a default buffer size of 4096 and the default character encoding.- Parameters:
dstream- TheInputStreamfrom 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
Constructs a newSimpleCharStreaminstance with the specified input stream and character encoding, using default values for the starting line, starting column, and buffer size.- Parameters:
dstream- TheInputStreamfrom which characters will be read.encoding- The character encoding to use. Ifnull, the default encoding will be used.- Throws:
UnsupportedEncodingException- If the specified encoding is not supported.
-
SimpleCharStream
Constructs a newSimpleCharStreaminstance with the specified input stream, using default values for the starting line, starting column, buffer size, and character encoding.- Parameters:
dstream- TheInputStreamfrom which characters will be read.
-
-
Method Details
-
BeginToken
Start.- Returns:
- chars
- Throws:
IOException- error
-
readChar
Read a character.- Returns:
- chars
- Throws:
IOException- error
-
getColumn
-
getLine
-
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
Reinitializes theSimpleCharStreaminstance with a newReader, 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
SimpleCharStreaminstance with different input or buffer settings.- Parameters:
dstream- The newReaderfrom 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
Reinitializes theSimpleCharStreaminstance with a newReader, starting line, and starting column, using a default buffer size of 4096.- Parameters:
dstream- The newReaderfrom 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
Reinitializes theSimpleCharStreaminstance with a newReader, using default values for the starting line, starting column, and buffer size.- Parameters:
dstream- The newReaderfrom which characters will be read.
-
ReInit
public void ReInit(InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) throws UnsupportedEncodingException Reinitializes theSimpleCharStreamwith the specified input stream, character encoding, starting line, starting column, and buffer size.- Parameters:
dstream- TheInputStreamfrom which characters will be read.encoding- The character encoding to use. Ifnull, 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
Reinitializes theSimpleCharStreamwith the specified input stream, starting line, starting column, and buffer size, using the default character encoding.- Parameters:
dstream- TheInputStreamfrom 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
Reinitializes theSimpleCharStream- Parameters:
dstream- TheInputStreamfrom which characters will be read.encoding- The character encoding to use. Ifnull, the default encoding will be used.- Throws:
UnsupportedEncodingException- If the specified encoding is not supported.
-
ReInit
Reinitializes theSimpleCharStreamwith the specified input stream, using default values for the starting line (1), starting column (1), buffer size (4096), and character encoding.- Parameters:
dstream- TheInputStreamfrom which characters will be read.
-
ReInit
public void ReInit(InputStream dstream, String encoding, int startline, int startcolumn) throws UnsupportedEncodingException Reinitializes theSimpleCharStreamwith the specified input stream, character encoding, starting line, and starting column, using a default buffer size of 4096.- Parameters:
dstream- TheInputStreamfrom which characters will be read.encoding- The character encoding to use. Ifnull, 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
Reinitializes theSimpleCharStreamwith the specified input stream, starting line, and starting column, using default values for the buffer size (4096) and character encoding.- Parameters:
dstream- TheInputStreamfrom 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
-
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 linenewCol- new column
-