com.davisor.data.stream
Class TupleDataStream

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

public class TupleDataStream
extends VoidData
implements DataStream

A TupleDataStream allows tuple elements in a tuple data stream to be rearranged at will, or to make ordinary data streams tuple streams.

Since:
JDK1.1
See Also:
TupleData, TupleType

Field Summary
protected  TupleData M_data
          Next element, if any.
protected  long M_index
          Element id counter.
protected  int[] M_map
          Tuple element reorder indexes.
protected  java.lang.Object M_metaData
          Stream meta data (may be null).
protected  DataStream M_stream
          Source stream.
protected  boolean M_tuplify
          Tuple element arrangement method indicator.
 
Fields inherited from class com.davisor.data.VoidData
M_type
 
Fields inherited from interface com.davisor.data.stream.DataStream
INITIAL_INDEX
 
Constructor Summary
TupleDataStream(DataStream stream)
          Creates a tuple data stream from any data stream.
TupleDataStream(DataStream stream, TupleType type)
          Creates a tuple data stream from any data stream.
TupleDataStream(DataStream stream, TupleType type, int[] map)
          Creates a tuple data stream from any data stream.
 
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.
 
Methods inherited from class com.davisor.data.VoidData
equals, getDataValue, getType, hashCode, setType, toString
 
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 TupleData M_data
Next element, if any.


M_index

protected long M_index
Element id counter.


M_map

protected int[] M_map
Tuple element reorder indexes.


M_metaData

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


M_stream

protected DataStream M_stream
Source stream.


M_tuplify

protected boolean M_tuplify
Tuple element arrangement method indicator.

Constructor Detail

TupleDataStream

public TupleDataStream(DataStream stream)
                throws InvalidDataException
Creates a tuple data stream from any data stream. If the given data stream contains tuples, it is accepted unchanged. If the given stream does not contain tuples, then the stream elements will be arranged into one element tuples.

Parameters:
stream - source stream
Throws:
InvalidDataException - if the collection content does not satisfy the given type.
See Also:
TupleType.getTypeIndex(java.lang.String), TupleType.getTypeIndexMap(com.davisor.data.TupleType), TupleType.rearrange(com.davisor.data.TupleData, int[])

TupleDataStream

public TupleDataStream(DataStream stream,
                       TupleType type)
                throws InvalidDataException
Creates a tuple data stream from any data stream. If the given data stream contains tuples, their content will be rearranged as specified by the given tuple type. If the given stream does not contain tuples, then the stream elements will be arranged into a tuple of the given type.

Parameters:
stream - source stream
type - new type
Throws:
InvalidDataException - if the collection content does not satisfy the given type.
See Also:
TupleType.getTypeIndex(java.lang.String), TupleType.getTypeIndexMap(com.davisor.data.TupleType), TupleType.rearrange(com.davisor.data.TupleData, int[])

TupleDataStream

public TupleDataStream(DataStream stream,
                       TupleType type,
                       int[] map)
                throws InvalidDataException
Creates a tuple data stream from any data stream. If the given data stream contains tuples, their content will be rearranged as specified by the given tuple type. If the given stream does not contain tuples, then the stream elements will be arranged into a tuple of the given type.

Parameters:
stream - source stream
type - new type
map - precomputed tuple member index map
Throws:
InvalidDataException - if the collection content does not satisfy given type.
See Also:
TupleType.getTypeIndex(java.lang.String), TupleType.getTypeIndexMap(com.davisor.data.TupleType), TupleType.rearrange(com.davisor.data.TupleData, int[])
Method Detail

close

public boolean close()
This method frees resources for cargabe collection.

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 collection content does not satisfy the given type.


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