A DataRecord is a class that supports multiple elements of differing data types. It is useful for passing record-oriented information between function in the same program or across a network.
The following code shows how to instantiate a DataRecord with 3 elements.
Getters and SettersDaraRecord elements (fields) are referenced by their relative position. The API for setting and setting record elements is based on the API used by JDBC for referencing columns in a database. The DataRecord class supports pairs of getters and setters to set or retrive element values in various data representations. The follow code utizes setter functions to initialize the fields of a three-element record:
myrecord.setString("Hello", 1);Similarly, there are corresponding getter functions for retrieving elements in native data formats:
String s = myrecord.getString(1);The DataRecord class provides public getter/setter pairs of functions for Boolean, byte, char, String, int, long, short, double, BigDecimal and Date data types.
Internal RepresentationThe internal representation of the DataRecord elements is a delimited string. The delimiter character (normally the pipe character) is the first character in the string, and is used to delimit each element:
|Hello|123|55.6There are public functions that return the delimited element representation as a String or byte array:
byte getBytes();Similarly, there are functions to set the DataRecord's elements to the values contained in a delimited string or delimited byte array:
void setText(String value);