|
Sun Adapter for Batch/FTP | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.stc.eways.batchext.InputStreamFindAdapter
public class InputStreamFindAdapter
This class is a shim to the java.io.InputStream interface. Constructor takes the InputStream and then this class provides similar methods as the InputStream plus a few more to make dealing with the stream in the record parser a bit easier. Where practical, the method names from the InputStream interface are used and, if so, the semantics are the same as the InputStream interface. Important: To provide for the ability to "peek", the InputStream that is passed to the constructor must support skipping backwards. The java.io.FileInputStream does. The ByteArrayInputStream does not. To use a ByteArrayInputStream, see the BatchByteArrayInputStream.
BatchRecordParser,
BatchByteArrayInputStream,
InputStream| Field Summary | |
|---|---|
protected boolean |
m_bDelimOnLast
|
protected java.io.InputStream |
m_is
The input stream passed to the constructor |
| Constructor Summary | |
|---|---|
InputStreamFindAdapter(java.io.InputStream is)
Constructor - pass the InputStream we are to wrap. |
|
| Method Summary | |
|---|---|
int |
available()
Get the total number of bytes that can be read. |
InputStreamFindResult |
find(byte b)
This function peeks ahead and searches for 'b' starting at the current position in the stream. |
InputStreamFindResult |
find(byte[] arr)
This function peeks ahead and searches for 'arr' starting at the current position in the stream. |
boolean |
getDelimOnLastRecord()
Gets the property which determines how the find method will interpret the delimiter for the last record. |
int |
read(byte[] buffer,
int count)
Read 'count' bytes into 'buffer' starting at current position in the InputStream. |
int |
read(byte[] buffer,
int off,
int count)
Semantically equiv to the same read method in the InputStream. |
void |
setDelimOnLastRecord(boolean bDelimOnLast)
Sets the property which determines how the find method will interpret the delimiter for the last record. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.io.InputStream m_is
protected boolean m_bDelimOnLast
| Constructor Detail |
|---|
public InputStreamFindAdapter(java.io.InputStream is)
throws java.lang.Exception
java.lang.Exception| Method Detail |
|---|
public int available()
throws java.lang.Exception
java.lang.Exception - If there is a problem determining this
or if underlying InputStream throws an exception.
public int read(byte[] buffer,
int count)
throws java.lang.Exception
buffer - The caller allocated buffer to fill with bytescount - The number of bytes to put in buffer
java.lang.Exception - If there is a problem getting the bytes.
It is an error if there are not 'count' bytes to
get from current position (i.e. try to get more
than what is available).
public int read(byte[] buffer,
int off,
int count)
throws java.lang.Exception
java.lang.Exception
public InputStreamFindResult find(byte b)
throws java.lang.Exception
b - The byte to look for.
java.lang.Exception - If there's a problem navigating the stream.public void setDelimOnLastRecord(boolean bDelimOnLast)
bDelimOnLast - Set to true if delimiter is required for the last
record; otherwise, set to false.getDelimOnLastRecord(),
find(byte)public boolean getDelimOnLastRecord()
setDelimOnLastRecord(boolean),
find(byte)
public InputStreamFindResult find(byte[] arr)
throws java.lang.Exception
arr - The byte array to look for.
java.lang.Exception - If there's a problem navigating the stream.
|
Sun Adapter for Batch/FTP | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||