public class BufferedSegmentReader extends Object
Modifier and Type | Field and Description |
---|---|
static String |
IGNORE_CR_LF |
Constructor and Description |
---|
BufferedSegmentReader(InputSource ediInputSource,
Delimiters rootDelimiters)
Construct the stream reader.
|
Modifier and Type | Method and Description |
---|---|
Charset |
changeEncoding(Charset encoding)
Change the encoding used to read the underlying EDI data stream.
|
String[] |
getCurrentSegmentFields()
Get the current EDI segment fields.
|
int |
getCurrentSegmentNumber()
Get the current segment "number".
|
Delimiters |
getDelimiters()
Get the current delimiter set.
|
Stack<Delimiters> |
getDelimitersStack()
Get the
|
StringBuffer |
getSegmentBuffer()
Get the segment buffer.
|
boolean |
hasCurrentSegment()
Does the read have a segment buffered and ready for processing.
|
void |
mark()
Try mark the stream so we can support changing of the reader encoding.
|
boolean |
moveToNextSegment()
Move to the next EDI segment.
|
boolean |
moveToNextSegment(boolean clearBuffer)
Move to the next EDI segment.
|
String |
peek(int numChars)
Peek a fixed number of characters from the input source.
|
String |
peek(int numChars,
boolean ignoreLeadingWhitespace)
Peek a fixed number of characters from the input source.
|
void |
popDelimiters()
Restore the parent delimiters set.
|
void |
pushDelimiters(Delimiters delimiters)
Push in a new
Delimiters set into the reader. |
String |
read(int numChars)
Read a fixed number of characters from the input source.
|
void |
setIgnoreNewLines(boolean ignoreNewLines)
Set ignore new lines in the EDI Stream.
|
void |
setSegmentListener(BufferedSegmentListener segmentListener)
Set the segment listener.
|
public static String IGNORE_CR_LF
public BufferedSegmentReader(InputSource ediInputSource, Delimiters rootDelimiters)
ediInputSource
- EDI Stream input source.rootDelimiters
- Root currentDelimiters. New currentDelimiters can be pushed and popped.public void mark()
changeEncoding(Charset)
public Charset changeEncoding(Charset encoding) throws IOException
mark()
should have been called first.encoding
- The new encoding.IOException
- Failed to skip already read characters.public Delimiters getDelimiters()
public void pushDelimiters(Delimiters delimiters)
Delimiters
set into the reader.delimiters
- New delimiters.public void popDelimiters()
get the delimiters stack
and check
that it is not empty before popping.public Stack<Delimiters> getDelimitersStack()
public void setIgnoreNewLines(boolean ignoreNewLines)
ignoreNewLines
- True if new line characters should be ignored, otherwise false.public String read(int numChars) throws IOException
numChars
- The number of characters to read.IOException
- Error reading from input source.public String peek(int numChars) throws IOException
read(int)
in that it leaves the
characters in the segment buffer.numChars
- The number of characters to peeked.IOException
- Error reading from input source.public String peek(int numChars, boolean ignoreLeadingWhitespace) throws IOException
read(int)
in that it leaves the
characters in the segment buffer.numChars
- The number of characters to peeked.ignoreLeadingWhitespace
- Ignore leading whitespace.IOException
- Error reading from input source.public void setSegmentListener(BufferedSegmentListener segmentListener)
segmentListener
- The segment listener.public boolean moveToNextSegment() throws IOException
IOException
- Error reading from EDI stream.public boolean moveToNextSegment(boolean clearBuffer) throws IOException
clearBuffer
- Clear the segment buffer before reading.IOException
- Error reading from EDI stream.public boolean hasCurrentSegment()
public StringBuffer getSegmentBuffer()
public String[] getCurrentSegmentFields() throws IllegalStateException
IllegalStateException
- No current Segment.public int getCurrentSegmentNumber()
Copyright © 2020. All rights reserved.