Package xal.tools.data
Class GenericRecord
java.lang.Object
xal.tools.data.GenericRecord
- All Implemented Interfaces:
DataListener,KeyedRecord
GenericRecord is the default record class for DataTable. This class can be
used directly for the records or a subclass of GenericRecord may be used for
convenience. GenericRecord stores its data as key/value pairs. Note that
GenericRecord is not thread safe. This is due to the fact that DataTable is
not thread safe.
- Author:
- tap
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA runtime exception thrown while attempting to parse values stored as strings into an object of the appropriate type. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanValueForKey(String key) Convenience method to get the value as a boolean associated with the specified key.dataLabel() provides the name used to identify the class in an external data source.doubledoubleValueForKey(String key) Convenience method to get the value as a double associated with the specified key.booleanhasAttributeForKey(String key) Determine whether this record has the specified attributeintintValueForKey(String key) Convenience method to get the value as an int associated with the specified key.keys()Get the keys used in this record.longlongValueForKey(String key) Convenience method to get the value as a long associated with the specified key.numberForKey(String key) Convenience method to get the value cast as a number associated with the specified key.voidsetValueForKey(boolean value, String key) Set the boolean value to associate with the specified key.voidsetValueForKey(double value, String key) Set the double value to associate with the specified key.voidsetValueForKey(int value, String key) Set the int value to associate with the specified key.voidsetValueForKey(long value, String key) Set the long value to associate with the specified key.voidsetValueForKey(Object value, String key) Set the value to associate with the specified key.stringValueForKey(String key) Convenience method to get the value as a String associated with the specified key.toString()Overrides toString() to show key/value pairs.voidupdate(DataAdaptor adaptor) Update the data based on the information provided by the data provider.valueForKey(String key) Get the value associated with the specified key.values()Get the collection of values held in this record.voidwrite(DataAdaptor adaptor) Write data to the data adaptor for storage.
-
Field Details
-
dataTable
data table to which this record belongs -
attributeTable
table of attributes by attribute ID
-
-
Constructor Details
-
GenericRecord
Creates new GenericRecord
-
-
Method Details
-
keys
Get the keys used in this record.- Returns:
- The keys used in this record.
-
values
Get the collection of values held in this record.- Returns:
- The collection of values held in this record.
-
hasAttributeForKey
Determine whether this record has the specified attribute -
valueForKey
Get the value associated with the specified key.- Specified by:
valueForKeyin interfaceKeyedRecord- Parameters:
key- The key for which to get the associated value.- Returns:
- The value as an Object.
-
setValueForKey
Set the value to associate with the specified key. If the value associated with a primary key is changed we must be careful to force the table to re-index the record.- Parameters:
value- The new value to associate with the specified key.key- The key for which to associated the new value.
-
numberForKey
Convenience method to get the value cast as a number associated with the specified key.- Parameters:
key- The key for which to get the associated value.- Returns:
- The value as an Number.
- Throws:
ClassCastException- if the value cannot be cast as a Number.
-
booleanValueForKey
Convenience method to get the value as a boolean associated with the specified key.- Parameters:
key- The key for which to get the associated value.- Returns:
- The value as an boolean.
- Throws:
ClassCastException- if the value cannot be cast as a Boolean.
-
setValueForKey
Set the boolean value to associate with the specified key.- Parameters:
value- The new boolean value to associate with the specified key.key- The key for which to associated the new value.
-
intValueForKey
Convenience method to get the value as an int associated with the specified key.- Parameters:
key- The key for which to get the associated value.- Returns:
- The value as an int.
- Throws:
ClassCastException- if the value cannot be cast as a Number.
-
setValueForKey
Set the int value to associate with the specified key.- Parameters:
value- The new int value to associate with the specified key.key- The key for which to associated the new value.
-
longValueForKey
Convenience method to get the value as a long associated with the specified key.- Parameters:
key- The key for which to get the associated value.- Returns:
- The value as a long.
- Throws:
ClassCastException- if the value cannot be cast as a Number.
-
setValueForKey
Set the long value to associate with the specified key.- Parameters:
value- The new long value to associate with the specified key.key- The key for which to associated the new value.
-
doubleValueForKey
Convenience method to get the value as a double associated with the specified key.- Parameters:
key- The key for which to get the associated value.- Returns:
- The value as a double.
- Throws:
ClassCastException- if the value cannot be cast as a Number.
-
setValueForKey
Set the double value to associate with the specified key.- Parameters:
value- The new double value to associate with the specified key.key- The key for which to associated the new value.
-
stringValueForKey
Convenience method to get the value as a String associated with the specified key.- Parameters:
key- The key for which to get the associated value.- Returns:
- The value as an String.
- Throws:
ClassCastException- if the value cannot be cast as a String.
-
toString
Overrides toString() to show key/value pairs. -
dataLabel
dataLabel() provides the name used to identify the class in an external data source.- Specified by:
dataLabelin interfaceDataListener- Returns:
- a tag that identifies the receiver's type
-
update
Update the data based on the information provided by the data provider.- Specified by:
updatein interfaceDataListener- Parameters:
adaptor- The adaptor from which to update the data- Throws:
GenericRecord.ParseException
-
write
Write data to the data adaptor for storage.- Specified by:
writein interfaceDataListener- Parameters:
adaptor- The adaptor to which the receiver's data is written
-