cern.cmw
Class DataEntry

java.lang.Object
  extended by cern.cmw.DataEntry
All Implemented Interfaces:
Serializable

public class DataEntry
extends Object
implements Serializable

Objects of this class serve as containers that can hold a value of different types. The contained values can be single instances or single-dimensional arrays of the types listed in the table below. A DataEntry object stores the value type code along with the value. Since the data entry objects can be passed between C++ and Java applications, the table provides also the correspondance between C++ and Java types.

type name C++ type Java type
Boolean bool boolean
Byte signed char byte
Short short short
Int long int
Long long long long
Float float float
Double double double
String null-terminated string String
A large part of the DataEntry API consists of the methods for inserting values into and extracting values from a data entry. For a given type X, these methods are:
void insert(X x)
This method allows the insertion of a scalar value of type X.
void insert(X[] x)
Same for an array of values of type X.
X extractX()
This method allows the extraction of a scalar value of type X. Throws TypeMismatch if the type of the element contained in the entry is not X.
X[] extractXArray()
Same for an array of values of type X. Thes method throws TypeMismatch if the entry contains something other than an array of type X, or nothing.
The DataEntry class is not thread-safe: multiple threads cannot share a single DataEntry object without the need for external synchronization. A DataEntry object is used as a component of a Data object.

See Also:
Serialized Form

Field Summary
static int TYPE_BOOLEAN
          Indicates a boolean value.
static int TYPE_BOOLEAN_ARRAY
          Indicates a boolean array value.
static int TYPE_BYTE
          Indicates a byte value.
static int TYPE_BYTE_ARRAY
          Indicates a byte array value.
static int TYPE_DOUBLE
          Indicates a double value.
static int TYPE_DOUBLE_ARRAY
          Indicates a double array value.
static int TYPE_FLOAT
          Indicates a float value.
static int TYPE_FLOAT_ARRAY
          Indicates a float array value.
static int TYPE_INT
          Indicates an int value.
static int TYPE_INT_ARRAY
          Indicates an int array value.
static int TYPE_LONG
          Indicates a long value.
static int TYPE_LONG_ARRAY
          Indicates a long array value.
static int TYPE_NULL
          Indicates that a DataEntry does not contain anything.
static int TYPE_SHORT
          Indicates a short value.
static int TYPE_SHORT_ARRAY
          Indicates a short array value.
static int TYPE_STRING
          Indicates a String value.
static int TYPE_STRING_ARRAY
          Indicates a String array value.
 
Constructor Summary
DataEntry()
          Creates an empty DataEntry.
 
Method Summary
 DataEntry copy()
          Creates and returns a copy of this DataEntry.
 boolean equals(DataEntry entry)
          Returns true if this DataEntry has the same contents (same data type and same value) as the specified entry; false otherwise.
 boolean extractBoolean()
          Returns the boolean stored in this DataEntry object.
 boolean[] extractBooleanArray()
          Returns the boolean array stored in this DataEntry object.
 byte extractByte()
          Returns the byte stored in this DataEntry object.
 byte[] extractByteArray()
          Returns the byte array stored in this DataEntry object.
 double extractDouble()
          Returns the double stored in this DataEntry object.
 double[] extractDoubleArray()
          Returns the double array stored in this DataEntry object.
 float extractFloat()
          Returns the float stored in this DataEntry object.
 float[] extractFloatArray()
          Returns the float array stored in this DataEntry object.
 int extractInt()
          Returns the int stored in this DataEntry object.
 int[] extractIntArray()
          Returns the int array stored in this DataEntry object.
 long extractLong()
          Returns the long stored in this DataEntry object.
 long[] extractLongArray()
          Returns the long array stored in this DataEntry object.
 Object extractObject()
          Returns the Object internally stored.
 short extractShort()
          Returns the short stored in this DataEntry object.
 short[] extractShortArray()
          Returns the short array stored in this DataEntry object.
 String extractString()
          Returns the String stored in this DataEntry object.
 String[] extractStringArray()
          Returns the String array stored in this DataEntry object.
 int getValueType()
          Returns type code for the value contained in this DataEntry object.
 void insert(boolean value)
          Inserts a boolean value into this DataEntry object.
 void insert(boolean[] value)
          Inserts a boolean array value into this DataEntry object.
 void insert(byte value)
          Inserts a byte value into this DataEntry object.
 void insert(byte[] value)
          Inserts a byte array value into this DataEntry object.
 void insert(double value)
          Inserts a double value into this DataEntry object.
 void insert(double[] value)
          Inserts a double array value into this DataEntry object.
 void insert(float value)
          Inserts a float value into this DataEntry object.
 void insert(float[] value)
          Inserts a float array value into this DataEntry object.
 void insert(int value)
          Inserts an int value into this DataEntry object.
 void insert(int[] value)
          Inserts an int array value into this DataEntry object.
 void insert(long value)
          Inserts a long value into this DataEntry object.
 void insert(long[] value)
          Inserts a long array value into this DataEntry object.
 void insert(Object val)
          Inserts an Object into this DataEntry, after checking that it is of one of the allowable types (Boolean, Byte, Short, Integer, Long, Float, Double, String) or arrays thereof.
 void insert(short value)
          Inserts a short value into this DataEntry object.
 void insert(short[] value)
          Inserts a short array value into this DataEntry object.
 void insert(String value)
          Inserts a String value into this DataEntry object.
 void insert(String[] value)
          Inserts a String array value into this DataEntry object.
 String toString()
          Returns a string representation of this DataEntry object.
 String toString(int maxElements)
          Returns a string representation of this DataEntry object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE_NULL

public static final int TYPE_NULL
Indicates that a DataEntry does not contain anything. For example, if you default-construct a DataEntry, the initial type code is TYPE_NULL.

See Also:
Constant Field Values

TYPE_BOOLEAN

public static final int TYPE_BOOLEAN
Indicates a boolean value.

See Also:
Constant Field Values

TYPE_BOOLEAN_ARRAY

public static final int TYPE_BOOLEAN_ARRAY
Indicates a boolean array value.

See Also:
Constant Field Values

TYPE_BYTE

public static final int TYPE_BYTE
Indicates a byte value.

See Also:
Constant Field Values

TYPE_BYTE_ARRAY

public static final int TYPE_BYTE_ARRAY
Indicates a byte array value.

See Also:
Constant Field Values

TYPE_SHORT

public static final int TYPE_SHORT
Indicates a short value.

See Also:
Constant Field Values

TYPE_SHORT_ARRAY

public static final int TYPE_SHORT_ARRAY
Indicates a short array value.

See Also:
Constant Field Values

TYPE_INT

public static final int TYPE_INT
Indicates an int value.

See Also:
Constant Field Values

TYPE_INT_ARRAY

public static final int TYPE_INT_ARRAY
Indicates an int array value.

See Also:
Constant Field Values

TYPE_LONG

public static final int TYPE_LONG
Indicates a long value.

See Also:
Constant Field Values

TYPE_LONG_ARRAY

public static final int TYPE_LONG_ARRAY
Indicates a long array value.

See Also:
Constant Field Values

TYPE_FLOAT

public static final int TYPE_FLOAT
Indicates a float value.

See Also:
Constant Field Values

TYPE_FLOAT_ARRAY

public static final int TYPE_FLOAT_ARRAY
Indicates a float array value.

See Also:
Constant Field Values

TYPE_DOUBLE

public static final int TYPE_DOUBLE
Indicates a double value.

See Also:
Constant Field Values

TYPE_DOUBLE_ARRAY

public static final int TYPE_DOUBLE_ARRAY
Indicates a double array value.

See Also:
Constant Field Values

TYPE_STRING

public static final int TYPE_STRING
Indicates a String value.

See Also:
Constant Field Values

TYPE_STRING_ARRAY

public static final int TYPE_STRING_ARRAY
Indicates a String array value.

See Also:
Constant Field Values
Constructor Detail

DataEntry

public DataEntry()
Creates an empty DataEntry.

Method Detail

copy

public DataEntry copy()
Creates and returns a copy of this DataEntry.


equals

public boolean equals(DataEntry entry)
Returns true if this DataEntry has the same contents (same data type and same value) as the specified entry; false otherwise. Always returns false if the entry argument is null


insert

public void insert(boolean value)
Inserts a boolean value into this DataEntry object.


insert

public void insert(byte value)
Inserts a byte value into this DataEntry object.


insert

public void insert(short value)
Inserts a short value into this DataEntry object.


insert

public void insert(int value)
Inserts an int value into this DataEntry object.


insert

public void insert(long value)
Inserts a long value into this DataEntry object.


insert

public void insert(float value)
Inserts a float value into this DataEntry object.


insert

public void insert(double value)
Inserts a double value into this DataEntry object.


insert

public void insert(String value)
Inserts a String value into this DataEntry object.


insert

public void insert(boolean[] value)
Inserts a boolean array value into this DataEntry object.


insert

public void insert(byte[] value)
Inserts a byte array value into this DataEntry object.


insert

public void insert(short[] value)
Inserts a short array value into this DataEntry object.


insert

public void insert(int[] value)
Inserts an int array value into this DataEntry object.


insert

public void insert(long[] value)
Inserts a long array value into this DataEntry object.


insert

public void insert(float[] value)
Inserts a float array value into this DataEntry object.


insert

public void insert(double[] value)
Inserts a double array value into this DataEntry object.


insert

public void insert(String[] value)
Inserts a String array value into this DataEntry object.


getValueType

public int getValueType()
Returns type code for the value contained in this DataEntry object. The return value can be one of the TYPE_X constants defined in the DataEntry class.

See Also:
TYPE_NULL, TYPE_BOOLEAN, TYPE_BOOLEAN_ARRAY, TYPE_BYTE, TYPE_BYTE_ARRAY, TYPE_SHORT, TYPE_SHORT_ARRAY, TYPE_INT, TYPE_INT_ARRAY, TYPE_LONG, TYPE_LONG_ARRAY, TYPE_FLOAT, TYPE_FLOAT_ARRAY, TYPE_DOUBLE, TYPE_DOUBLE_ARRAY, TYPE_STRING, TYPE_STRING_ARRAY

extractBoolean

public boolean extractBoolean()
                       throws TypeMismatch
Returns the boolean stored in this DataEntry object.

Throws:
TypeMismatch - thrown if this DataEntry contains something other than a boolean, or nothing.

extractBooleanArray

public boolean[] extractBooleanArray()
                              throws TypeMismatch
Returns the boolean array stored in this DataEntry object.

Throws:
TypeMismatch - thrown if this DataEntry contains something other than a boolean array, or nothing.

extractByte

public byte extractByte()
                 throws TypeMismatch
Returns the byte stored in this DataEntry object.

Throws:
TypeMismatch - thrown if this DataEntry contains something other than a byte, or nothing.

extractByteArray

public byte[] extractByteArray()
                        throws TypeMismatch
Returns the byte array stored in this DataEntry object.

Throws:
TypeMismatch - thrown if this DataEntry contains something other than a byte array, or nothing.

extractShort

public short extractShort()
                   throws TypeMismatch
Returns the short stored in this DataEntry object.

Throws:
TypeMismatch - thrown if this DataEntry contains something other than a short, or nothing.

extractShortArray

public short[] extractShortArray()
                          throws TypeMismatch
Returns the short array stored in this DataEntry object.

Throws:
TypeMismatch - thrown if this DataEntry contains something other than a short array, or nothing.

extractInt

public int extractInt()
               throws TypeMismatch
Returns the int stored in this DataEntry object.

Throws:
TypeMismatch - thrown if this DataEntry contains something other than an int, or nothing.

extractIntArray

public int[] extractIntArray()
                      throws TypeMismatch
Returns the int array stored in this DataEntry object.

Throws:
TypeMismatch - thrown if this DataEntry contains something other than an int array or nothing.

extractLong

public long extractLong()
                 throws TypeMismatch
Returns the long stored in this DataEntry object.

Throws:
TypeMismatch - thrown if this DataEntry contains something other than a long, or nothing.

extractLongArray

public long[] extractLongArray()
                        throws TypeMismatch
Returns the long array stored in this DataEntry object.

Throws:
TypeMismatch - thrown if this DataEntry contains something other than a long array, or nothing.

extractFloat

public float extractFloat()
                   throws TypeMismatch
Returns the float stored in this DataEntry object.

Throws:
TypeMismatch - thrown if this DataEntry contains something other than a float, or nothing.

extractFloatArray

public float[] extractFloatArray()
                          throws TypeMismatch
Returns the float array stored in this DataEntry object.

Throws:
TypeMismatch - thrown if this DataEntry contains something other than a float array or nothing.

extractDouble

public double extractDouble()
                     throws TypeMismatch
Returns the double stored in this DataEntry object.

Throws:
TypeMismatch - thrown if this DataEntry contains something other than a double, or nothing.

extractDoubleArray

public double[] extractDoubleArray()
                            throws TypeMismatch
Returns the double array stored in this DataEntry object.

Throws:
TypeMismatch - thrown if this DataEntry contains something other than a double array or nothing.

extractString

public String extractString()
                     throws TypeMismatch
Returns the String stored in this DataEntry object.

Throws:
TypeMismatch - thrown if this DataEntry contains something other than a String, or nothing.

extractStringArray

public String[] extractStringArray()
                            throws TypeMismatch
Returns the String array stored in this DataEntry object.

Throws:
TypeMismatch - thrown if this DataEntry contains something other than a String array or nothing.

insert

public void insert(Object val)
            throws IllegalArgumentException
Inserts an Object into this DataEntry, after checking that it is of one of the allowable types (Boolean, Byte, Short, Integer, Long, Float, Double, String) or arrays thereof.

Throws:
IllegalArgumentException - thrown if the inserted value is not of one of the supported types.

extractObject

public Object extractObject()
Returns the Object internally stored.


toString

public String toString()
Returns a string representation of this DataEntry object. This call is equivalent to toString(100).

Overrides:
toString in class Object
See Also:
toString(int)

toString

public String toString(int maxElements)
Returns a string representation of this DataEntry object. For array values, not more then the specified number of elements will be included in the string.



Copyright © 2007 CERN. All Rights Reserved.