com.pega.pegarules.pub.runtime
Interface ParseState


public interface ParseState

The 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.

Version:
$Revision: 31 $ $Date: 2009-06-24 09:38:04 -0400 (Wed, 24 Jun 2009) $
Author:
David Burns

Field Summary
static java.lang.String COPYRIGHT
           
static java.lang.String VERSION
           
 
Method Summary
 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.
 

Field Detail

COPYRIGHT

static final java.lang.String COPYRIGHT
See Also:
Constant Field Values

VERSION

static final java.lang.String VERSION
See Also:
Constant Field Values
Method Detail

isByteStream

boolean isByteStream()
Is the active input stream a byte stream (InputStream).

Returns:
true when InputStream is in use, false otherwise.

isCharacterStream

boolean isCharacterStream()
Is the active input stream a character stream (Reader).

Returns:
true when Reader is in use, false otherwise.

getInputStream

java.io.InputStream getInputStream()
Get the InputStream object.

Returns:
Returns the InputStream object.

getReader

java.io.Reader getReader()
Get the Reader object.

Returns:
Return the Reader object.

getCharacterEncoding

java.lang.String getCharacterEncoding()
Get the current character encoding.

Returns:
the current character encoding.

setCharacterEncoding

void setCharacterEncoding(java.lang.String value)
Set the character encoding used to translate from the input stream to java string.

Any valid supported java character encoding. Character encoding is used to do translations when reading from the byte stream.

Parameters:
value - The new value for character encoding.

getLastToken

java.lang.String getLastToken()
Get the last token.

Last token can be set explicitly using setLastToken(String). Token is also set when using the "get" methods such as parseBytesText(long,int).

Returns:
String representation of last token.

setLastToken

void setLastToken(java.lang.String value)
Set the last token.

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.

Parameters:
value - The new value for last token.


getStreamOffset

long getStreamOffset()
Get the current offset of the input stream.

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.

Returns:
the current stream position.

isEndOfStream

boolean isEndOfStream()
Get the "end of stream" flag.

The end of stream flag is set when a "parse" method hits the end of stream.

Returns:
the current stream position.

parseFixedBinary

java.lang.String parseFixedBinary(int byteCount,
                                  boolean littleEndian)
Read the next token from the input stream as fixed binary data.

The bytes are converted from fixed binary to string using the endian encoding passed as a parameter. The result is stored in lastToken.

Parameters:
byteCount - the size of the binary data in bytes.
littleEndian - true if the data is little endian encoded, false otherwise.
Returns:
The new value of lastToken.

parsePackedDecimal

java.lang.String parsePackedDecimal(int digits,
                                    int decimals)
Read the next token from the input stream as packed decimal data.

The bytes are converted from packed decimal to string. The result is stored in lastToken.

Parameters:
digits - the number of digits encoded in the data.
decimals - the number of implied decimals in the data.
Returns:
The new value of lastToken.

parseBytesText

java.lang.String parseBytesText(long offset,
                                int length)
Read the next token from the input stream as text.

The bytes are converted to string. The result is stored in lastToken.

Parameters:
offset - number of bytes to skip on the byte stream
length - number of bytes to read from the input stream
Returns:
The new value of lastToken.

parseBytesRaw

byte[] parseBytesRaw(long offset,
                     int length)
Read raw data from the input stream as text.

Note: The last token value is set to null after this call.

Parameters:
offset - number of bytes to skip on the byte stream
length - number of bytes to read from the input stream
Returns:
the raw bytes read from the input stream

parseCharsText

java.lang.String parseCharsText(long offset,
                                int length)
Read the next token from the reader as text.

The chars are converted to string. The result is stored in lastToken.

Parameters:
offset - number of chars to skip on the character stream
length - number of chars to read from the character stream
Returns:
The new value of lastToken.

skipBytes

long skipBytes(long count)
               throws java.io.IOException
Advance the input stream by count bytes.

Parameters:
count - the number of bytes to advance stream.
Returns:
actual number of bytes skipped.
Throws:
java.io.IOException

skipCharacters

long skipCharacters(long count)
                    throws java.io.IOException
Advance the stream reader by count characters.

Parameters:
count - the number of chars to advance stream.
Returns:
actual number of characters skipped.
Throws:
java.io.IOException


Copyright © 2012 Pegasystems Inc. All Rights Reserved.