Package xal.tools.data
Class TransientDataAdaptor
java.lang.Object
xal.tools.data.TransientDataAdaptor
- All Implemented Interfaces:
DataAdaptor
A volatile implementation of the
DataAdaptor
interface.
TransientDataAdaptor
is intended as a convenience class for
passing data using the DataAdaptor
interface. Note, however,
class supports no persistence. Once an object of class
TransientDataAdaptor
is destroyed all internal data is lost.- Author:
- Christopher K. Allen
-
Constructor Summary
ConstructorsConstructorDescriptionTransientDataAdaptor
(String strLabel) Create a new instance of VolatileDataAdaptor -
Method Summary
Modifier and TypeMethodDescriptionString[]
Get all the attribute names in the data node.boolean
booleanValue
(String strAttrName) Get the value of an attribute.childAdaptor
(String strLabel) Convenience method to get a single child adaptor when only one is expected.Get an iterator containing all child adaptors of this node.childAdaptorIterator
(String strLabel) Get an iterator for all child data nodes having a given data label.Get all the child data nodes of this adaptor.childAdaptors
(String strLabel) Get all the child data nodes of a particular data label.createChild
(String strLabel) Create a new empty child adaptor with the specified label.double[]
doubleArray
(String strAttr) Returns the value of an attribute as an array of doubles.double
doubleValue
(String strAttrName) Get the value of an attribute.boolean
hasAttribute
(String strAttrName) Test whether or not an attribute is present in the data node.int
Get the value of an attribute.long
Get the value of an attribute.name()
Get the label for this data node.int
Get the number of child data nodes.void
print
(PrintStream os) Print out the contents of this adaptor.void
removeChild
(DataAdaptor adaptor) Remove a child adaptorvoid
Set the value of the specified attributevoid
Set the value of the specified attributevoid
Sets the attribute (name,value) pair for the given arguments.void
Set the value of the specified attributevoid
Set the value of the specified attributevoid
Set the value of the specified attributevoid
Set the value of the specified attribute as a string.stringValue
(String strAttrName) Get the value of an attribute.void
writeNode
(DataListener ifcSrc) Write out the listener data as a new node then append it as a child node in the data tree.void
writeNodes
(Collection<? extends DataListener> colSrcs) write the collection of listeners to new nodes and append them to the data tree.
-
Constructor Details
-
TransientDataAdaptor
Create a new instance of VolatileDataAdaptor- Parameters:
strLabel
- label for new data node
-
-
Method Details
-
name
Get the label for this data node.- Specified by:
name
in interfaceDataAdaptor
- Returns:
- name for the particular node in the data tree
-
attributes
Get all the attribute names in the data node.- Specified by:
attributes
in interfaceDataAdaptor
- Returns:
- array of all attributes names
-
hasAttribute
Test whether or not an attribute is present in the data node.- Specified by:
hasAttribute
in interfaceDataAdaptor
- Parameters:
strAttrName
- attribute name- Returns:
- true if specified attribute is present, false otherwise
-
stringValue
Get the value of an attribute.- Specified by:
stringValue
in interfaceDataAdaptor
- Parameters:
strAttrName
- name of attribute- Returns:
- value of attribute as boolean
-
booleanValue
Get the value of an attribute.- Specified by:
booleanValue
in interfaceDataAdaptor
- Parameters:
strAttrName
- name of attribute- Returns:
- value of attribute as boolean
- Throws:
NumberFormatException
- unable to parse value as boolean
-
intValue
Get the value of an attribute.- Specified by:
intValue
in interfaceDataAdaptor
- Parameters:
strAttrName
- name of attribute- Returns:
- value of attribute as int
- Throws:
NumberFormatException
- unable to parse value as int
-
longValue
Get the value of an attribute.- Specified by:
longValue
in interfaceDataAdaptor
- Parameters:
strAttrName
- name of attribute- Returns:
- value of attribute as long
- Throws:
NumberFormatException
- unable to parse value as long
-
doubleValue
Get the value of an attribute.- Specified by:
doubleValue
in interfaceDataAdaptor
- Parameters:
strAttrName
- name of attribute- Returns:
- value of attribute as double
- Throws:
NumberFormatException
- unable to parse value as double
-
doubleArray
Returns the value of an attribute as an array of doubles. The attribute value must be stored as a string of comma separated values (CSVs). The values are parsed into doubles and packed into the returned array.- Specified by:
doubleArray
in interfaceDataAdaptor
- Parameters:
strAttr
- the attribute name- Returns:
- Array of double values as parsed from the value string. A
null
value is returned if the value string is empty. - Throws:
NumberFormatException
- at least one value was malformed, or the CSV string was malformed- Since:
- Mar 12, 2010
-
setValue
Set the value of the specified attribute as a string.- Specified by:
setValue
in interfaceDataAdaptor
- Parameters:
strAttrName
- attribute namestrAttrVal
- attribute value
-
setValue
Set the value of the specified attribute- Specified by:
setValue
in interfaceDataAdaptor
- Parameters:
strAttrName
- attribute nameobjAttrVal
- new attribute value
-
setValue
Set the value of the specified attribute- Specified by:
setValue
in interfaceDataAdaptor
- Parameters:
strAttrName
- attribute namebolAttrVal
- new attribute value
-
setValue
Set the value of the specified attribute- Specified by:
setValue
in interfaceDataAdaptor
- Parameters:
strAttrName
- attribute nameintAttrVal
- new attribute value
-
setValue
Set the value of the specified attribute- Specified by:
setValue
in interfaceDataAdaptor
- Parameters:
strAttrName
- attribute namelongAttrVal
- new attribute value
-
setValue
Set the value of the specified attribute- Specified by:
setValue
in interfaceDataAdaptor
- Parameters:
strAttrName
- attribute namedblAttrVal
- new attribute value
-
setValue
Sets the attribute (name,value) pair for the given arguments. The value here is a double array which is stored as a string of comma separated values.- Specified by:
setValue
in interfaceDataAdaptor
- Parameters:
strAttr
- attribute namearrVal
- attribute value- Since:
- Mar 11, 2010
- See Also:
-
nodeCount
public int nodeCount()Get the number of child data nodes.- Returns:
- number of child node adaptors
-
childAdaptor
Convenience method to get a single child adaptor when only one is expected.- Specified by:
childAdaptor
in interfaceDataAdaptor
- Parameters:
strLabel
- data label of child node- Returns:
- first child node with label strLabel, null if none exist
-
childAdaptors
Get all the child data nodes of this adaptor.- Specified by:
childAdaptors
in interfaceDataAdaptor
- Returns:
- all child adaptors
-
childAdaptors
Get all the child data nodes of a particular data label.- Specified by:
childAdaptors
in interfaceDataAdaptor
- Parameters:
strLabel
- data label for child nodes- Returns:
- all child adaptors with specified label
-
childAdaptorIterator
Get an iterator containing all child adaptors of this node.- Returns:
- iterator of all child adaptors
-
childAdaptorIterator
Get an iterator for all child data nodes having a given data label.- Parameters:
strLabel
- data label for child nodes- Returns:
- iterator of child adaptors with specified label
-
createChild
Create a new empty child adaptor with the specified label.- Specified by:
createChild
in interfaceDataAdaptor
- Parameters:
strLabel
- data label for the child node- Returns:
- new child data node attached to this
-
removeChild
Description copied from interface:DataAdaptor
Remove a child adaptor- Specified by:
removeChild
in interfaceDataAdaptor
-
writeNode
Write out the listener data as a new node then append it as a child node in the data tree.- Specified by:
writeNode
in interfaceDataAdaptor
- Parameters:
ifcSrc
-
-
writeNodes
write the collection of listeners to new nodes and append them to the data tree.- Specified by:
writeNodes
in interfaceDataAdaptor
- Parameters:
colSrcs
- collection data sources exposingDataListener
interface
-
print
Print out the contents of this adaptor.- Parameters:
os
- output stream- Since:
- Mar 12, 2010
-