Package org.tweetyproject.lp.asp.parser
Class SimpleCharStream
java.lang.Object
org.tweetyproject.lp.asp.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, character encoding, and a default buffer size of 4096 characters.SimpleCharStream(InputStream dstream, String encoding, int startline, int startcolumn) Constructs aSimpleCharStreamwith the specified input stream, character encoding, starting line, and starting column.SimpleCharStream(InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) Constructs aSimpleCharStreamwith the specified input stream, character encoding, starting line, starting column, and buffer size.SimpleCharStream(Reader dstream) Constructs aSimpleCharStreamwith the specified input reader.SimpleCharStream(Reader dstream, int startline, int startcolumn) Constructs aSimpleCharStreamwith the specified input reader, starting line, and starting column.SimpleCharStream(Reader dstream, int startline, int startcolumn, int buffersize) Constructs aSimpleCharStreamwith the specified input 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) backup by amountcharReturn beginvoidDone()Reset buffer when finished.intGet token beginning column numberintGet token beginning line numberintDeprecated.intGet token end column numberintGet token end line numberGetImage()Get token literal value.intgetLine()Deprecated.char[]GetSuffix(int len) Get the suffix.charreadChar()Read a charactervoidReInit(InputStream dstream) Reinitializes the character stream with the specified input stream.voidReInit(InputStream dstream, int startline, int startcolumn) Reinitializes the character stream with the specified input stream, starting line, and starting column.voidReInit(InputStream dstream, int startline, int startcolumn, int buffersize) Reinitializes the character stream with the specified input stream, starting line, starting column, and buffer size.voidReInit(InputStream dstream, String encoding) Reinitializes the character stream with the specified input stream and character encoding.voidReInit(InputStream dstream, String encoding, int startline, int startcolumn) Reinitializes the character stream with the specified input stream, character encoding, starting line, and starting column.voidReInit(InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) Reinitializes the character stream with the specified input stream, character encoding, starting line, starting column, and buffer size.voidReinitializes thisSimpleCharStreamwith a new input reader.voidReinitializes thisSimpleCharStreamwith a new input reader, starting line, and starting column.voidReinitializes thisSimpleCharStreamwith a new input 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 input reader, starting line, starting column, and buffer size.- Parameters:
dstream- TheReaderto read character data from.startline- The line number to start reading from (1-based).startcolumn- The column number to start reading from (1-based).buffersize- The size of the buffer used to read characters.
-
SimpleCharStream
Constructs aSimpleCharStreamwith the specified input reader, starting line, and starting column. The buffer size is set to 4096 characters by default.- Parameters:
dstream- TheReaderto read character data from.startline- The line number to start reading from (1-based).startcolumn- The column number to start reading from (1-based).
-
SimpleCharStream
Constructs aSimpleCharStreamwith the specified input reader. The starting line and column are set to 1, and the buffer size is set to 4096 characters by default.- Parameters:
dstream- TheReaderto read character data from.
-
SimpleCharStream
public SimpleCharStream(InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) throws UnsupportedEncodingException Constructs aSimpleCharStreamwith the specified input stream, character encoding, starting line, starting column, and buffer size.- Parameters:
dstream- TheInputStreamto read character data from.encoding- The character encoding to use. Ifnull, the default encoding is used.startline- The line number to start reading from (1-based).startcolumn- The column number to start reading from (1-based).buffersize- The size of the buffer used to read characters.- Throws:
UnsupportedEncodingException- If the specified encoding is not supported.
-
SimpleCharStream
Constructs aSimpleCharStreamwith the specified input stream, starting line, starting column, and buffer size. The character encoding is set to the platform's default.- Parameters:
dstream- TheInputStreamto read character data from.startline- The line number to start reading from (1-based).startcolumn- The column number to start reading from (1-based).buffersize- The size of the buffer used to read characters.
-
SimpleCharStream
Constructs aSimpleCharStreamwith the specified input stream, starting line, and starting column. The buffer size is set to 4096 characters by default. The character encoding is set to the platform's default.- Parameters:
dstream- TheInputStreamto read character data from.startline- The line number to start reading from (1-based).startcolumn- The column number to start reading from (1-based).
-
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 by default. The character encoding is set to the platform's default.- Parameters:
dstream- TheInputStreamto read character data from.
-
SimpleCharStream
public SimpleCharStream(InputStream dstream, String encoding, int startline, int startcolumn) throws UnsupportedEncodingException Constructs aSimpleCharStreamwith the specified input stream, character encoding, starting line, and starting column. The buffer size is set to 4096 characters by default.- Parameters:
dstream- TheInputStreamto read character data from.encoding- The character encoding to use. Ifnull, the default encoding is used.startline- The line number to start reading from (1-based).startcolumn- The column number to start reading from (1-based).- Throws:
UnsupportedEncodingException- If the specified encoding is not supported.
-
SimpleCharStream
Constructs aSimpleCharStreamwith the specified input stream, character encoding, and a default buffer size of 4096 characters. The starting line and column are set to 1.- Parameters:
dstream- TheInputStreamto read character data from.encoding- The character encoding to use. Ifnull, the default encoding is used.- Throws:
UnsupportedEncodingException- If the specified encoding is not supported.
-
-
Method Details
-
BeginToken
Return begin- Returns:
- a char
- Throws:
IOException- error
-
readChar
Read a character- Returns:
- a character
- Throws:
IOException- error
-
getColumn
-
getLine
-
getEndColumn
public int getEndColumn()Get token end column number- Returns:
- token end column number
-
getEndLine
public int getEndLine()Get token end line number- Returns:
- token end line number
-
getBeginColumn
public int getBeginColumn()Get token beginning column number- Returns:
- Get token beginning column number
-
getBeginLine
public int getBeginLine()Get token beginning line number- Returns:
- Get token beginning line number
-
backup
public void backup(int amount) backup by amount- Parameters:
amount- the amount
-
ReInit
Reinitializes thisSimpleCharStreamwith a new input reader, starting line, starting column, and buffer size.- Parameters:
dstream- TheReaderto read character data from.startline- The line number to start reading from (1-based).startcolumn- The column number to start reading from (1-based).buffersize- The size of the buffer used to read characters.
-
ReInit
Reinitializes thisSimpleCharStreamwith a new input reader, starting line, and starting column. The buffer size is set to 4096 characters by default.- Parameters:
dstream- TheReaderto read character data from.startline- The line number to start reading from (1-based).startcolumn- The column number to start reading from (1-based).
-
ReInit
Reinitializes thisSimpleCharStreamwith a new input reader. The starting line and column are set to 1, and the buffer size is set to 4096 characters by default.- Parameters:
dstream- TheReaderto read character data from.
-
ReInit
public void ReInit(InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) throws UnsupportedEncodingException Reinitializes the character stream with the specified input stream, character encoding, starting line, starting column, and buffer size.- Parameters:
dstream- TheInputStreamto read character data from.encoding- The character encoding to use. Ifnull, the default encoding is used.startline- The line number to start reading from (1-based).startcolumn- The column number to start reading from (1-based).buffersize- The size of the buffer used to read characters.- Throws:
UnsupportedEncodingException- If the specified encoding is not supported.
-
ReInit
Reinitializes the character stream with the specified input stream, starting line, starting column, and buffer size. The character encoding is set to the platform's default.- Parameters:
dstream- TheInputStreamto read character data from.startline- The line number to start reading from (1-based).startcolumn- The column number to start reading from (1-based).buffersize- The size of the buffer used to read characters.
-
ReInit
Reinitializes the character stream with the specified input stream and character encoding. The starting line and column are set to 1, and the buffer size is set to 4096 characters by default.- Parameters:
dstream- TheInputStreamto read character data from.encoding- The character encoding to use. Ifnull, the default encoding is used.- Throws:
UnsupportedEncodingException- If the specified encoding is not supported.
-
ReInit
Reinitializes the character stream with the specified input stream. The starting line and column are set to 1, and the buffer size is set to 4096 characters by default. The character encoding is set to the platform's default.- Parameters:
dstream- TheInputStreamto read character data from.
-
ReInit
public void ReInit(InputStream dstream, String encoding, int startline, int startcolumn) throws UnsupportedEncodingException Reinitializes the character stream with the specified input stream, character encoding, starting line, and starting column. The buffer size is set to 4096 characters by default.- Parameters:
dstream- TheInputStreamto read character data from.encoding- The character encoding to use. Ifnull, the default encoding is used.startline- The line number to start reading from (1-based).startcolumn- The column number to start reading from (1-based).- Throws:
UnsupportedEncodingException- If the specified encoding is not supported.
-
ReInit
Reinitializes the character stream with the specified input stream, starting line, and starting column. The buffer size is set to 4096 characters by default and the character encoding is set to the platform's default.- Parameters:
dstream- TheInputStreamto read character data from.startline- The line number to start reading from (1-based).startcolumn- The column number to start reading from (1-based).
-
GetImage
-
GetSuffix
public char[] GetSuffix(int len) Get the suffix.- Parameters:
len- length- Returns:
- char
-
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- new linenewCol- the column
-