edu.unh.sdb.common
Class MixedDatum

java.lang.Object
  extended by edu.unh.sdb.common.Datum
      extended by edu.unh.sdb.common.MixedDatum

public class MixedDatum
extends Datum

Represent multiple data values for a single point. This implementation stores values as an array of bytes.


Constructor Summary
MixedDatum(Datum d)
          Copy Constructor creates a copy of the argument datum.
MixedDatum(Datum[] datums)
          This constructor creates a single MixedDatum from an array of Datums.
MixedDatum(float[] vals)
          Deprecated.  
MixedDatum(int numvalues)
          Deprecated.  
MixedDatum(int[] vals)
          Deprecated.  
MixedDatum(MixedDatum d)
          Copy Constructor creates a copy of the argument datum.
MixedDatum(MixedDatum[] datums)
          This constructor creates a single MixedDatum from an array of datums.
MixedDatum(RecordDescriptor rd)
          Creates a Datum based on a RecordDescriptor.
MixedDatum(RecordDescriptor rd, byte[] values, int startIndex)
          Creates a datum by copying a subset of values from an array.
 
Method Summary
 void assign(byte[] data)
          Copy the values in the argument to this datum.
 void assign(byte[] data, int startIndex)
          Assigns values to an existing datum by copying values from a portion of an array.
 void assign(byte[] values, int startIndex, int numAttributes)
          Assigns values to an existing datum by copying values from a portion of an array.
 int byteSize()
          Return the size in bytes needed to store the data for the attributes.
 java.lang.Object clone()
          Return a copy of this datum.
 void copyTo(Datum d)
          Copy the values of this MixedDatum object into the argument datum.
 void copyTo(MixedDatum d)
          Copy the values of this MixedDatum object into the argument datum.
 boolean equals(java.lang.Object o)
          Determine if the argument is a MixedDatum with the same set of data values.
 byte getByte(int i)
          Return the field specified by the argument as a byte.
 double getDouble(int i)
          Return the field specified by the argument as a double.
 float getFloat(int i)
          Return the field specified by the argument as a float.
 int getInt(int i)
          Return the field specified by the argument as a int.
 RecordDescriptor getRecordDescriptor()
          Return the RecordDescriptor associated with MixedDatum.
 short getShort(int i)
          Return the field specified by the argument as a short.
 int getStorageType()
          Return the StorageType for this Datum
 Values getValues()
          Return all attributes of the Datum as a Values object
 void setByte(int i, byte v)
          Set the attribute indicated by the first argument to the value of the second argument.
 void setBytes(byte[] newVals)
          Copy the values in the argument array to this datum.
 void setDouble(int i, double v)
          Set the attribute indicated by the first argument to the value of the second argument.
 void setFloat(int i, float v)
          Set the attribute indicated by the first argument to the value of the second argument.
 void setInt(int i, int v)
          Set the attribute indicated by the first argument to the value of the second argument.
 void setShort(int i, short v)
          Set the attribute indicated by the first argument to the value of the second argument.
 int size()
          Return the number of attributes in the datum.
 void subset(Datum d, RecordSpec spec)
          Copy the attributes specified by the RecordSpec into the argument datum.
 void subset(MixedDatum d, RecordSpec spec)
          Copy the attributes specified by the RecordSpec into the argument datum.
 Datum subset(RecordSpec spec)
          Return a new datum with the attributes indicated by the RecordSpec.
 java.lang.String toString()
          Return a string representation of the datum.
 
Methods inherited from class edu.unh.sdb.common.Datum
create, create, create, create, create, create, create, create, create, create, create, create, getBytes, getBytes, getBytes, getDoubles, getDoubles, getFloats, getFloats, getInts, getInts, getNumAttributes, getShorts, getShorts, setBytes, setBytes, setDoubles, setDoubles, setDoubles, setFloats, setFloats, setFloats, setInts, setInts, setInts, setShorts, setShorts, setShorts
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MixedDatum

public MixedDatum(RecordDescriptor rd)
Creates a Datum based on a RecordDescriptor. This is the standard way of creating a MixedDatum.

Parameters:
rd - A RecordDescriptor describing all the fields of the Datum

MixedDatum

public MixedDatum(int numvalues)
Deprecated. 

Creates a null datum with the specified number of values. The fields will all be set to float (for now).


MixedDatum

public MixedDatum(float[] vals)
Deprecated. 

Creates a datum with attributes containing the argument values.


MixedDatum

public MixedDatum(RecordDescriptor rd,
                  byte[] values,
                  int startIndex)
Creates a datum by copying a subset of values from an array. The 3rd argument specifies where to start copying; we copy enough bytes to match the data size from the RecordDescriptor.


MixedDatum

public MixedDatum(int[] vals)
Deprecated. 

Creates a datum with attributes containing the argument values.


MixedDatum

public MixedDatum(MixedDatum d)
Copy Constructor creates a copy of the argument datum.


MixedDatum

public MixedDatum(Datum d)
Copy Constructor creates a copy of the argument datum.


MixedDatum

public MixedDatum(MixedDatum[] datums)
This constructor creates a single MixedDatum from an array of datums. The Datums in the array are copied in the order they are given.


MixedDatum

public MixedDatum(Datum[] datums)
This constructor creates a single MixedDatum from an array of Datums. The Datums in the array are copied in the order they are given.

Method Detail

clone

public java.lang.Object clone()
Return a copy of this datum.

Specified by:
clone in class Datum

copyTo

public void copyTo(MixedDatum d)
Copy the values of this MixedDatum object into the argument datum.


copyTo

public void copyTo(Datum d)
Copy the values of this MixedDatum object into the argument datum.

Specified by:
copyTo in class Datum

assign

public void assign(byte[] data)
Copy the values in the argument to this datum.


assign

public void assign(byte[] data,
                   int startIndex)
Assigns values to an existing datum by copying values from a portion of an array. The second argument indicates where to start the copy. We try to copy enough data to fill the Datum. If the input array or this object contain too few attributes, an error is generated.


assign

public void assign(byte[] values,
                   int startIndex,
                   int numAttributes)
Assigns values to an existing datum by copying values from a portion of an array. The second argument indicates where to start the copy, the 3rd indicates the number of attributes to copy (as opposed to the number of bytes!) If the input array or this object contain too few attributes, an error is generated.


equals

public boolean equals(java.lang.Object o)
Determine if the argument is a MixedDatum with the same set of data values.

Overrides:
equals in class java.lang.Object

setDouble

public void setDouble(int i,
                      double v)
Set the attribute indicated by the first argument to the value of the second argument.

Specified by:
setDouble in class Datum

setFloat

public void setFloat(int i,
                     float v)
Set the attribute indicated by the first argument to the value of the second argument.

Specified by:
setFloat in class Datum

setInt

public void setInt(int i,
                   int v)
Set the attribute indicated by the first argument to the value of the second argument.

Specified by:
setInt in class Datum

setShort

public void setShort(int i,
                     short v)
Set the attribute indicated by the first argument to the value of the second argument.

Specified by:
setShort in class Datum

setByte

public void setByte(int i,
                    byte v)
Set the attribute indicated by the first argument to the value of the second argument.

Specified by:
setByte in class Datum

getDouble

public double getDouble(int i)
Return the field specified by the argument as a double.

Specified by:
getDouble in class Datum

getFloat

public float getFloat(int i)
Return the field specified by the argument as a float.

Specified by:
getFloat in class Datum

getInt

public int getInt(int i)
Return the field specified by the argument as a int.

Specified by:
getInt in class Datum

getShort

public short getShort(int i)
Return the field specified by the argument as a short.

Specified by:
getShort in class Datum

getByte

public byte getByte(int i)
Return the field specified by the argument as a byte.

Specified by:
getByte in class Datum

setBytes

public void setBytes(byte[] newVals)
Description copied from class: Datum
Copy the values in the argument array to this datum. The array length should be <= the number of attributes in the datum.

Overrides:
setBytes in class Datum

getValues

public Values getValues()
Return all attributes of the Datum as a Values object

Specified by:
getValues in class Datum

subset

public Datum subset(RecordSpec spec)
Return a new datum with the attributes indicated by the RecordSpec. The values of these attributes are taken from this MixedDatum object.

Specified by:
subset in class Datum

subset

public void subset(MixedDatum d,
                   RecordSpec spec)
Copy the attributes specified by the RecordSpec into the argument datum.


subset

public void subset(Datum d,
                   RecordSpec spec)
Copy the attributes specified by the RecordSpec into the argument datum.

Specified by:
subset in class Datum

toString

public java.lang.String toString()
Return a string representation of the datum.

Overrides:
toString in class java.lang.Object

size

public int size()
Return the number of attributes in the datum.

Specified by:
size in class Datum

byteSize

public int byteSize()
Return the size in bytes needed to store the data for the attributes.

Specified by:
byteSize in class Datum

getStorageType

public int getStorageType()
Return the StorageType for this Datum

Specified by:
getStorageType in class Datum

getRecordDescriptor

public RecordDescriptor getRecordDescriptor()
Return the RecordDescriptor associated with MixedDatum.