public interface ExpressionEngine
Definition of an interface for evaluating keys for hierarchical configurations.
An expression engine knows how to map a key for a configuration's
property to a single or a set of configuration nodes. Thus it defines the way
how properties are addressed in this configuration. Methods of a
configuration that have to handle property keys (e.g. getProperty()
or addProperty()
do not interpret the passed in keys on their own,
but delegate this task to an associated expression engine. This expression
engine will then find out, which configuration nodes are addressed by the
key.
Separating the task of evaluating property keys from the configuration object has the advantage that multiple different expression languages (i.e. ways for querying or setting properties) can be supported. Just set a suitable implementation of this interface as the configuration's expression engine, and you can use the syntax provided by this implementation.
An ExpressionEngine
can deal with nodes of different types. To
achieve this, a NodeHandler
for the desired type must be passed to
the methods.
Modifier and Type | Method and Description |
---|---|
String |
attributeKey(String parentKey,
String attributeName)
Returns the key of an attribute.
|
<T> String |
canonicalKey(T node,
String parentKey,
NodeHandler<T> handler)
Determines a "canonical" key for the specified node in the
expression language supported by this implementation.
|
<T> String |
nodeKey(T node,
String parentKey,
NodeHandler<T> handler)
Returns the key for the specified node in the expression language
supported by an implementation.
|
<T> NodeAddData<T> |
prepareAdd(T root,
String key,
NodeHandler<T> handler)
Returns information needed for an add operation.
|
<T> List<QueryResult<T>> |
query(T root,
String key,
NodeHandler<T> handler)
Finds the nodes and/or attributes that are matched by the specified key.
|
<T> List<QueryResult<T>> query(T root, String key, NodeHandler<T> handler)
NodeHandler
can be used to gather the required information from
the node object.T
- the type of the node to be processedroot
- the root node of a hierarchy of nodeskey
- the key to be evaluatedhandler
- the NodeHandler
for accessing the node<T> String nodeKey(T node, String parentKey, NodeHandler<T> handler)
getKeys()
method.T
- the type of the node to be processednode
- the node, for which the key must be constructedparentKey
- the key of this node's parent (can be null for
the root node)handler
- the NodeHandler
for accessing the nodeString attributeKey(String parentKey, String attributeName)
parentKey
must
reference the parent node of the attribute. A concrete implementation
must concatenate this parent key with the attribute name to a valid key
for this attribute.parentKey
- the key to the node owning this attributeattributeName
- the name of the attribute in question<T> String canonicalKey(T node, String parentKey, NodeHandler<T> handler)
T
- the type of the node to be processednode
- the node, for which the key must be constructedparentKey
- the key of this node's parent (can be null for
the root node)handler
- the NodeHandler
for accessing the node<T> NodeAddData<T> prepareAdd(T root, String key, NodeHandler<T> handler)
T
- the type of the node to be processedroot
- the root nodekey
- the key for the new propertyhandler
- the NodeHandler
for accessing the nodeCopyright © 2001–2020 The Apache Software Foundation. All rights reserved.