Interface DataAdaptor
- All Known Subinterfaces:
FileDataAdaptor
- All Known Implementing Classes:
Hdf5DataAdaptor
,InMemoryDataAdaptor
,TransientDataAdaptor
,XmlDataAdaptor
DataAdaptor
is a generic interface to an external data source. A
specific data adaptor (e.g. XmlDataAdaptor
) will implement this
interface to advertise its data in a generic way for reading and writing to a
specific data source (e.g. XML file). DataAdaptor
is intended to
be a generic wrapper for specific data sources and sinks. Data adaptors do
not have any knowledge about the objects that read and write data. Such data
receivers and writers should implement the
interface (or the DataListener
interface for
model persistence).
IArchive
A DataAdaptor
instance is generated for each node in a
hierarchical data tree and advertises information about the node and provides
accessors to its children. Information about a node is in the form of
attributes which represent key/value pairs of primitive data. The node also
contains a text string which represents the data node "content".
The general structure of the data should be tree based, analogous to that of
the XML DOM structure. Data is distributed by nodes in a tree, each node
having a data label (see
),
attributes, and possibly some type of string content (see
name()
DataAdaptor#getContent()
- currently unimplimented).
There are potentially child data nodes of each node (see
and
createChild(String)
).
childAdaptor(String)
Any object that is able to read and write from
DataAdaptor
interfaces can implement the DataListener
interface. The idea is
that such an object should know, itself, how to load and save data from this
interface, and expect to receive the appropriate DataAdaptor
object for doing so. Finally, note that the update(DataAdaptor)
and write(DataAdaptor)
methods of the IDataAware
interface expect IDataAdaptors
in different positions on the
data tree. This must be the case for proper logistical implementation. The
update()
method expects to be synchronized to the current data
node while the write()
method expects to be given the parent of
the data node it is to populate. See the documentation for the
DataListener
interface for more information.- Author:
- Tom Pelaia, Christopher K. Allen
-
Method Summary
Modifier and TypeMethodDescriptionString[]
return the array of all attributesboolean
booleanValue
(String attribute) boolean value associated with the specified attributechildAdaptor
(String label) Convenience method to get a single child adaptor when only one is expectedreturn all child adaptorschildAdaptors
(String label) return all child adaptors of the specified node namecreateChild
(String label) Create an new empty child adaptor with labeldouble[]
doubleArray
(String attribute) Returns the value of an attribute as an array of doubles.double
doubleValue
(String attribute) double value associated with the specified attributeboolean
hasAttribute
(String attribute) returns true if the node has the specified attributeint
integer value associated with the specified attributelong
long value associated with the specified attributename()
name for the particular node in the data treevoid
removeChild
(DataAdaptor adaptor) Remove a child adaptorvoid
set the value of the specified attribute to the specified valuevoid
set the value of the specified attribute to the specified valuevoid
Stores the value of the givendouble[]
object in the data adaptor backing store.void
set the value of the specified attribute to the specified valuevoid
set the value of the specified attribute to the specified valuevoid
set the value of the specified attribute to the specified valuevoid
set the value of the specified attribute to the specified valuestringValue
(String attribute) string value associated with the specified attributevoid
writeNode
(DataListener listener) write the listener as a new node and append it to the data treevoid
writeNodes
(Collection<? extends DataListener> nodes) Write the collection of listeners to new nodes and append them to the data tree.
-
Method Details
-
name
String name()name for the particular node in the data tree -
hasAttribute
returns true if the node has the specified attribute -
stringValue
string value associated with the specified attribute -
doubleValue
double value associated with the specified attribute -
longValue
long value associated with the specified attribute -
intValue
integer value associated with the specified attribute -
booleanValue
boolean value associated with the specified attribute -
doubleArray
Returns the value of an attribute as an array of doubles.- Parameters:
attribute
- the attribute name- Returns:
- Array of double values, a
null
value is returned if the value string is empty.
-
setValue
set the value of the specified attribute to the specified value -
setValue
set the value of the specified attribute to the specified value -
setValue
set the value of the specified attribute to the specified value -
setValue
set the value of the specified attribute to the specified value -
setValue
set the value of the specified attribute to the specified value -
setValue
set the value of the specified attribute to the specified value -
setValue
Stores the value of the givendouble[]
object in the data adaptor backing store.- Parameters:
attribute
- attribute namearray
- attribute value
-
attributes
String[] attributes()return the array of all attributes -
childAdaptors
List<DataAdaptor> childAdaptors()return all child adaptors -
childAdaptors
return all child adaptors of the specified node name -
childAdaptor
Convenience method to get a single child adaptor when only one is expected -
createChild
Create an new empty child adaptor with label -
removeChild
Remove a child adaptor -
writeNode
write the listener as a new node and append it to the data tree -
writeNodes
Write the collection of listeners to new nodes and append them to the data tree.- Parameters:
nodes
- the nodes to write
-