|
|||||||||||
| 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.IteratorDataStream
IteratorDataStream represents a data stream that uses a standard Java iterator to implement stream elements. The elements may or may not be DataValues, and they may or may not be of a mutually equal type. The stream itself has a single type, however.
References to DataValue elements are returned as they are. Elements not of the expected type are converted first to data objects of the proper type, and then the converted objects are returned. The original objects in the source are not changed.
next(),
EnumeratorDataStream,
Type| Field Summary | |
protected boolean |
M_hasNext
Is there still data in this stream. |
protected long |
M_index
Element id counter. |
protected java.util.Iterator |
M_iterator
Underlying stream iterator. |
protected java.lang.Object |
M_metaData
Stream meta data (may be null). |
protected DataValue |
M_nextData
Reference to the next data element to be returned (may be null). |
| Fields inherited from class com.davisor.data.VoidData |
M_type |
| Fields inherited from interface com.davisor.data.stream.DataStream |
INITIAL_INDEX |
| Constructor Summary | |
|
IteratorDataStream(java.util.Collection collection)
Creates a data stream out of a collection. |
|
IteratorDataStream(java.util.Collection collection,
Type type)
Creates a data stream out of a collection and given type. |
|
IteratorDataStream(java.util.Iterator iterator)
Creates a data stream out of an iterator. |
|
IteratorDataStream(java.util.Iterator iterator,
Type type)
Creates a data stream out of an iterator and the given type. |
protected |
IteratorDataStream(Type type)
Creates a new data stream out of a given type. |
| Method Summary | |
boolean |
close()
Explicitly closes this data stream, and frees all system resources it has allocated immediately. |
long |
getIndex()
Retrieves the index number of the element returned by the latest next() call. |
boolean |
hasNext()
Tests if the stream still contains data. |
protected void |
init(java.util.Iterator iterator)
Initializes this iterator stream with given iterator. |
DataValue |
next()
Gets the next data value from the stream. |
java.lang.String |
toString()
Gets the string representation of this data stream. |
| 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 DataValue M_nextData
protected long M_index
protected java.util.Iterator M_iterator
protected boolean M_hasNext
protected java.lang.Object M_metaData
| Constructor Detail |
protected IteratorDataStream(Type type)
type - the type of data in streamVoidData.getType(),
init(java.util.Iterator)
public IteratorDataStream(java.util.Collection collection)
throws InvalidDataException
collection - data collection to create a stream from
InvalidDataException - if the first element is not a DataValueIteratorDataStream(Collection,Type)
public IteratorDataStream(java.util.Collection collection,
Type type)
throws InvalidDataException
collection - data collection to create a stream fromtype - the type of data in stream
InvalidDataException - if the first element is not of the given
type, and cannot be converted to a data object of that typeIteratorDataStream(Iterator,Type)
public IteratorDataStream(java.util.Iterator iterator)
throws InvalidDataException
AutoType.
iterator - data iterator to create a stream from
InvalidDataException - if the first element was not a
DataValue, and no suitable type could be created for itIteratorDataStream(Iterator,Type),
AutoType
public IteratorDataStream(java.util.Iterator iterator,
Type type)
throws InvalidDataException
iterator - data iterator to create a stream fromtype - the type of data in stream
InvalidDataException - if the first element is not of the
given type, and cannot be converted to a data object of that
type.IteratorDataStream(Collection,Type),
IteratorDataStream(Iterator),
init(java.util.Iterator)| Method Detail |
public boolean close()
close in interface DataStreamtrueinit(java.util.Iterator)public long getIndex()
next() call. The index represents the position of the
element within this stream. The stream index may or may
not be equal to any other indexes the element itself thinks it
posesses.
The index value is initially INITIAL_INDEX (-1),
indicating no element. After first next() call, index
becomes 0, then 1, and so on. This functionality resembles
java.sql.resultSet#getRow method functionality, but
with the difference that the index counter starts from 0, not 1.
getIndex in interface DataStreampublic boolean hasNext()
hasNext in interface DataStreamtrue if it does.
public DataValue next()
throws InvalidDataException
next in interface DataStreamInvalidDataException - if the stream content does not satisfy
the stream typeclose(),
VoidData.getDataValue(java.lang.Object),
hasNext(),
init(java.util.Iterator)public java.lang.String toString()
toString in class VoidDatahasNext(),
next()
protected void init(java.util.Iterator iterator)
throws InvalidDataException
hasNext() status is
inspected at this time. If the iterator is not null
and it has a next element, stream hasNext() status is
set to true, and the next iterator element is set to
be the next() stream object to be returned. Otherwise
stream hasNext() status is set to false,
and the next iterator element is set to null.
The stream index is also set to INITIAL_INDEX (-1)
value.
iterator - the iterator to initialize this stream with (may be null)
InvalidDataException - if the first element is not a DataValueVoidData.getDataValue(java.lang.Object)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||