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
FieldsModifier and TypeFieldDescriptionintPosition in buffer.static final booleanWhether parser is static. -
Constructor Summary
ConstructorsConstructorDescriptionSimpleCharStream(InputStream dstream) Constructs aSimpleCharStreamwith the specified input stream.SimpleCharStream(InputStream dstream, int startline, int startcolumn) Constructs aSimpleCharStreamwith the specified input stream, starting line, and starting column.SimpleCharStream(InputStream dstream, int startline, int startcolumn, int buffersize) Constructs aSimpleCharStreamwith the specified input stream, starting line, starting column, and buffer size.SimpleCharStream(InputStream dstream, String encoding) Constructs aSimpleCharStreamwith the specified input stream and encoding.SimpleCharStream(InputStream dstream, String encoding, int startline, int startcolumn) Constructs aSimpleCharStreamwith the specified input stream, encoding, starting line, and starting column.SimpleCharStream(InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) Constructs aSimpleCharStreamwith the specified input stream, encoding, starting line, starting column, and buffer size.SimpleCharStream(Reader dstream) Constructs aSimpleCharStreamwith the specified reader.SimpleCharStream(Reader dstream, int startline, int startcolumn) Constructs aSimpleCharStreamwith the specified reader, starting line, and starting column.SimpleCharStream(Reader dstream, int startline, int startcolumn, int buffersize) Constructs aSimpleCharStreamwith the specified reader, starting line, starting column, and buffer size. -
Method Summary
Modifier and TypeMethodDescriptionvoidadjustBeginLineColumn(int newLine, int newCol) Method to adjust line and column numbers for the start of a token.voidbackup(int amount) Rewinds the input stream by a specified number of characters.charStart.voidDone()Reset buffer when finished.intRetrieves the column number where the current token begins.intRetrieves the line number where the current token begins.intDeprecated.intGet token end column number.intGet token end line number.GetImage()Get token literal value.intgetLine()Deprecated.char[]GetSuffix(int len) Get the suffix.charreadChar()Read a character.voidReInit(InputStream dstream) Reinitializes theSimpleCharStreamwith the specified input stream.voidReInit(InputStream dstream, int startline, int startcolumn) Reinitializes theSimpleCharStreamwith the specified input stream, starting line, and starting column.voidReInit(InputStream dstream, int startline, int startcolumn, int buffersize) Reinitializes theSimpleCharStreamwith the specified input stream, starting line, starting column, and buffer size.voidReInit(InputStream dstream, String encoding) Reinitializes theSimpleCharStreamwith the specified input stream and encoding.voidReInit(InputStream dstream, String encoding, int startline, int startcolumn) Reinitializes theSimpleCharStreamwith the specified input stream, encoding, starting line, and starting column.voidReInit(InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) Reinitializes theSimpleCharStreamwith the specified input stream, encoding, starting line, starting column, and buffer size.voidReinitializes theSimpleCharStreamwith the specified reader.voidReinitializes theSimpleCharStreamwith the specified reader, starting line, and starting column.voidReinitializes theSimpleCharStreamwith 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 aSimpleCharStreamwith 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 aSimpleCharStreamwith 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 aSimpleCharStreamwith 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 aSimpleCharStreamwith 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 aSimpleCharStreamwith 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 aSimpleCharStreamwith 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 aSimpleCharStreamwith 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 aSimpleCharStreamwith 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 aSimpleCharStreamwith 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 theSimpleCharStreamwith 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 theSimpleCharStreamwith 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 theSimpleCharStreamwith 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 theSimpleCharStreamwith 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 theSimpleCharStreamwith 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 theSimpleCharStreamwith 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 theSimpleCharStreamwith 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 theSimpleCharStreamwith 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 theSimpleCharStreamwith 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
-