public final class CRecord
extends java.lang.Object
Constructor and Description |
---|
CRecord(CRecord aTemplate)
Copy constructor.
|
CRecord(IId aId)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
ISlot |
addSlot(java.lang.Object aKey,
ISlot aSlot)
Set a slot.
|
void |
clear()
Clear all data in the record.
|
void |
clearSlots()
Remove all slots, but not the ID.
|
static CRecord |
createFromStream(java.io.DataInputStream aStream)
Read a record from an input stream.
|
boolean |
equals(java.lang.Object aObj) |
boolean |
exist(ISlotKey aKey)
Check if a certain slot exist.
|
IId |
getId() |
ISlot |
getSlot(ISlotKey aKey,
CSlotType aType)
Get a slot and check it's type.
|
ISlot |
getSlot(java.lang.Object aKey)
Get a Slot.
|
java.util.Map<ISlotKey,ISlot> |
getSlots()
Get all slots as Map.
|
CSlotType |
getSlotType(ISlotKey aKey)
Get the slot type.
|
java.lang.Object |
getValue(ISlotKey aKey)
Get a data pool value by key.
|
java.lang.Object |
getValue(ISlotKey aKey,
CSlotType aType)
Get a data pool value by key.
|
java.lang.Object |
getValue(ISlotKey aKey,
CSlotType aType,
java.lang.Object aDefaultValue)
Get a data pool value by key.
|
java.lang.Object |
getValue(ISlotKey aKey,
java.lang.Object aDefaultValue)
Get a data pool value by key.
|
byte |
getVersion() |
int |
hashCode() |
void |
removeSlot(ISlotKey aKey)
Remove a slot.
|
void |
setId(IId aId)
Set the ID of the record.
|
static void |
setNameDb(INameDb aNameDb)
Internal method to set the name database.
|
static void |
setSlotFactory(ISlotFactory aFactory)
Internal method to set the slot factory.
|
void |
setValue(ISlotKey aKey,
CSlotType aType,
java.lang.Object aValue)
Set a value.
|
void |
setValueSafe(ISlotKey aKey,
CSlotType aType,
java.lang.Object aValue)
Set a value.
|
int |
size() |
void |
takeSlots(CRecord aRecord)
Add all slots from another record/message to this one.
|
void |
toStream(java.io.DataOutputStream aStream)
Write the record into a stream.
|
java.lang.String |
toString() |
public CRecord(CRecord aTemplate)
aTemplate
- The record template.public CRecord(IId aId)
aId
- The record ID.public static CRecord createFromStream(java.io.DataInputStream aStream) throws java.io.IOException
aStream
- The input stream.java.io.IOException
- on errorpublic static void setNameDb(INameDb aNameDb)
aNameDb
- The name database.public static void setSlotFactory(ISlotFactory aFactory)
aFactory
- The slot factory.public ISlot addSlot(java.lang.Object aKey, ISlot aSlot)
aKey
- The key of the slot.aSlot
- The slot.public void clear()
public void clearSlots()
public boolean equals(java.lang.Object aObj)
equals
in class java.lang.Object
public IId getId()
public ISlot getSlot(ISlotKey aKey, CSlotType aType) throws CException
aKey
- The key of the slot.aType
- The expected type of the slot.CException
- if the slot type was another one.public ISlot getSlot(java.lang.Object aKey)
CSlotType
.aKey
- The key of the slot.public java.util.Map<ISlotKey,ISlot> getSlots()
public CSlotType getSlotType(ISlotKey aKey)
aKey
- The key to find the slot.public java.lang.Object getValue(ISlotKey aKey)
aKey
- The key.public java.lang.Object getValue(ISlotKey aKey, CSlotType aType) throws CException
aKey
- The key.aType
- The expected data typeCException
- if the type does not match an existing slot.public java.lang.Object getValue(ISlotKey aKey, CSlotType aType, java.lang.Object aDefaultValue) throws CException
aKey
- The key.aType
- The expected data typeaDefaultValue
- If the record does not exist, this default value is returned.CException
- if the type does not match an existing slot.public java.lang.Object getValue(ISlotKey aKey, java.lang.Object aDefaultValue)
aKey
- The key.aDefaultValue
- If the record does not exist, this default value is returned.public byte getVersion()
public int hashCode()
hashCode
in class java.lang.Object
public boolean exist(ISlotKey aKey)
aKey
- The key of the slot.public void removeSlot(ISlotKey aKey)
aKey
- The key of the slot.public void setId(IId aId)
aId
- The ID.public void setValue(ISlotKey aKey, CSlotType aType, java.lang.Object aValue) throws CException
aKey
- The key of the slot.aType
- The type of the slot.aValue
- The value of the slot.CException
- on parsing the value.public void setValueSafe(ISlotKey aKey, CSlotType aType, java.lang.Object aValue)
aKey
- The key of the slot.aType
- The type of the slot.aValue
- The value of the slot.public int size()
public void takeSlots(CRecord aRecord)
aRecord
- The record.public void toStream(java.io.DataOutputStream aStream) throws java.io.IOException
aStream
- The output stream.java.io.IOException
- on error.public java.lang.String toString()
toString
in class java.lang.Object