net.sf.farrago.fennel.tuple
Class FennelTupleDatum

java.lang.Object
  extended by net.sf.farrago.fennel.tuple.FennelTupleDatum

public class FennelTupleDatum
extends Object

A FennelTupleDatum is a component of FennelTupleData; see the fennel tuple design document for more details.

This differs from the C++ version as we can't represent pointers in java. Therefore all the primitive accessors have been provided as methods of this object.

Internally, this object attempts to bypass object creation during normal use. It does this by wrangling all numeric primitive types into a 64-bit (long) value and all array data into a byte array. This class is JDK 1.4 compatible.


Field Summary
private  int capacity
          maximum size of this data in externalized form.
private  int dataLen
          length of this data in externalized form.
private  byte[] initialBytes
          a byte array holding the initial byte array, of capacity size.
private  boolean isUnicode
          if character data, whether the attribute descriptor is Unicode; otherwise false
private  long numeric
          the numeric object kept by this tuple; this holds all the numeric primitive type.
private  boolean numericSet
          indicates whether the numeric value has been set.
private  byte[] rawBytes
          a byte array holding non-numeric information.
private  boolean rawBytesSet
          indicates whether the byte array has been set.
 
Constructor Summary
FennelTupleDatum()
          Constructs a raw datum; setCapacity must be called before use.
FennelTupleDatum(FennelTupleDatum other)
          copy constructor.
FennelTupleDatum(int capacity)
          Constructs a datum with a defined capacity.
 
Method Summary
 void copyFrom(FennelTupleDatum other)
          copy construction helper.
 boolean getBoolean()
          gets a boolean value.
 byte getByte()
          gets a signed byte value.
 byte[] getBytes()
          gets a byte array.
 int getCapacity()
          gets the capacity of this data item.
 double getDouble()
          gets a double value.
 float getFloat()
          gets a float value.
 int getInt()
          gets a signed int value.
 int getLength()
          gets the length, in bytes, of this datum.
 long getLong()
          gets a signed long value.
 short getShort()
          gets a signed short value.
 short getUnsignedByte()
          gets an unsigned byte value
 long getUnsignedInt()
          gets an unsigned int value.
 long getUnsignedLong()
          gets an unsigned long value.
 int getUnsignedShort()
          gets an unsigned short value.
 boolean isPresent()
          Indicates whether data is present in this datum.
 boolean isUnicode()
          Whether character data is stored as Unicode.
 void reset()
          resets a datum for reuse.
 void setBoolean(boolean val)
          sets a boolean value.
 void setByte(byte n)
          sets the numeric value of a signed byte.
 void setBytes(byte[] bytes)
          set the byte array.
 void setCapacity(int capacity)
          sets the capacity of this data item.
 void setDouble(double val)
          sets the numeric value of a double.
 void setFloat(float val)
          sets the numeric value of a float.
 void setInt(int n)
          sets the numeric value of a signed integer.
 void setLength(int len)
          sets the length of this datum's byte array.
 void setLong(long n)
          used by the attribute marshalling to set numeric values.
 byte[] setRawBytes()
          used by the marshalling routines to set a byte array.
 void setShort(short n)
          sets the numeric value of a signed short.
 void setString(String str)
          set the byte array to a string.
 void setString(String str, String charsetName)
           
(package private)  void setUnicode(boolean isUnicode)
          Sets the isUnicode flag; this is non-public because it is private to TupleData initialization.
 void setUnsignedByte(short val)
          sets the numeric value of an unsigned byte.
 void setUnsignedInt(long val)
          sets the numeric value of an unsigned integer.
 void setUnsignedLong(long val)
          sets the numeric value of an unsigned long.
 void setUnsignedShort(int val)
          sets the numeric value of an unsigned short.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dataLen

private int dataLen
length of this data in externalized form.


capacity

private int capacity
maximum size of this data in externalized form.


isUnicode

private boolean isUnicode
if character data, whether the attribute descriptor is Unicode; otherwise false


numeric

private long numeric
the numeric object kept by this tuple; this holds all the numeric primitive type.


numericSet

private boolean numericSet
indicates whether the numeric value has been set.


rawBytes

private byte[] rawBytes
a byte array holding non-numeric information.


initialBytes

private byte[] initialBytes
a byte array holding the initial byte array, of capacity size.


rawBytesSet

private boolean rawBytesSet
indicates whether the byte array has been set.

Constructor Detail

FennelTupleDatum

public FennelTupleDatum()
Constructs a raw datum; setCapacity must be called before use.


FennelTupleDatum

public FennelTupleDatum(int capacity)
Constructs a datum with a defined capacity. This is the normal constructor.


FennelTupleDatum

public FennelTupleDatum(FennelTupleDatum other)
copy constructor.

Method Detail

setCapacity

public void setCapacity(int capacity)
sets the capacity of this data item.


getCapacity

public int getCapacity()
gets the capacity of this data item.


isPresent

public boolean isPresent()
Indicates whether data is present in this datum.


reset

public void reset()
resets a datum for reuse.


getLength

public int getLength()
gets the length, in bytes, of this datum.


setLength

public void setLength(int len)
sets the length of this datum's byte array.


copyFrom

public void copyFrom(FennelTupleDatum other)
copy construction helper.


setLong

public void setLong(long n)
used by the attribute marshalling to set numeric values.


setInt

public void setInt(int n)
sets the numeric value of a signed integer.


setUnsignedInt

public void setUnsignedInt(long val)
sets the numeric value of an unsigned integer.


setShort

public void setShort(short n)
sets the numeric value of a signed short.


setUnsignedShort

public void setUnsignedShort(int val)
sets the numeric value of an unsigned short.


setByte

public void setByte(byte n)
sets the numeric value of a signed byte.


setUnsignedByte

public void setUnsignedByte(short val)
sets the numeric value of an unsigned byte.


setUnsignedLong

public void setUnsignedLong(long val)
sets the numeric value of an unsigned long.


setFloat

public void setFloat(float val)
sets the numeric value of a float.


setDouble

public void setDouble(double val)
sets the numeric value of a double.


setBoolean

public void setBoolean(boolean val)
sets a boolean value.


setRawBytes

public byte[] setRawBytes()
used by the marshalling routines to set a byte array.


getLong

public long getLong()
             throws NullPointerException
gets a signed long value.

Throws:
NullPointerException

getInt

public int getInt()
           throws NullPointerException
gets a signed int value.

Throws:
NullPointerException

getShort

public short getShort()
               throws NullPointerException
gets a signed short value.

Throws:
NullPointerException

getByte

public byte getByte()
             throws NullPointerException
gets a signed byte value.

Throws:
NullPointerException

getUnsignedByte

public short getUnsignedByte()
                      throws NullPointerException
gets an unsigned byte value

Throws:
NullPointerException

getUnsignedShort

public int getUnsignedShort()
                     throws NullPointerException
gets an unsigned short value.

Throws:
NullPointerException

getUnsignedInt

public long getUnsignedInt()
                    throws NullPointerException
gets an unsigned int value.

Throws:
NullPointerException

getUnsignedLong

public long getUnsignedLong()
                     throws NullPointerException
gets an unsigned long value.

Throws:
NullPointerException

getFloat

public float getFloat()
               throws NullPointerException
gets a float value.

Throws:
NullPointerException

getDouble

public double getDouble()
                 throws NullPointerException
gets a double value.

Throws:
NullPointerException

getBoolean

public boolean getBoolean()
                   throws NullPointerException
gets a boolean value.

Throws:
NullPointerException

getBytes

public byte[] getBytes()
                throws NullPointerException
gets a byte array.

Throws:
NullPointerException

setBytes

public void setBytes(byte[] bytes)
set the byte array.


setString

public void setString(String str)
set the byte array to a string.


setString

public void setString(String str,
                      String charsetName)
               throws UnsupportedEncodingException
Throws:
UnsupportedEncodingException

setUnicode

void setUnicode(boolean isUnicode)
Sets the isUnicode flag; this is non-public because it is private to TupleData initialization.


isUnicode

public boolean isUnicode()
Whether character data is stored as Unicode.