com.davisor.data.stream
Class JoinedDataStream

java.lang.Object
  extended bycom.davisor.data.VoidData
      extended bycom.davisor.data.stream.JoinedDataStream
All Implemented Interfaces:
Data, DataStream

public class JoinedDataStream
extends VoidData
implements DataStream

A JoinedDataStream makes a data stream out of several parallel streams.

Access to joined data buffers goes through the tools provided by TupleType and TupleData objects. Please see their respective documentation for more information.

Since:
JDK1.1
See Also:
JoinedDataBuffer, TupleData, TupleType

Field Summary
protected  DataValue M_data
          Next data element in stream.
protected  long M_index
          Element id counter.
protected  java.lang.Object M_metaData
          External meta data (may be null).
protected  DataStream[] M_streams
          Stream components.
 
Fields inherited from class com.davisor.data.VoidData
M_type
 
Fields inherited from interface com.davisor.data.stream.DataStream
INITIAL_INDEX
 
Constructor Summary
JoinedDataStream(DataStream[] streams)
          Creates a data stream out of an array of streams.
JoinedDataStream(DataStream[] streams, java.lang.String[] streamIDs)
          Creates a data stream out of an array of streams and new stream identities.
JoinedDataStream(DataStream[] streams, TupleType type)
          Creates a data stream out of an array of streams and the corresponding tuple type.
JoinedDataStream(DataStream stream1, java.lang.String stream1ID, DataStream stream2, java.lang.String stream2ID)
          Creates a data stream out of two streams.
JoinedDataStream(DataStream stream1, java.lang.String stream1ID, DataStream stream2, java.lang.String stream2ID, DataStream stream3, java.lang.String stream3ID)
          Creates a data stream out of two streams.
JoinedDataStream(java.util.Iterator streamDatas, java.util.Iterator streamTypes, java.util.List streamIDs)
          Creates a data stream out of a list of data lists, type list, list of identities.
JoinedDataStream(java.util.List streams)
          Creates a data stream out of a list of streams.
JoinedDataStream(java.util.List streams, java.util.List streamIDs)
          Creates a data stream out of a list of streams and new stream identities.
 
Method Summary
 boolean close()
          This method frees resources for cargabe collection.
 long getIndex()
          Retrieves the index number of the element returned by the latest next() call.
 boolean hasNext()
          Tests if the stream still contains data.
 DataValue next()
          Gets the next data from the stream.
 java.lang.String toString()
          Gets the stream string representation.
 
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

M_data

protected DataValue M_data
Next data element in stream.


M_index

protected long M_index
Element id counter.


M_metaData

protected java.lang.Object M_metaData
External meta data (may be null).


M_streams

protected DataStream[] M_streams
Stream components.

Constructor Detail

JoinedDataStream

public JoinedDataStream(DataStream[] streams)
                 throws InvalidDataException
Creates a data stream out of an array of streams. The stream tuple type is composed automatically from the types of given streams.

Parameters:
streams - stream component streams
Throws:
InvalidDataException - if the substream content does not satisfy the given type
See Also:
JoinedDataStream(DataStream[],String[])

JoinedDataStream

public JoinedDataStream(java.util.List streams)
                 throws InvalidDataException
Creates a data stream out of a list of streams. The stream tuple type is composed automatically from the types of given streams.

Parameters:
streams - stream component streams
Throws:
InvalidDataException - if the substream content does not satisfy the given type
See Also:
JoinedDataStream(List,List)

JoinedDataStream

public JoinedDataStream(DataStream[] streams,
                        TupleType type)
                 throws InvalidDataException
Creates a data stream out of an array of streams and the corresponding tuple type. The given tuple type is expected to contain component stream types as tuple members.

Parameters:
streams - stream component streams
type - combined stream types
Throws:
InvalidDataException - if the substream content does not satisfy the given type

JoinedDataStream

public JoinedDataStream(DataStream[] streams,
                        java.lang.String[] streamIDs)
                 throws InvalidDataException
Creates a data stream out of an array of streams and new stream identities. The stream tuple type is composed automatically from the types of given streams. Furthermore, the identities of the types of given streams will be changed to match given new identities, if any.

Parameters:
streams - streams to be joined
streamIDs - unique ids for each stream (may be null)
Throws:
InvalidDataException - if the substream content does not satisfy the given type
See Also:
JoinedDataStream(DataStream[]), Type.setID(java.lang.String)

JoinedDataStream

public JoinedDataStream(java.util.List streams,
                        java.util.List streamIDs)
                 throws InvalidDataException
Creates a data stream out of a list of streams and new stream identities. The stream tuple type is composed automatically from the types of given streams. Furthermore, the identities of the types of given streams will be changed to match given new identities, if any.

Parameters:
streams - streams to be joined
streamIDs - unique ids for each stream (may be null)
Throws:
InvalidDataException - if the substream content does not satisfy the given type
See Also:
JoinedDataStream(List)

JoinedDataStream

public JoinedDataStream(java.util.Iterator streamDatas,
                        java.util.Iterator streamTypes,
                        java.util.List streamIDs)
                 throws InvalidDataException
Creates a data stream out of a list of data lists, type list, list of identities. The stream tuple type is composed automatically from given types. Furthermore, the identities of the types of given streams will be changed to match given new identities, if any.

Parameters:
streamDatas - component stream data lists
streamTypes - componen stream types
streamIDs - unique ids for each stream (may be null)
Throws:
InvalidDataException - if the substream content does not satisfy the given type
See Also:
JoinedDataStream(List)

JoinedDataStream

public JoinedDataStream(DataStream stream1,
                        java.lang.String stream1ID,
                        DataStream stream2,
                        java.lang.String stream2ID)
                 throws InvalidDataException
Creates a data stream out of two streams. The stream tuple type is composed automatically from given types. Furthermore, type identities of the types of the given streams will be changed to match the given identities, if any.

Parameters:
stream1 - first stream
stream1ID - first stream new identity
stream2 - second stream
stream2ID - second stream new identity
Throws:
InvalidDataException - if the substream content does not satisfy the given type

JoinedDataStream

public JoinedDataStream(DataStream stream1,
                        java.lang.String stream1ID,
                        DataStream stream2,
                        java.lang.String stream2ID,
                        DataStream stream3,
                        java.lang.String stream3ID)
                 throws InvalidDataException
Creates a data stream out of two streams. The stream tuple type is composed automatically from given types. Furthermore, type identities of the types of the given streams will be changed to match the given identities, if any.

Parameters:
stream1 - first stream
stream1ID - first stream new identity
stream2 - second stream
stream2ID - second stream new identity
stream3 - third stream
stream3ID - third stream new identity
Throws:
InvalidDataException - if the substream content does not satisfy the given type
Method Detail

close

public boolean close()
This method frees resources for cargabe collection. Will try to close all the stream that this has access to.

Specified by:
close in interface DataStream
Returns:
true
See Also:
DataStream.hasNext()

getIndex

public long getIndex()
Retrieves the index number of the element returned by the latest 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 -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.

Specified by:
getIndex in interface DataStream
Returns:
element index

hasNext

public boolean hasNext()
Tests if the stream still contains data.

Specified by:
hasNext in interface DataStream
Returns:
true if it does.

next

public DataValue next()
               throws InvalidDataException
Gets the next data from the stream.

Specified by:
next in interface DataStream
Throws:
InvalidDataException - if the substream content does not satisfy the given type.

toString

public java.lang.String toString()
Gets the stream string representation. The string representation will consist of the stream representations of each data stream, concatenated together, and separated with a new line character.

Depending on stream implementation, streams may or may not be permanently consumed by this operation.

Overrides:
toString in class VoidData


Copyright © 2001-2004 Davisor Oy. All Rights Reserved.