T
- the type of the nodes managed by this modelpublic interface NodeModel<T>
Definition of an interface describing a model based on a nodes structure.
This interface can be used for dealing with hierarchical, tree-like data. It defines basic operations for manipulating the tree structure which use keys to select the nodes affected.
The idea behind this interface is that concrete implementations can be used by hierarchical configurations. This
makes it possible to integrate various hierarchical structures with the API of a hierarchical configuration, e.g.
configuration nodes stored in memory, JNDI contexts, or other structures. The configuration object interacts with the
underlying data structure via this interface. For more complex operations access to an ExpressionEngine
may
be required in order to interpret the passed in keys. For these purposes a NodeKeyResolver
has to be provided
which knows how to deal with keys.
Modifier and Type | Method and Description |
---|---|
void |
addNodes(String key,
Collection<? extends T> nodes,
NodeKeyResolver<T> resolver)
Adds a collection of new nodes to this model.
|
void |
addProperty(String key,
Iterable<?> values,
NodeKeyResolver<T> resolver)
Adds a new property to this node model consisting of an arbitrary number of values.
|
void |
clear(NodeKeyResolver<T> resolver)
Removes all data from this model.
|
void |
clearProperty(String key,
NodeKeyResolver<T> resolver)
Clears the value of a property.
|
Object |
clearTree(String key,
NodeKeyResolver<T> resolver)
Removes the sub trees defined by the given key from this model.
|
ImmutableNode |
getInMemoryRepresentation()
Returns a representation of the data stored in this model in form of a nodes hierarchy of
ImmutableNode
objects. |
NodeHandler<T> |
getNodeHandler()
Returns a
NodeHandler for dealing with the nodes managed by this model. |
void |
setProperty(String key,
Object value,
NodeKeyResolver<T> resolver)
Changes the value of a property.
|
void |
setRootNode(T newRoot)
Sets a new root node for this model.
|
void setRootNode(T newRoot)
newRoot
- the new root node to be set (can be null, then an empty root node is set)NodeHandler<T> getNodeHandler()
NodeHandler
for dealing with the nodes managed by this model.NodeHandler
void addProperty(String key, Iterable<?> values, NodeKeyResolver<T> resolver)
NodeAddData
object defining the add operation to be performed.key
- the keyvalues
- the values to be added at the position defined by the keyresolver
- the NodeKeyResolver
void addNodes(String key, Collection<? extends T> nodes, NodeKeyResolver<T> resolver)
addNodes()
method of the
HierarchicalConfiguration
interface. The new nodes are either added to an existing node (if the passed in key
selects exactly one node) or to a newly created node. The passed in NodeKeyResolver
is used to interpret the
given key.key
- the keynodes
- the collection of nodes to be added (may be null)resolver
- the NodeKeyResolver
IllegalArgumentException
- if the key references an attribute (of course, it is not possible to add something
to an attribute)void setProperty(String key, Object value, NodeKeyResolver<T> resolver)
NodeKeyResolver
which will produce a corresponding NodeUpdateData
object. Based on the content of this object, update
operations are performed.key
- the keyvalue
- the new value for this property (to be evaluated by the NodeKeyResolver
)resolver
- the NodeKeyResolver
Object clearTree(String key, NodeKeyResolver<T> resolver)
NodeKeyResolver
and removed from the model.key
- the key selecting the properties to be removedresolver
- the NodeKeyResolver
void clearProperty(String key, NodeKeyResolver<T> resolver)
clearTree(String, NodeKeyResolver)
: However, the
nodes referenced by the passed in key are not removed completely, but only their value is set to null.key
- the key selecting the properties to be clearedresolver
- the NodeKeyResolver
void clear(NodeKeyResolver<T> resolver)
resolver
- the NodeKeyResolver
ImmutableNode getInMemoryRepresentation()
ImmutableNode
objects. A concrete model implementation can use an arbitrary means to store its data. When a model's data is to be
used together with other functionality of the Configuration library (e.g. when combining multiple
configuration sources) it has to be transformed into a common format. This is done by this method.
ImmutableNode
is a generic representation of a hierarchical structure. Thus, it should be possible to
generate a corresponding structure from arbitrary model data.Copyright © 2001–2022 The Apache Software Foundation. All rights reserved.