Records

Records carry the ID and the user data of a message. The payload is transported in a list of slots.

The following constructors exist:

CRecord(final IId aId);

CRecord(final CRecord aTemplate);

There is also a factory method:

static CRecord createFromStream(final DataInputStream aStream) throws IOException;

Record ID

The ID is of the type: ref: IId <ID> and can consist of an integer, a string or a UUID:

IId getId();

void setId(final IId aId);

Accessing the Slots

Slots are kept in the record in a map. They can be set using the following methods:

// Adding a single slot. aKey can be SlotKey or a component.
ISlot addSlot(final Object aKey,
              final ISlot aSlot);

// Transfer from a template.
void takeSlots(final CRecord aRecord);

Removal of slots is also possible:

void removeSlot(final ISlotKey aKey);

The following access methods exist:

// aKey can be SlotKey or a component
ISlot getSlot(final Object aKey);

// incl. check of type; wrong type --> CException
ISlot getSlot(final ISlotKey aKey,
              final CSlotType aType) throws CException;

// get all slots
Map<ISlotKey, ISlot> getSlots();

// check if slot exists
boolean exist(final ISlotKey aKey);

// Number of slots
int size();

There are separate methods for accessing the value of a slot:

Object getValue(final ISlotKey aKey);

// incl. default value
Object getValue(final ISlotKey aKey,
                final Object aDefaultValue);

// incl. check of type; wrong type --> CException
Object getValue(final ISlotKey aKey,
                final CSlotType aType) throws CException;

// incl. check of type; wrong type --> CException
Object getValue(final ISlotKey aKey,
                final CSlotType aType,
                final Object aDefaultValue) throws CException;

Here you can clearly see that an untyped object is returned, so you have to cast it yourself. This can be avoided by using the static access classes of the Record-Generator.

A check of the slot type is of course possible at any time:

CSlotType getSlotType(final ISlotKey aKey);

Or:

ISlot slot = getSlot(aKey);
CSlotType type = slot.getType();

It is also possible to set the value directly:

void setValue(final ISlotKey aKey,
              final CSlotType aType,
              final Object aValue) throws CException;

// in case of an error the error will only be logged
void setValueSafe(final ISlotKey aKey,
                  final CSlotType aType,
                  final Object aValue);

Further Methods

The following methods are available:

// The current version is always 0
getVersion();

// Writing to a stream
void toStream(final DataOutputStream aStream) throws IOException;

// resets ID, removes all slots
void clear();

// removes all slots
void clearSlots();