public class GenericRecord extends java.lang.Object implements KeyedRecord, DataListener
| Modifier and Type | Class and Description |
|---|---|
class |
GenericRecord.ParseException
A runtime exception thrown while attempting to parse values stored as strings into an object of
the appropriate type.
|
| Modifier and Type | Field and Description |
|---|---|
protected java.util.Map<java.lang.String,java.lang.Object> |
ATTRIBUTE_TABLE
table of attributes by attribute ID
|
protected DataTable |
DATA_TABLE
data table to which this record belongs
|
| Constructor and Description |
|---|
GenericRecord(DataTable aTable)
Creates new GenericRecord
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
booleanValueForKey(java.lang.String key)
Convenience method to get the value as a boolean associated with the specified key.
|
java.lang.String |
dataLabel()
dataLabel() provides the name used to identify the class in an
external data source.
|
double |
doubleValueForKey(java.lang.String key)
Convenience method to get the value as a double associated with the specified key.
|
boolean |
hasAttributeForKey(java.lang.String key)
Determine whether this record has the specified attribute
|
int |
intValueForKey(java.lang.String key)
Convenience method to get the value as an int associated with the specified key.
|
java.util.Set<java.lang.String> |
keys()
Get the keys used in this record.
|
long |
longValueForKey(java.lang.String key)
Convenience method to get the value as a long associated with the specified key.
|
java.lang.Number |
numberForKey(java.lang.String key)
Convenience method to get the value cast as a number associated with the specified key.
|
void |
setValueForKey(boolean value,
java.lang.String key)
Set the boolean value to associate with the specified key.
|
void |
setValueForKey(double value,
java.lang.String key)
Set the double value to associate with the specified key.
|
void |
setValueForKey(int value,
java.lang.String key)
Set the int value to associate with the specified key.
|
void |
setValueForKey(long value,
java.lang.String key)
Set the long value to associate with the specified key.
|
void |
setValueForKey(java.lang.Object value,
java.lang.String key)
Set the value to associate with the specified key.
|
java.lang.String |
stringValueForKey(java.lang.String key)
Convenience method to get the value as a String associated with the specified key.
|
java.lang.String |
toString()
Overrides toString() to show key/value pairs.
|
void |
update(DataAdaptor adaptor)
Update the data based on the information provided by the data provider.
|
java.lang.Object |
valueForKey(java.lang.String key)
Get the value associated with the specified key.
|
java.util.Collection<java.lang.Object> |
values()
Get the collection of values held in this record.
|
void |
write(DataAdaptor adaptor)
Write data to the data adaptor for storage.
|
protected final DataTable DATA_TABLE
protected final java.util.Map<java.lang.String,java.lang.Object> ATTRIBUTE_TABLE
public GenericRecord(DataTable aTable)
public java.util.Set<java.lang.String> keys()
public java.util.Collection<java.lang.Object> values()
public boolean hasAttributeForKey(java.lang.String key)
public java.lang.Object valueForKey(java.lang.String key)
valueForKey in interface KeyedRecordkey - The key for which to get the associated value.public void setValueForKey(java.lang.Object value,
java.lang.String key)
value - The new value to associate with the specified key.key - The key for which to associated the new value.public java.lang.Number numberForKey(java.lang.String key)
key - The key for which to get the associated value.java.lang.ClassCastException - if the value cannot be cast as a Number.public boolean booleanValueForKey(java.lang.String key)
key - The key for which to get the associated value.java.lang.ClassCastException - if the value cannot be cast as a Boolean.public void setValueForKey(boolean value,
java.lang.String key)
value - The new boolean value to associate with the specified key.key - The key for which to associated the new value.public int intValueForKey(java.lang.String key)
key - The key for which to get the associated value.java.lang.ClassCastException - if the value cannot be cast as a Number.public void setValueForKey(int value,
java.lang.String key)
value - The new int value to associate with the specified key.key - The key for which to associated the new value.public long longValueForKey(java.lang.String key)
key - The key for which to get the associated value.java.lang.ClassCastException - if the value cannot be cast as a Number.public void setValueForKey(long value,
java.lang.String key)
value - The new long value to associate with the specified key.key - The key for which to associated the new value.public double doubleValueForKey(java.lang.String key)
key - The key for which to get the associated value.java.lang.ClassCastException - if the value cannot be cast as a Number.public void setValueForKey(double value,
java.lang.String key)
value - The new double value to associate with the specified key.key - The key for which to associated the new value.public java.lang.String stringValueForKey(java.lang.String key)
key - The key for which to get the associated value.java.lang.ClassCastException - if the value cannot be cast as a String.public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String dataLabel()
dataLabel in interface DataListenerpublic void update(DataAdaptor adaptor) throws GenericRecord.ParseException
update in interface DataListeneradaptor - The adaptor from which to update the dataGenericRecord.ParseExceptionpublic void write(DataAdaptor adaptor)
write in interface DataListeneradaptor - The adaptor to which the receiver's data is written