com.davisor.data.stream
Class ProxyDataBuffer

java.lang.Object
  extended bycom.davisor.data.stream.IndirectDataBuffer
      extended bycom.davisor.data.stream.ProxyDataBuffer
All Implemented Interfaces:
Data, DataBuffer, DataSource

public class ProxyDataBuffer
extends IndirectDataBuffer

ProxyDataBuffer provides a single column view to a multi column buffer. A multi column buffer is any buffer that contains TupleData elements.

The proxy source data buffer and target tuple member are set at proxy construction time, and from there on the proxy buffer behaves like a buffer that would contain only one column.

The connection to the source data buffer is live in that sense that any changes made to the source data buffer affect the results returned by this proxy immediately. In particular, applications must take care of appropriate synchronization issues by themselves.

If the proxy source data buffer in an instance of JoinedDataBuffer, all proxy operations will access the target joined data buffer member buffer directly. If the source data buffer is some other implementation, proxy operations will first access the main buffer, and then only operation one of the main buffer tuple elements. Please note, that these two cases represent column-first and row-first data table arrangements, respectively.

Since:
JDK1.4

Nested Class Summary
 class ProxyDataBuffer.ProxyDataStream
          ProxyDataStream implements a single column view to a multi column stream.
 
Field Summary
protected  int M_memberIndex
          The index of the member this proxy refers to.
static int NONE
          Member index value to indicate access to the the whole element.
 
Fields inherited from class com.davisor.data.stream.IndirectDataBuffer
M_dataBuffer
 
Constructor Summary
ProxyDataBuffer(DataBuffer dataBuffer, int memberIndex)
          Creates a new proxy data buffer.
 
Method Summary
 DataValue getData(int index)
          Gets the specific data element from the data buffer.
 DataStream getStream()
          Gets a new data stream from the data source.
 DataStream getStream(boolean reversed)
          Gets a new data stream from the data source.
 Type getType()
          Gets the type of this data object.
 java.lang.String toString(java.lang.String id, java.lang.String dataName)
          Returns a String representation of the DataSource.
 
Methods inherited from class com.davisor.data.stream.IndirectDataBuffer
close, equals, getSize, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NONE

public static final int NONE
Member index value to indicate access to the the whole element.

See Also:
Constant Field Values

M_memberIndex

protected int M_memberIndex
The index of the member this proxy refers to.

Constructor Detail

ProxyDataBuffer

public ProxyDataBuffer(DataBuffer dataBuffer,
                       int memberIndex)
                throws com.davisor.core.InvalidIndexException
Creates a new proxy data buffer. If the given data buffer is a JoinedDataBuffer instance, this proxy will access one of the joined data buffer member buffers directly. Otherwise the proxy will access the whole buffer, but operate on given member element only.

If given member index is NONE, the proxy will always access the whole element, and therefore act as an extra no-operation layer on top of given buffer. In particular, this will allow the proxy to operate on single column buffers, too, that use simple data values instead of tuple data values.

In order to support lazy buffer content evaluation, given buffer access is minimized at this time. This means also that buffer validity is not fully checked. Instead, if the buffer type or content is invalid in some sense, this will cause runtime exceptions later when the buffer is actually referenced.

Parameters:
dataBuffer - proxy source data buffer
memberIndex - source tuple data target member index (may be NONE)
Throws:
com.davisor.core.InvalidIndexException - if there is no such member in given buffer
java.lang.NullPointerException - if the given data buffer is null
Method Detail

getType

public Type getType()
             throws InvalidDataException
Gets the type of this data object.

Specified by:
getType in interface Data
Overrides:
getType in class IndirectDataBuffer
Returns:
the type associated with this data object
Throws:
java.lang.ClassCastException - if a target type could not be resolved
InvalidDataException - if type retrieval fails
java.lang.NullPointerException - if the source buffer is null
See Also:
Data.getType()

getData

public DataValue getData(int index)
                  throws com.davisor.core.InvalidIndexException
Gets the specific data element from the data buffer.

Specified by:
getData in interface DataBuffer
Specified by:
getData in class IndirectDataBuffer
Parameters:
index - data element index
Throws:
com.davisor.core.InvalidIndexException - if no data is bound to given index
java.lang.NullPointerException - if the source buffer is null

getStream

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

Specified by:
getStream in interface DataBuffer
Specified by:
getStream in class IndirectDataBuffer
Parameters:
reversed - controls if stream reads buffer forwards or backwards
Throws:
InvalidDataException - if a new stream can not be created
java.lang.NullPointerException - if the source buffer is null

getStream

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

Specified by:
getStream in interface DataSource
Overrides:
getStream in class IndirectDataBuffer
Throws:
InvalidDataException - if a new stream can not be created
java.lang.NullPointerException - if the source buffer is null

toString

public java.lang.String toString(java.lang.String id,
                                 java.lang.String dataName)
Returns a String representation of the DataSource. The possible id and dataname are is overridden with the given calues.

Specified by:
toString in interface DataSource
Overrides:
toString in class IndirectDataBuffer
Throws:
java.lang.NullPointerException - if the source buffer is null


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