Class SimpleCharStream
java.lang.Object
org.tweetyproject.arg.delp.parser.SimpleCharStream
An implementation of interface CharStream, where the stream is assumed to
contain only ASCII characters (without unicode processing).
-
Field Summary
Modifier and TypeFieldDescriptionint
Position in buffer.static final boolean
Whether parser is static. -
Constructor Summary
ConstructorDescriptionSimpleCharStream
(InputStream dstream) Constructs aSimpleCharStream
with the specified input stream.SimpleCharStream
(InputStream dstream, int startline, int startcolumn) Constructs aSimpleCharStream
with the specified input stream, starting line, and starting column.SimpleCharStream
(InputStream dstream, int startline, int startcolumn, int buffersize) Constructs aSimpleCharStream
with the specified input stream, starting line, starting column, and buffer size.SimpleCharStream
(InputStream dstream, String encoding) Constructs aSimpleCharStream
with the specified input stream and encoding.SimpleCharStream
(InputStream dstream, String encoding, int startline, int startcolumn) Constructs aSimpleCharStream
with the specified input stream, encoding, starting line, and starting column.SimpleCharStream
(InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) Constructs aSimpleCharStream
with the specified input stream, encoding, starting line, starting column, and buffer size.SimpleCharStream
(Reader dstream) Constructs aSimpleCharStream
with the specified reader.SimpleCharStream
(Reader dstream, int startline, int startcolumn) Constructs aSimpleCharStream
with the specified reader, starting line, and starting column.SimpleCharStream
(Reader dstream, int startline, int startcolumn, int buffersize) Constructs aSimpleCharStream
with the specified reader, starting line, starting column, and buffer size. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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
Done()
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.GetImage()
Get token literal value.int
getLine()
Deprecated.char[]
GetSuffix
(int len) Get the suffix.char
readChar()
Read a character.void
ReInit
(InputStream dstream) Reinitializes theSimpleCharStream
with the specified input stream.void
ReInit
(InputStream dstream, int startline, int startcolumn) Reinitializes theSimpleCharStream
with the specified input stream, starting line, and starting column.void
ReInit
(InputStream dstream, int startline, int startcolumn, int buffersize) Reinitializes theSimpleCharStream
with the specified input stream, starting line, starting column, and buffer size.void
ReInit
(InputStream dstream, String encoding) Reinitializes theSimpleCharStream
with the specified input stream and encoding.void
ReInit
(InputStream dstream, String encoding, int startline, int startcolumn) Reinitializes theSimpleCharStream
with the specified input stream, encoding, starting line, and starting column.void
ReInit
(InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) Reinitializes theSimpleCharStream
with the specified input stream, encoding, starting line, starting column, and buffer size.void
Reinitializes theSimpleCharStream
with the specified reader.void
Reinitializes theSimpleCharStream
with the specified reader, starting line, and starting column.void
Reinitializes theSimpleCharStream
with the specified reader, starting line, starting column, and buffer size.
-
Field Details
-
staticFlag
public static final boolean staticFlagWhether parser is static.- See Also:
-
bufpos
public int bufposPosition in buffer.
-
-
Constructor Details
-
SimpleCharStream
Constructs aSimpleCharStream
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
Constructs aSimpleCharStream
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
Constructs aSimpleCharStream
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 aSimpleCharStream
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
Constructs aSimpleCharStream
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 aSimpleCharStream
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
Constructs aSimpleCharStream
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
Constructs aSimpleCharStream
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
Constructs aSimpleCharStream
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
Start.- Returns:
- the begin token
- Throws:
IOException
- error
-
readChar
Read a character.- Returns:
- a char
- Throws:
IOException
- error
-
getColumn
-
getLine
-
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
Reinitializes theSimpleCharStream
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
Reinitializes theSimpleCharStream
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
Reinitializes theSimpleCharStream
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 theSimpleCharStream
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. Ifnull
, 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
Reinitializes theSimpleCharStream
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
Reinitializes theSimpleCharStream
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
Reinitializes theSimpleCharStream
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 theSimpleCharStream
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
Reinitializes theSimpleCharStream
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
-
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
- linenewCol
- col
-