|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--SSF.Util.Streams.BasicRecorder
BasicRecorder demonstrates how to build a simple implementation of a StreamInterface for portably emitting a stream of records.
| Constructor Summary | |
BasicRecorder(java.lang.String streamID)
|
|
| Method Summary | |
void |
addSession()
|
void |
connectRead(java.lang.String url)
Connect this stream to a data source at the given URL. |
void |
connectWrite(java.lang.String url)
Connect this stream to a data sink at the given URL. |
void |
connectWrite(java.lang.String url,
boolean append)
open files in append mode. |
void |
disconnect()
Signal that no more records are to be received (if reading) or sent (if writing). |
int |
getRecordSourceCode(java.lang.String name)
Return the integer code associated with the user-defined record source string in this record stream. |
java.lang.String |
getRecordSourceString(int id)
Return the arbitrary-length String identifying the user-defined source (writer) ID associated with a given code in this record stream. |
int |
getRecordTypeCode(java.lang.String name)
Return the integer code associated with the user-defined record type string in this record stream. |
java.lang.String |
getRecordTypeString(int id)
Return the arbitrary-length String identifying the user-defined record type associated with a given code in this record stream. |
boolean |
isConnected()
Return true if this stream has been successfully connected to a data source or sink, and not disconnected. |
int |
receive(int service,
int source,
double time,
byte[] bytes,
int off,
int len)
Process a single record in the data stream. |
int |
send(int service,
int source,
double time)
Return the same value (zero for success, nonzero for failure) that would be returned by a send with the given header information and actual payload data, assuming no IOExceptions etc. |
int |
send(int service,
int source,
double time,
byte[] bytes,
int off,
int len)
Send a single record on the data stream. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public BasicRecorder(java.lang.String streamID)
| Method Detail |
public void addSession()
public boolean isConnected()
StreamInterface
isConnected in interface StreamInterface
public void connectRead(java.lang.String url)
throws streamException
StreamInterface
connectRead in interface StreamInterfacestreamException
public void connectWrite(java.lang.String url,
boolean append)
throws streamException
streamException
public void connectWrite(java.lang.String url)
throws streamException
StreamInterface
connectWrite in interface StreamInterfacestreamExceptionpublic void disconnect()
StreamInterface
disconnect in interface StreamInterface
public int receive(int service,
int source,
double time,
byte[] bytes,
int off,
int len)
StreamInterfaceThese codes are not portable across implementations, or even across runs within the same implementation; they are used for efficiency purposes to minimize the overhead associated with constructing, sending, receiving, and interpreting Strings. Returns zero for successful receipt, non-zero for failure.
receive in interface StreamInterface
public int send(int service,
int source,
double time)
StreamInterfaceMany source-side filtering schemes will suppress sends of records that match given profiles for record types, points of origin, or intervals of time. This standard inquiry method allows a savvy sender to avoid the overhead of preparing a bufferful of bytes that will simply be ignored anyway. First test the waters with a no-payload send(), and if it returns success (zero), prepare the bytes and call the full version of send().
send in interface StreamInterface
public int send(int service,
int source,
double time,
byte[] bytes,
int off,
int len)
StreamInterfaceThese codes are not portable across implementations, or even across runs within the same implementation; they are used for efficiency purposes to minimize the overhead associated with constructing, sending, receiving, and interpreting Strings. Returns zero if a record was sent, nonzero if no record was sent (due to error, suppression due to filtering, or any other cause).
send in interface StreamInterfacepublic java.lang.String getRecordTypeString(int id)
StreamInterface
getRecordTypeString in interface StreamInterfacepublic int getRecordTypeCode(java.lang.String name)
StreamInterfaceThe code returned for an unknown name depends on the state of the stream. In a stream connected for writing, a new code is returned which henceforth will refer to that string; in a stream which is unconnected or connected for reading, the error code -1 is returned, signifying that the code is not yet known (i.e., because the stream record that might identify the code has not yet been processed).
getRecordTypeCode in interface StreamInterfacepublic java.lang.String getRecordSourceString(int id)
StreamInterface
getRecordSourceString in interface StreamInterfacepublic int getRecordSourceCode(java.lang.String name)
StreamInterface
getRecordSourceCode in interface StreamInterface
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||