DataRecord Elements

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.

import osmq.records.DataRecordBean;
DataRecord  myrecord = new DataRecordBean(3);

Getters and Setters

DaraRecord 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);
myrecord.setInt(123, 2);
myrecord.setDouble(55.6, 3);

Similarly, there are corresponding getter functions for retrieving elements in native data formats:
String s = myrecord.getString(1);
int i = myrecord.getInt(2);
double d = myrecord.getDouble(3);

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 Representation

The 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.6
There are public functions that return the delimited element representation as a String or byte array:
byte[] getBytes();
String getText();
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);
void setBytes(byte[] value);