public interface ParseState
ParseState
interface defines access to parse rule
runtime information. It is used in the "Parse-*" Rule-Obj-Method
generated java and is also available to Java steps using the
PublicApi method PublicAPI.getParseState(InputStream)
.
We want to force stream reads to come through this interface. This
will allow us to track the offset in the stream as well as flag the
end of stream.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
COPYRIGHT |
static java.lang.String |
VERSION |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getCharacterEncoding()
Get the current character encoding.
|
java.io.InputStream |
getInputStream()
Get the InputStream object.
|
java.lang.String |
getLastToken()
Get the last token.
|
java.io.Reader |
getReader()
Get the Reader object.
|
long |
getStreamOffset()
Get the current offset of the input stream.
|
boolean |
isByteStream()
Is the active input stream a byte stream (InputStream).
|
boolean |
isCharacterStream()
Is the active input stream a character stream (Reader).
|
boolean |
isEndOfStream()
Get the "end of stream" flag.
|
byte[] |
parseBytesRaw(long offset,
int length)
Read raw data from the input stream as text.
|
java.lang.String |
parseBytesText(long offset,
int length)
Read the next token from the input stream as text.
|
java.lang.String |
parseCharsText(long offset,
int length)
Read the next token from the reader as text.
|
java.lang.String |
parseFixedBinary(int byteCount,
boolean littleEndian)
Read the next token from the input stream as fixed binary data.
|
java.lang.String |
parsePackedDecimal(int digits,
int decimals)
Read the next token from the input stream as packed decimal data.
|
void |
setCharacterEncoding(java.lang.String value)
Set the character encoding used to translate from the input stream to java string.
|
void |
setLastToken(java.lang.String value)
Set the last token.
|
long |
skipBytes(long count)
Advance the input stream by
count bytes. |
long |
skipCharacters(long count)
Advance the stream reader by
count characters. |
static final java.lang.String VERSION
static final java.lang.String COPYRIGHT
boolean isByteStream()
InputStream
is in use, false otherwise.boolean isCharacterStream()
Reader
is in use, false otherwise.java.io.InputStream getInputStream()
java.io.Reader getReader()
java.lang.String getCharacterEncoding()
void setCharacterEncoding(java.lang.String value)
Any valid supported java character encoding. Character encoding is used to do translations when reading from the byte stream.
value
- The new value for character encoding.java.lang.String getLastToken()
Last token can be set explicitly using setLastToken(String)
. Token is
also set when using the "get" methods such as parseBytesText(long,int)
.
void setLastToken(java.lang.String value)
This method is usful for data that needs data convertion. For example dates may be required in different formats. LastToken will hold the raw date and be modified in a subsequent step.
value
- The new value for last token.long getStreamOffset()
The stream offset units is mode independent. If the byte stream is active, then position is kept in bytes. If the character stream is active then position is kept in charaters.
boolean isEndOfStream()
The end of stream flag is set when a "parse" method hits the end of stream.
java.lang.String parseFixedBinary(int byteCount, boolean littleEndian)
The bytes are converted from fixed binary to string using the endian encoding passed as a parameter. The result is stored in lastToken.
byteCount
- the size of the binary data in bytes.littleEndian
- true if the data is little endian encoded, false otherwise.java.lang.String parsePackedDecimal(int digits, int decimals)
The bytes are converted from packed decimal to string. The result is stored in lastToken.
digits
- the number of digits encoded in the data.decimals
- the number of implied decimals in the data.java.lang.String parseBytesText(long offset, int length)
The bytes are converted to string. The result is stored in lastToken.
offset
- number of bytes to skip on the byte streamlength
- number of bytes to read from the input streambyte[] parseBytesRaw(long offset, int length)
Note: The last token value is set to null after this call.
offset
- number of bytes to skip on the byte streamlength
- number of bytes to read from the input streamjava.lang.String parseCharsText(long offset, int length)
The chars are converted to string. The result is stored in lastToken.
offset
- number of chars to skip on the character streamlength
- number of chars to read from the character streamlong skipBytes(long count) throws java.io.IOException
count
bytes.count
- the number of bytes to advance stream.java.io.IOException
long skipCharacters(long count) throws java.io.IOException
count
characters.count
- the number of chars to advance stream.java.io.IOException
Copyright © 2018 Pegasystems Inc. All Rights Reserved.