|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.davisor.data.VoidData
com.davisor.data.stream.StreamDataSource
A StreamDataSource makes a reuseable data source out of a data stream that can be read only once. The data stream is therefore consumed entirely, and the data is stored in a buffer from which it can be read multiple times.
The exact moment, when the source data stream is consumed, can be controlled during the stream data source construction time. The stream can be consumed immediately at construction time, or the buffer creation can be delayed until explicitly needed. If the buffer construction is delayed, the original, unbuffered stream remains available for reading. In this case the stream can, however, be read only once.
Delayed stream buffering is useful when subclasses need to modify
the original stream content before it is buffered. The subclasses
need only override the getBuffer method, or provide
some other way to alter the stream content before it is read and
buffered.
DataBuffer,
DataStream,
Type| Field Summary | |
protected DataBuffer |
M_buffer
Data source buffer (re-readable, may initially be null). |
protected DataStream |
M_stream
Data source stream (readable only once, null when unavailable). |
| Fields inherited from class com.davisor.data.VoidData |
M_type |
| Constructor Summary | |
|
StreamDataSource(DataBuffer buffer)
Creates a stream data stream source out of the given buffer. |
|
StreamDataSource(DataStream stream)
Creates a stream data stream source out of the given stream. |
|
StreamDataSource(DataStream stream,
boolean buffer)
Creates a stream data stream source out of the given stream. |
protected |
StreamDataSource(StreamDataSource sds)
Shallow copy constructor. |
| Method Summary | |
boolean |
close()
This method frees resources for cargabe collection. |
DataBuffer |
getBuffer()
Gets the underlying data buffer. |
DataBuffer |
getBuffer(Type type)
Gets the underlying data buffer. |
DataValue |
getData(int index)
Gets the specific data element from the data buffer, if available. |
int |
getSize()
Gets the number of data elements in the data buffer, if available. |
DataStream |
getStream()
Gets a data stream from the source. |
DataStream |
getStream(boolean reversed)
Gets a new data stream from the data buffer, if available. |
boolean |
isBuffered()
Tests if the stream has been buffered. |
void |
setBuffer(DataBuffer buffer)
Sets the current data buffer. |
void |
setStream(DataStream stream)
Sets the current data stream. |
java.lang.String |
toString()
Gets the data source string representation. |
java.lang.String |
toString(java.lang.String id,
java.lang.String dataName)
See the DataSource documentation |
| Methods inherited from class com.davisor.data.VoidData |
equals, getDataValue, getType, hashCode, setType |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface com.davisor.data.Data |
getType |
| Field Detail |
protected DataBuffer M_buffer
protected DataStream M_stream
| Constructor Detail |
protected StreamDataSource(StreamDataSource sds)
throws InvalidDataException
sds - source stream data source (may be null)
InvalidDataException - if the stream contains invalid datagetBuffer()
public StreamDataSource(DataStream stream)
throws InvalidDataException
InvalidDataException - if data strem type resolvation failsgetBuffer()
public StreamDataSource(DataStream stream,
boolean buffer)
throws InvalidDataException
InvalidDataException - if the stream contains invalid data
public StreamDataSource(DataBuffer buffer)
throws InvalidDataException
InvalidDataException - if data buffer type resolvation fails| Method Detail |
public DataValue getData(int index)
throws com.davisor.core.InvalidIndexException
null is
returned. If buffer is available, but requested element is not,
NotFoundException is thrown.
getData in interface DataBufferindex - data element index
com.davisor.core.InvalidIndexException - if no data is bound to given indexpublic int getSize()
-1 is
returned.
getSize in interface DataBuffer
public DataStream getStream(boolean reversed)
throws InvalidDataException
getStream in interface DataBufferreversed - controls if stream reads buffer forwards or backwards
NullDataException - if no data buffer was available
InvalidDataException - if a new stream can not be createdpublic boolean close()
close in interface DataSource
public DataStream getStream()
throws InvalidDataException
getStream in interface DataSourceNullDataException - if there is no stream or buffer.
InvalidDataExceptionpublic java.lang.String toString()
toString in class VoidData
public DataBuffer getBuffer()
throws InvalidDataException
InvalidDataException - if the stream contains invalid data
public DataBuffer getBuffer(Type type)
throws InvalidDataException
InvalidDataException - if the stream contains invalid datapublic boolean isBuffered()
public void setBuffer(DataBuffer buffer)
public void setStream(DataStream stream)
public java.lang.String toString(java.lang.String id,
java.lang.String dataName)
DataSource documentation
toString in interface DataSource
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||