cdev.data
Class DataEntry

java.lang.Object
  |
  +--cdev.data.DataEntry

public final class DataEntry
extends java.lang.Object
implements java.lang.Cloneable


Constructor Summary
DataEntry(int newkey, byte d)
          Construct a DataEntry from a byte
DataEntry(int newkey, double d)
          Construct a DataEntry from a double
DataEntry(int newkey, float d)
          Construct a DataEntry from a float
DataEntry(int newkey, int d)
          Construct a DataEntry from a int
DataEntry(int newKey, int newType, int[] newDims)
          Construct a DataEntry with specified key, dimensions, and type.
DataEntry(int newkey, long d)
          Construct a DataEntry from a long
DataEntry(int newkey, java.lang.Object d)
          Construct a DataEntry from an object.
DataEntry(int newkey, short d)
          Construct a DataEntry from a short
 
Method Summary
 byte[] byteArray()
          Return the data as an array of bytes.
 byte byteValue()
          Get a byte from the DataEntry.
 java.lang.Object clone()
          Creates a new object whose content is a full copy of this data entry.
 double[] doubleArray()
          Return the data as an array of doubles.
 double doubleValue()
          Get a double from the DataEntry.
 float[] floatArray()
          Return the data as an array of floats.
 float floatValue()
          Get a float from the DataEntry.
 java.lang.Class getComponentType()
          Get the component data type (returns the Class).
 int getDim()
          Get the number of dimensions.
 int[] getDimensions()
          Get the array of dimensions.
 int getEnumeratedType()
          Get the enumerated data type (returns an int type).
 int getKey()
          Get the integer key.
 java.lang.String getKeyAsString()
          Get the key as a String.
 java.lang.Object getValue()
          Get the contained data.
 int[] intArray()
          Return the data as an array of integers.
 int intValue()
          Get an integer from the DataEntry.
 long[] longArray()
          Return the data as an array of longs.
 long longValue()
          Get a long from the DataEntry.
 int nelems()
          Get the number of elements in the data array (if scalar, return 1).
 int setKey(int ikey)
          Change the integer key, and return the old key.
 short[] shortArray()
          Return the data as an array of shorts.
 short shortValue()
          Get a short from the DataEntry.
 DataEntry smartCompareCopy(DataEntry dst)
          Performs a compare & copy on the content of a data entry.
 java.lang.String[] stringArray()
          Return the data as an array of Strings.
 java.lang.String stringValue()
          Return the string value of data in this DataEntry object.
 java.lang.String toString()
          Convert the entire DataEntry object to a string.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataEntry

public DataEntry(int newkey,
                 java.lang.Object d)
Construct a DataEntry from an object. Valid object types are only [multidimensional] arrays of either primitive numeric type or String.

DataEntry

public DataEntry(int newkey,
                 double d)
Construct a DataEntry from a double

DataEntry

public DataEntry(int newkey,
                 float d)
Construct a DataEntry from a float

DataEntry

public DataEntry(int newkey,
                 long d)
Construct a DataEntry from a long

DataEntry

public DataEntry(int newkey,
                 int d)
Construct a DataEntry from a int

DataEntry

public DataEntry(int newkey,
                 short d)
Construct a DataEntry from a short

DataEntry

public DataEntry(int newkey,
                 byte d)
Construct a DataEntry from a byte

DataEntry

public DataEntry(int newKey,
                 int newType,
                 int[] newDims)
          throws java.lang.IllegalArgumentException
Construct a DataEntry with specified key, dimensions, and type. If array of dimensions is null, create a DataEntry with an array with one element as data.
Parameters:
newKey - The key of DataEntry
newType - an int for the type
newDims - an array of int for the array of dimensions
Throws:
java.lang.IllegalArgumentException - if invalid type
Method Detail

getDimensions

public int[] getDimensions()
Get the array of dimensions. Returns null if data is scalar.

getDim

public int getDim()
Get the number of dimensions.

getKey

public int getKey()
Get the integer key.

getKeyAsString

public java.lang.String getKeyAsString()
Get the key as a String.

setKey

public int setKey(int ikey)
Change the integer key, and return the old key.

getComponentType

public java.lang.Class getComponentType()
Get the component data type (returns the Class).

getEnumeratedType

public int getEnumeratedType()
Get the enumerated data type (returns an int type).

nelems

public int nelems()
Get the number of elements in the data array (if scalar, return 1).

getValue

public java.lang.Object getValue()
Get the contained data.

doubleValue

public double doubleValue()
Get a double from the DataEntry. An Exception will be thrown if the requested conversion is not possible.

floatValue

public float floatValue()
Get a float from the DataEntry. An Exception will be thrown if the requested conversion is not possible.

longValue

public long longValue()
Get a long from the DataEntry. An Exception will be thrown if the requested conversion is not possible.

intValue

public int intValue()
Get an integer from the DataEntry. An Exception will be thrown if the requested conversion is not possible.

shortValue

public short shortValue()
Get a short from the DataEntry. An Exception will be thrown if the requested conversion is not possible.

byteValue

public byte byteValue()
Get a byte from the DataEntry. An Exception will be thrown if the requested conversion is not possible.

stringValue

public java.lang.String stringValue()
Return the string value of data in this DataEntry object.

doubleArray

public double[] doubleArray()
Return the data as an array of doubles.

floatArray

public float[] floatArray()
Return the data as an array of floats.

intArray

public int[] intArray()
Return the data as an array of integers.

shortArray

public short[] shortArray()
Return the data as an array of shorts.

longArray

public long[] longArray()
Return the data as an array of longs.

byteArray

public byte[] byteArray()
Return the data as an array of bytes.

stringArray

public java.lang.String[] stringArray()
Return the data as an array of Strings.

toString

public java.lang.String toString()
Convert the entire DataEntry object to a string. The resulting string will contain tag, tag name, data type, and, when applicable, dimensions. If the data is scalar, it will be appended as well. If data is 1D array, the first 8 elements will be appended.
Overrides:
toString in class java.lang.Object

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException,
                              java.lang.IllegalArgumentException
Creates a new object whose content is a full copy of this data entry. Executes a deep copy of the contents of this data entry.
Throws:
java.lang.CloneNotSupportedException - if the value is not of one of the supported data types.

smartCompareCopy

public final DataEntry smartCompareCopy(DataEntry dst)
                                 throws java.lang.CloneNotSupportedException
Performs a compare & copy on the content of a data entry. This data entry is compared with a specified destination data entry. If this data entry and the destination one don't have the same structure: same dimensions and same component type, the comparison fails and a clone of this data entry is returned. Otherwise, the contents of the two data entries are compared and the contents of this data entry is copied into the destination one. The keys are not compared.
Parameters:
dst - The destination data entry. If null, a clone of this data entry is returned.
Returns:
null if the comparison succeeds. Otherwise: either the destination data entry or a new clone of this data entry.
See Also:
clone()