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
Modifier and TypeFieldDescriptionstatic int
Position in buffer.static final boolean
Whether parser is static. -
Constructor Summary
ConstructorDescriptionSimpleCharStream
(InputStream dstream) Constructs a newSimpleCharStream
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 newSimpleCharStream
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 newSimpleCharStream
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 newSimpleCharStream
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 newSimpleCharStream
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 newSimpleCharStream
instance with the specified input stream, character encoding, starting line, starting column, and buffer size.SimpleCharStream
(Reader dstream) Constructs a newSimpleCharStream
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 newSimpleCharStream
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 newSimpleCharStream
instance with the specified input stream, start line, start column, and buffer size. -
Method Summary
Modifier and TypeMethodDescriptionstatic 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
Done()
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
GetImage()
Get token literal value.static int
getLine()
Deprecated.static char[]
GetSuffix
(int len) Get the suffix.static char
readChar()
Read a character.void
ReInit
(InputStream dstream) Reinitializes theSimpleCharStream
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 theSimpleCharStream
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 theSimpleCharStream
with the specified input stream, starting line, starting column, and buffer size, using the default character encoding.void
ReInit
(InputStream dstream, String encoding) Reinitializes theSimpleCharStream
void
ReInit
(InputStream dstream, String encoding, int startline, int startcolumn) Reinitializes theSimpleCharStream
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 theSimpleCharStream
with the specified input stream, character encoding, starting line, starting column, and buffer size.void
Reinitializes theSimpleCharStream
instance with a newReader
, using default values for the starting line, starting column, and buffer size.void
Reinitializes theSimpleCharStream
instance with a newReader
, starting line, and starting column, using a default buffer size of 4096.void
Reinitializes theSimpleCharStream
instance 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 newSimpleCharStream
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 theinputStream
is already initialized, it throws anError
indicating that the constructor should not be called again. This behavior is intended to prevent multiple initializations of a static instance ofSimpleCharStream
.- Parameters:
dstream
- TheReader
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
Constructs a newSimpleCharStream
instance with the specified input stream, start line, and start column, using a default buffer size of 4096.- Parameters:
dstream
- TheReader
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
Constructs a newSimpleCharStream
instance with the specified input stream, using default values for the start line, start column, and buffer size.- Parameters:
dstream
- TheReader
from which characters will be read.
-
SimpleCharStream
public SimpleCharStream(InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) throws UnsupportedEncodingException Constructs a newSimpleCharStream
instance with the specified input stream, character encoding, starting line, starting column, and buffer size.- Parameters:
dstream
- TheInputStream
from 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 newSimpleCharStream
instance with the specified input stream, starting line, starting column, and buffer size, using the default character encoding.- Parameters:
dstream
- TheInputStream
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 newSimpleCharStream
instance with the specified input stream, character encoding, starting line, and starting column, using a default buffer size of 4096.- Parameters:
dstream
- TheInputStream
from 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 newSimpleCharStream
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
- TheInputStream
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
Constructs a newSimpleCharStream
instance with the specified input stream and character encoding, using default values for the starting line, starting column, and buffer size.- Parameters:
dstream
- TheInputStream
from 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 newSimpleCharStream
instance with the specified input stream, using default values for the starting line, starting column, buffer size, and character encoding.- Parameters:
dstream
- TheInputStream
from 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 theSimpleCharStream
instance 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
SimpleCharStream
instance with different input or buffer settings.- Parameters:
dstream
- The newReader
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
Reinitializes theSimpleCharStream
instance with a newReader
, starting line, and starting column, using a default buffer size of 4096.- Parameters:
dstream
- The newReader
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
Reinitializes theSimpleCharStream
instance with a newReader
, using default values for the starting line, starting column, and buffer size.- Parameters:
dstream
- The newReader
from which characters will be read.
-
ReInit
public void ReInit(InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) throws UnsupportedEncodingException Reinitializes theSimpleCharStream
with the specified input stream, character encoding, starting line, starting column, and buffer size.- Parameters:
dstream
- TheInputStream
from 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 theSimpleCharStream
with the specified input stream, starting line, starting column, and buffer size, using the default character encoding.- Parameters:
dstream
- TheInputStream
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
Reinitializes theSimpleCharStream
- Parameters:
dstream
- TheInputStream
from 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 theSimpleCharStream
with the specified input stream, using default values for the starting line (1), starting column (1), buffer size (4096), and character encoding.- Parameters:
dstream
- TheInputStream
from which characters will be read.
-
ReInit
public void ReInit(InputStream dstream, String encoding, int startline, int startcolumn) throws UnsupportedEncodingException Reinitializes theSimpleCharStream
with the specified input stream, character encoding, starting line, and starting column, using a default buffer size of 4096.- Parameters:
dstream
- TheInputStream
from 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 theSimpleCharStream
with the specified input stream, starting line, and starting column, using default values for the buffer size (4096) and character encoding.- Parameters:
dstream
- TheInputStream
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
-
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
-