com.davisor.data.stream
Class JoinedDataBuffer

java.lang.Object
  extended bycom.davisor.data.VoidData
      extended bycom.davisor.data.stream.JoinedDataBuffer
All Implemented Interfaces:
Data, DataBuffer, DataSource
Direct Known Subclasses:
ChartXMLDataBuffer

public class JoinedDataBuffer
extends VoidData
implements DataBuffer

A JoinedDataBuffer makes a data buffer out of several parallel buffers. The elements of the new buffer will be tuples with as many elements as there are buffers. Elements of equal sequence numbers make one tuple data value. Missing elements and buffers and buffers shorter than other buffers will show up as null tuple elements.

If source buffers contain tuple-elements, then the buffers may optionally be fused together at the construction time by treating the tuple-elements in the original buffers as separate buffers. A tuple-buffer with N elements will in this case be broken into N separate buffers which will show up as if they would have been inserted separately. The names for these sub-buffers will be taken from their corresponding tuple element type names. Fusing will remove only the first tuple layer leaving other tuple elements deeper down alone.

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:
TupleData, TupleType

Field Summary
protected  java.util.Map bufferMetaData
          this meta data is inserted to the data buffer type
protected  DataBuffer[] M_buffers
          Underlying data buffers.
protected  int M_size
          Number of elements in the longest buffer.
 
Fields inherited from class com.davisor.data.VoidData
M_type
 
Constructor Summary
protected JoinedDataBuffer()
          Default constructor.
  JoinedDataBuffer(java.lang.String name, DataBuffer[] buffers)
          Creates a data buffer out of an array of buffers.
  JoinedDataBuffer(java.lang.String name, DataBuffer[] buffers, boolean fuse)
          Creates a data buffer out of an array of buffers.
  JoinedDataBuffer(java.lang.String name, DataBuffer[] buffers, java.lang.String[] ids)
          Creates a data buffer out of an array of buffers.
  JoinedDataBuffer(java.lang.String name, DataBuffer[] buffers, java.lang.String[] ids, boolean fuse)
          Creates a data buffer out of an array of buffers.
  JoinedDataBuffer(java.lang.String name, DataBuffer buffer, java.lang.String bufferID)
          Creates a data buffer out of two buffers.
  JoinedDataBuffer(java.lang.String name, DataBuffer buffer1, java.lang.String buffer1ID, DataBuffer buffer2, java.lang.String buffer2ID, boolean fuse)
          Creates a data buffer out of two buffers.
  JoinedDataBuffer(java.lang.String name, DataBuffer buffer1, java.lang.String buffer1ID, DataBuffer buffer2, java.lang.String buffer2ID, DataBuffer buffer3, java.lang.String buffer3ID, boolean fuse)
          Creates a data buffer out of three buffers.
  JoinedDataBuffer(java.lang.String name, java.util.Iterator lists, java.util.Iterator types, java.util.List idList, boolean fuse)
          Creates a data buffer out of a list of data lists, and assosiated list content types.
  JoinedDataBuffer(java.lang.String name, java.util.List bufferList)
          Creates a data buffer out of a list of buffers.
  JoinedDataBuffer(java.lang.String name, java.util.List bufferList, boolean fuse)
          Creates a data buffer out of a list of buffers.
  JoinedDataBuffer(java.lang.String name, java.util.List bufferList, java.util.List idList)
          Creates a data buffer out of a list of buffers.
  JoinedDataBuffer(java.lang.String name, java.util.List bufferList, java.util.List idList, boolean fuse)
          Creates a data buffer out of a list of buffers.
 
Method Summary
protected static java.util.List assosiateListsWithTypes(java.util.Iterator lists, java.util.Iterator types)
          Creates a ListDataBuffer for each list in given list of lists, and assosiates them with given types.
 boolean close()
          Dummy implementation.
 DataBuffer[] getBuffers()
          Gets the underlying data buffers.
 DataValue getData(int index)
          Gets a specific data element.
 int getSize()
          Gets the number of data elements in the buffer.
 DataStream getStream()
          Gets a data stream from the source.
 DataStream getStream(boolean reversed)
          Gets a data stream from the source.
protected  void init(java.lang.String name, java.util.List bufferList, java.util.List idList, boolean fuse)
          Initialize this buffer from a list of buffers and ids.
protected  void resolveSizeAndType(java.lang.String name, java.lang.String[] ids, boolean fuse)
          Resolves the joined buffer size and type.
 java.lang.String toString()
          Gets a buffer 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

M_buffers

protected DataBuffer[] M_buffers
Underlying data buffers.


M_size

protected int M_size
Number of elements in the longest buffer.


bufferMetaData

protected java.util.Map bufferMetaData
this meta data is inserted to the data buffer type

Constructor Detail

JoinedDataBuffer

protected JoinedDataBuffer()
Default constructor.


JoinedDataBuffer

public JoinedDataBuffer(java.lang.String name,
                        DataBuffer[] buffers)
                 throws InvalidDataException
Creates a data buffer out of an array of buffers. Each buffer will contribute one channel to the joined data buffer. The buffers will be given unique identifiers as described in the resolveSizeAndType method documentation.

Parameters:
name - buffer type name
buffers - channel buffers
Throws:
InvalidDataException - if buffers contain invalid elements
See Also:
JoinedDataBuffer(String,DataBuffer[],String[],boolean), resolveSizeAndType(java.lang.String, java.lang.String[], boolean)

JoinedDataBuffer

public JoinedDataBuffer(java.lang.String name,
                        DataBuffer[] buffers,
                        java.lang.String[] ids)
                 throws InvalidDataException
Creates a data buffer out of an array of buffers. Each buffer will contribute one channel to the joined data buffer. The buffers will be given unique identifiers as described in the resolveSizeAndType method documentation.

Parameters:
name - buffer type name
buffers - channel buffers
ids - channel identifiers (may be null)
Throws:
InvalidDataException - if buffers contain invalid elements
See Also:
JoinedDataBuffer(String,DataBuffer[],String[],boolean), resolveSizeAndType(java.lang.String, java.lang.String[], boolean)

JoinedDataBuffer

public JoinedDataBuffer(java.lang.String name,
                        DataBuffer[] buffers,
                        boolean fuse)
                 throws InvalidDataException
Creates a data buffer out of an array of buffers. Each buffer will contribute one channel to the joined data buffer. The buffers will be given unique identifiers as described in the resolveSizeAndType method documentation.

Parameters:
name - buffer type name
buffers - channel buffers
fuse - fuse buffers flag
Throws:
InvalidDataException - if buffers contain invalid elements
See Also:
JoinedDataBuffer(String,DataBuffer[],String[],boolean), resolveSizeAndType(java.lang.String, java.lang.String[], boolean)

JoinedDataBuffer

public JoinedDataBuffer(java.lang.String name,
                        DataBuffer[] buffers,
                        java.lang.String[] ids,
                        boolean fuse)
                 throws InvalidDataException
Creates a data buffer out of an array of buffers. Each buffer will contribute one channel to the joined data buffer. The buffers will be given unique identifiers as described in the resolveSizeAndType method documentation.

Parameters:
name - buffer type name
buffers - channel buffers
ids - channel identifiers (may be null)
fuse - fuse buffers flag
Throws:
InvalidDataException - if buffers contain invalid elements
See Also:
resolveSizeAndType(java.lang.String, java.lang.String[], boolean)

JoinedDataBuffer

public JoinedDataBuffer(java.lang.String name,
                        java.util.List bufferList)
                 throws InvalidDataException
Creates a data buffer out of a list of buffers. Each buffer will contribute one channel to the joined data buffer. The buffers will be given unique identifiers as described in the resolveSizeAndType method documentation.

Parameters:
name - buffer type name
bufferList - a list of channel buffers
Throws:
InvalidDataException - if buffers contain invalid elements
See Also:
JoinedDataBuffer(String,List,List,boolean), resolveSizeAndType(java.lang.String, java.lang.String[], boolean)

JoinedDataBuffer

public JoinedDataBuffer(java.lang.String name,
                        java.util.List bufferList,
                        java.util.List idList)
                 throws InvalidDataException
Creates a data buffer out of a list of buffers. Each buffer will contribute one channel to the joined data buffer. The buffers will be given unique identifiers as described in the resolveSizeAndType method documentation.

Parameters:
name - buffer type name
bufferList - a list of channel buffers
idList - a list of channel identifier strings (may be null)
Throws:
InvalidDataException - if buffers contain invalid elements
See Also:
JoinedDataBuffer(String,List,List,boolean), resolveSizeAndType(java.lang.String, java.lang.String[], boolean)

JoinedDataBuffer

public JoinedDataBuffer(java.lang.String name,
                        java.util.List bufferList,
                        boolean fuse)
                 throws InvalidDataException
Creates a data buffer out of a list of buffers. Each buffer will contribute one channel to the joined data buffer. The buffers will be given unique identifiers as described in the resolveSizeAndType method documentation.

Parameters:
name - buffer type name
bufferList - a list of channel buffers
fuse - fuse buffers flag
Throws:
InvalidDataException - if buffers contain invalid elements
See Also:
JoinedDataBuffer(String,List,List,boolean), resolveSizeAndType(java.lang.String, java.lang.String[], boolean)

JoinedDataBuffer

public JoinedDataBuffer(java.lang.String name,
                        java.util.List bufferList,
                        java.util.List idList,
                        boolean fuse)
                 throws InvalidDataException
Creates a data buffer out of a list of buffers. Each buffer will contribute one channel to the joined data buffer. The buffers will be given unique identifiers as described in the resolveSizeAndType method documentation.

Parameters:
name - buffer type name
bufferList - a list of channel buffers
idList - a list of channel identifier strings (may be null)
fuse - fuse buffers flag
Throws:
InvalidDataException - if buffers contain invalid elements
See Also:
resolveSizeAndType(java.lang.String, java.lang.String[], boolean)

JoinedDataBuffer

public JoinedDataBuffer(java.lang.String name,
                        java.util.Iterator lists,
                        java.util.Iterator types,
                        java.util.List idList,
                        boolean fuse)
                 throws InvalidDataException
Creates a data buffer out of a list of data lists, and assosiated list content types. Each data list will contribute one channel to the joined data buffer. The buffers will be given unique identifiers as described in the resolveSizeAndType method documentation.

Parameters:
name - buffer type name
lists - a list of data lists
types - a list of types that describe the content of each data list
idList - a list of channel identifier strings (may be null)
fuse - fuse buffers flag
Throws:
InvalidDataException - if buffers contain invalid elements
See Also:
resolveSizeAndType(java.lang.String, java.lang.String[], boolean)

JoinedDataBuffer

public JoinedDataBuffer(java.lang.String name,
                        DataBuffer buffer,
                        java.lang.String bufferID)
                 throws InvalidDataException
Creates a data buffer out of two buffers. Each buffer will contribute one channel to the joined data buffer. The buffers will be given unique identifiers as described in the resolveSizeAndType method documentation.

Parameters:
name - buffer type name
buffer - first channel data buffer
bufferID - first channel identifier
Throws:
InvalidDataException - if buffers contain invalid elements
See Also:
resolveSizeAndType(java.lang.String, java.lang.String[], boolean)

JoinedDataBuffer

public JoinedDataBuffer(java.lang.String name,
                        DataBuffer buffer1,
                        java.lang.String buffer1ID,
                        DataBuffer buffer2,
                        java.lang.String buffer2ID,
                        boolean fuse)
                 throws InvalidDataException
Creates a data buffer out of two buffers. Each buffer will contribute one channel to the joined data buffer. The buffers will be given unique identifiers as described in the resolveSizeAndType method documentation.

Parameters:
name - buffer type name
buffer1 - first channel data buffer
buffer1ID - first channel identifier
buffer2 - second channel data buffer
buffer2ID - second channel identifier
fuse - fuse buffers flag
Throws:
InvalidDataException - if buffers contain invalid elements
See Also:
resolveSizeAndType(java.lang.String, java.lang.String[], boolean)

JoinedDataBuffer

public JoinedDataBuffer(java.lang.String name,
                        DataBuffer buffer1,
                        java.lang.String buffer1ID,
                        DataBuffer buffer2,
                        java.lang.String buffer2ID,
                        DataBuffer buffer3,
                        java.lang.String buffer3ID,
                        boolean fuse)
                 throws InvalidDataException
Creates a data buffer out of three buffers. Each buffer will contribute one channel to the joined data buffer. The buffers will be given unique identifiers as described in the resolveSizeAndType method documentation.

Parameters:
name - buffer type name
buffer1 - first channel data buffer
buffer1ID - first channel identifier
buffer2 - second channel data buffer
buffer2ID - second channel identifier
buffer3 - third channel data buffer
buffer3ID - third channel identifier
fuse - fuse buffers flag
Throws:
InvalidDataException - if buffers contain invalid elements
See Also:
resolveSizeAndType(java.lang.String, java.lang.String[], boolean)
Method Detail

close

public boolean close()
Dummy implementation. Closing data buffer not so important, when compared to dynamic data sources.

Specified by:
close in interface DataSource
Returns:
true

getData

public DataValue getData(int index)
                  throws com.davisor.core.InvalidIndexException
Gets a specific data element. The returned element is a new TupleData object with references to data values in underlying data buffers and types. Missing data in undersized buffers will show up as null values.

If an unexpected error is encountered while fetching data from an underlying data buffer, this method will immediately recover from the error by simply setting the corresponding tuple member value to null value, and printing a verbose error message to system error log.

Specified by:
getData in interface DataBuffer
Parameters:
index - data element index
Throws:
com.davisor.core.InvalidIndexException - if no data is bound to given index

getSize

public int getSize()
Gets the number of data elements in the buffer.

Specified by:
getSize in interface DataBuffer

getStream

public DataStream getStream(boolean reversed)
                     throws InvalidDataException
Gets a data stream from the source.

Specified by:
getStream in interface DataBuffer
Parameters:
reversed - controls if stream reads buffer forwards or backwards
Throws:
InvalidDataException - if a new stream can not be created
See Also:
JoinedDataStream.JoinedDataStream(DataStream[],TupleType)

getStream

public DataStream getStream()
                     throws InvalidDataException
Gets a data stream from the source.

Specified by:
getStream in interface DataSource
Throws:
InvalidDataException
See Also:
JoinedDataStream.JoinedDataStream(DataStream[],TupleType)

toString

public java.lang.String toString(java.lang.String id,
                                 java.lang.String dataName)
See the DataSource documentation

Specified by:
toString in interface DataSource

toString

public java.lang.String toString()
Gets a buffer string representation. The string representation will consist of the the string representations of each individual component buffer.

Possible meta data fields of 'name' and 'group' are not returned.

Overrides:
toString in class VoidData

assosiateListsWithTypes

protected static final java.util.List assosiateListsWithTypes(java.util.Iterator lists,
                                                              java.util.Iterator types)
Creates a ListDataBuffer for each list in given list of lists, and assosiates them with given types.

Parameters:
lists - list of data lists
types - corresponding list of list data types
See Also:
ListDataBuffer.ListDataBuffer(com.davisor.data.Type,java.util.List)

init

protected void init(java.lang.String name,
                    java.util.List bufferList,
                    java.util.List idList,
                    boolean fuse)
             throws InvalidDataException
Initialize this buffer from a list of buffers and ids. The buffer list is expected to contain DataBuffer objects, and the id list string objects.

Parameters:
name - buffer type name
bufferList - a list of channel buffers
idList - a list of channel identifier strings (may be null)
fuse - fuse buffers flag
Throws:
InvalidDataException

resolveSizeAndType

protected final void resolveSizeAndType(java.lang.String name,
                                        java.lang.String[] ids,
                                        boolean fuse)
                                 throws InvalidDataException
Resolves the joined buffer size and type. The buffer size will equal the size of the largest member channel. The buffer type will be a tuple type with member channel types as type elements.

If channel identifiers have been explicitly given, then they are assigned to member types in the order the identifiers appear in the given identifier table. If the identifier table or some of it's members are null, then the missing channel identifiers are taken from member type names. In either case, the identifier uniqueness is enforced by making sure that no two identifiers are equal. If they are, the later identifier is given a running integer index that is appended to the end of the violating identifier.

If the member buffers contain tuple-elements that are to be fused together, that fusing is done here before the buffers are assigned their final names. Sub-buffer tuple ids are preserved, while single valued buffer ids are taken from the given id argument.

Parameters:
name - buffer type name
ids - channel identifiers
fuse - fuse buffers flag
Throws:
InvalidDataException - if buffers contain invalid elements

getBuffers

public DataBuffer[] getBuffers()
Gets the underlying data buffers.



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