cdev.data
Class Data

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

public class Data
extends java.lang.Object
implements java.lang.Cloneable

A container class for storing DataEntry objects accessed via either String or int keys.


Field Summary
static short BYTE
           
static short DOUBLE
           
static short FLOAT
           
static short INT
           
static short INVALID
           
static short LONG
           
static int MAXTYPE
           
static short SHORT
           
static short STRING
           
static int VALUE_KEY
           
 
Constructor Summary
Data()
          Construct an empty Data object.
Data(Data original)
          Shallow Copy Constructor.
Data(xdrReader in)
          Construct a Data object given the byte stream in an xdrReader object.
 
Method Summary
 void addDataEntry(DataEntry entry)
          Add a data entry to this container.
 void changeKey(int oldkey, int newkey)
          Change the key for an existing data entry.
 java.lang.Object clone()
          clone(): performs a deep copy of a Data Object
 boolean containsKey(int key)
          Test to see if the specified key is in the Data object.
 boolean containsKey(java.lang.String key)
          Test to see if the specified key is in the Data object.
static java.lang.String convertKey(int key)
          Get the string equivalent of an integer key.
static int convertKey(java.lang.String key)
          Get the integer equivalent of a string key.
 void copyInto(Data dst)
          Performs a copy of this Data into another destination Data.
 java.util.Enumeration elements()
          Get an Enumeration of all contained DataEntry objects.
 boolean equals(Data other)
          Perform a deep compare of 2 Data object to determine if they have the same data.
static java.lang.Class getClass(int dataType)
          Returns a Class from an integer data type
 DataEntry getDataEntry(int key)
          Return the DataEntry with the specified key, or null if not found.
 DataEntry getDataEntry(java.lang.String key)
          Return the DataEntry with the specified key, or null if not found.
 int getSize()
          Return the number of DataEntry objects in this Data object.
 java.lang.Object getValue(int key)
          Retrieves a data object specified by key from the specified DataEntry.
 java.lang.Object getValue(java.lang.String key)
          Retrieves a data object specified by key from the specified DataEntry.
 void insert(int tag, byte data)
          Insert a scalar value into a Data object as a tagged data item.
 void insert(int tag, double data)
          Insert a scalar value of type double into the Data object and give it the specified integer tag.
 void insert(int tag, float data)
          Insert a scalar value of type float into a Data object and give it the specified integer tag.
 void insert(int tag, int data)
          Insert a scalar value of type int into a Data object and give it the specified integer tag.
 void insert(int tag, long data)
          Insert a scalar value of type long into a Data object and give it the specified integer tag.
 void insert(int tag, java.lang.Object data)
          Insert an object into the Data object and give it the specified integer tag.
 void insert(int tag, short data)
          Insert a scalar value into a Data object as a tagged data item.
 void insert(java.lang.String tag, byte data)
          Insert "data" into the this cdev.Data object associated with "tag".
 void insert(java.lang.String tag, double data)
           
 void insert(java.lang.String tag, float data)
           
 void insert(java.lang.String tag, int data)
          Insert "data" into the this cdev.Data object associated with "tag".
 void insert(java.lang.String tag, long data)
           
 void insert(java.lang.String tag, java.lang.Object data)
           
 void insert(java.lang.String tag, short data)
          Insert "data" into the this cdev.Data object associated with "tag".
static void insertKeyPair(int key, java.lang.String skey)
          Insert a key pair into the table.
 void remove()
          Remove all DataEntry objects from this Data object.
 void remove(int key)
          Remove the data entry corresponding to a given key.
 void remove(java.lang.String key)
          Remove the data entry corresponding to a given key.
 java.lang.String toString()
          Convert the Data object to a formatted string.
 java.lang.String toString(java.lang.String title)
          Convert the Data object to a string with a given title preceeding the object.
 byte[] xdrExport()
           
 void xdrImport(xdrReader bin)
          Populate this Data object from a byte buffer which was written in XDR format.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INVALID

public static final short INVALID

BYTE

public static final short BYTE

SHORT

public static final short SHORT

INT

public static final short INT

LONG

public static final short LONG

FLOAT

public static final short FLOAT

DOUBLE

public static final short DOUBLE

STRING

public static final short STRING

MAXTYPE

public static final int MAXTYPE

VALUE_KEY

public static final int VALUE_KEY
Constructor Detail

Data

public Data()
Construct an empty Data object.

Data

public Data(xdrReader in)
     throws java.io.IOException
Construct a Data object given the byte stream in an xdrReader object.
Parameters:
in - - An xdrReader object that contains the byte stream.

Data

public Data(Data original)
Shallow Copy Constructor.
Parameters:
original - The original Data object to replicate.
Method Detail

convertKey

public static int convertKey(java.lang.String key)
Get the integer equivalent of a string key.
Parameters:
key - The String key.
Returns:
The integer key.

convertKey

public static java.lang.String convertKey(int key)
Get the string equivalent of an integer key.
Parameters:
key - The integer key.
Returns:
The String key.

insertKeyPair

public static void insertKeyPair(int key,
                                 java.lang.String skey)
Insert a key pair into the table.
Parameters:
key - The integer key.
skey - The string key.

getClass

public static java.lang.Class getClass(int dataType)
Returns a Class from an integer data type

getDataEntry

public DataEntry getDataEntry(int key)
                       throws java.lang.IllegalArgumentException
Return the DataEntry with the specified key, or null if not found.
Parameters:
key - The integer key.
Returns:
A DataEntry object that matches the integer tag.
See Also:
getDataEntry(int key)

getDataEntry

public DataEntry getDataEntry(java.lang.String key)
Return the DataEntry with the specified key, or null if not found.
Parameters:
tag - The String key.
See Also:
getDataEntry(String key)

containsKey

public boolean containsKey(int key)
Test to see if the specified key is in the Data object.
Returns:
true If the key exists in this Data object.

containsKey

public boolean containsKey(java.lang.String key)
Test to see if the specified key is in the Data object.
Returns:
true If the key exists in this Data object.

toString

public java.lang.String toString()
Convert the Data object to a formatted string.
Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(java.lang.String title)
Convert the Data object to a string with a given title preceeding the object.

addDataEntry

public void addDataEntry(DataEntry entry)
Add a data entry to this container.

remove

public void remove()
Remove all DataEntry objects from this Data object.

remove

public void remove(int key)
Remove the data entry corresponding to a given key. If the key is not found, do nothing.
Parameters:
key - Integer key.

remove

public void remove(java.lang.String key)
Remove the data entry corresponding to a given key. If the key is not found, do nothing.
Parameters:
key - String key.

insert

public void insert(int tag,
                   byte data)
Insert a scalar value into a Data object as a tagged data item. If the tag is in use, it is first removed!
Parameters:
tag - The tag to associate with the data item.
data - A byte data item.

insert

public void insert(int tag,
                   short data)
Insert a scalar value into a Data object as a tagged data item. If the tag is in use, it is first removed!
Parameters:
tag - The tag to associate with the data item.
data - A short data item.

insert

public void insert(int tag,
                   int data)
Insert a scalar value of type int into a Data object and give it the specified integer tag.
Parameters:
tag - The tag to associate with the data item.
data - An int data item to insert.

insert

public void insert(int tag,
                   long data)
Insert a scalar value of type long into a Data object and give it the specified integer tag. If the tag is used, the new item replaces the old item.
Parameters:
tag - The tag to associate with the data item.
data - the data item to insert.

insert

public void insert(int tag,
                   float data)
Insert a scalar value of type float into a Data object and give it the specified integer tag. If the tag is used, the new item replaces the old item.
Parameters:
tag - The tag to associate with the data item.
data - the data item to insert.

insert

public void insert(int tag,
                   double data)
Insert a scalar value of type double into the Data object and give it the specified integer tag. If the tag is used, the new item replaces the old item.
Parameters:
tag - The tag to associate with the data item.
data - the data item to insert.

insert

public void insert(int tag,
                   java.lang.Object data)
Insert an object into the Data object and give it the specified integer tag. If the tag is used, the new item replaces the old item.
Parameters:
tag - The tag to associate with the data item.
data - the data item to insert.

insert

public void insert(java.lang.String tag,
                   byte data)
Insert "data" into the this cdev.Data object associated with "tag".
Parameters:
tag - The string tag name to give the data
data - The byte data

insert

public void insert(java.lang.String tag,
                   short data)
Insert "data" into the this cdev.Data object associated with "tag".
Parameters:
tag - The string tag name to give the data
data - The short data

insert

public void insert(java.lang.String tag,
                   int data)
Insert "data" into the this cdev.Data object associated with "tag".
Parameters:
tag - The string tag name to give the data
data - The int data

insert

public void insert(java.lang.String tag,
                   long data)

insert

public void insert(java.lang.String tag,
                   float data)

insert

public void insert(java.lang.String tag,
                   double data)

insert

public void insert(java.lang.String tag,
                   java.lang.Object data)

changeKey

public void changeKey(int oldkey,
                      int newkey)
               throws java.lang.IllegalArgumentException
Change the key for an existing data entry. If the old one can not be not found, or the new tag already exists in this Data object, an IllegalArgumentException is thrown.
Parameters:
oldtag - The old tag number.
newtag - The new tag number.

getValue

public java.lang.Object getValue(int key)
Retrieves a data object specified by key from the specified DataEntry. If the key is not found, throws IllegalArgumentException.
Parameters:
key - The key of the selected entry.
Returns:
A reference to the contained data (array, Number, ...)

getValue

public java.lang.Object getValue(java.lang.String key)
Retrieves a data object specified by key from the specified DataEntry. If the key is not found, throws IllegalArgumentException.
Parameters:
key - The key of the selected entry.
Returns:
A reference to the contained data (array, Number, ...)

elements

public java.util.Enumeration elements()
Get an Enumeration of all contained DataEntry objects.

xdrImport

public void xdrImport(xdrReader bin)
               throws java.io.IOException
Populate this Data object from a byte buffer which was written in XDR format.

xdrExport

public byte[] xdrExport()

getSize

public int getSize()
Return the number of DataEntry objects in this Data object.

equals

public boolean equals(Data other)
Perform a deep compare of 2 Data object to determine if they have the same data. The comparison is performed by converting the data objects first to a byte streams then comparing the byte streams.

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
clone(): performs a deep copy of a Data Object
Returns:
the clone Object

copyInto

public void copyInto(Data dst)
              throws java.lang.CloneNotSupportedException
Performs a copy of this Data into another destination Data. DataEntries from this Data are copied into the destination Data. If the destination Data contains DataEntries with the same key, same type and same dimensions as this Data, the DataEntries of this Data will be copied into the destination Data ones, if not, they will be cloned. The DataEntries contained in the destination Data whose key is not the key of any DataEntry of this Data are not affected.
Parameters:
dst - The destination Data. Cannot be null.
See Also:
DataEntry.smartCompareCopy(DataEntry dst)