You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by oh...@apache.org on 2014/03/21 21:33:15 UTC
svn commit: r1580036 - in
/commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration:
AbstractHierarchicalConfiguration.java tree/NodeKeyResolver.java
Author: oheger
Date: Fri Mar 21 20:33:14 2014
New Revision: 1580036
URL: http://svn.apache.org/r1580036
Log:
Added new methods to NodeKeyResolver interface.
These methods are needed for doing more complex operations with tracked nodes.
Modified:
commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/AbstractHierarchicalConfiguration.java
commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/tree/NodeKeyResolver.java
Modified: commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/AbstractHierarchicalConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/AbstractHierarchicalConfiguration.java?rev=1580036&r1=1580035&r2=1580036&view=diff
==============================================================================
--- commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/AbstractHierarchicalConfiguration.java (original)
+++ commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/AbstractHierarchicalConfiguration.java Fri Mar 21 20:33:14 2014
@@ -469,6 +469,11 @@ public abstract class AbstractHierarchic
return getExpressionEngine().query(root, key, handler);
}
+ public List<T> resolveNodeKey(T root, String key, NodeHandler<T> handler) {
+ //TODO implementation
+ return null;
+ }
+
/**
* {@inheritDoc} This implementation delegates to the expression engine.
*/
@@ -523,6 +528,11 @@ public abstract class AbstractHierarchic
removedItems, key);
}
+ public String nodeKey(T node, Map<T, String> cache, NodeHandler<T> handler) {
+ //TODO implementation
+ return null;
+ }
+
/**
* Clears this configuration. This is a more efficient implementation than
* the one inherited from the base class. It delegates to the node model.
Modified: commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/tree/NodeKeyResolver.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/tree/NodeKeyResolver.java?rev=1580036&r1=1580035&r2=1580036&view=diff
==============================================================================
--- commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/tree/NodeKeyResolver.java (original)
+++ commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/tree/NodeKeyResolver.java Fri Mar 21 20:33:14 2014
@@ -17,6 +17,7 @@
package org.apache.commons.configuration.tree;
import java.util.List;
+import java.util.Map;
/**
* <p>
@@ -49,6 +50,20 @@ public interface NodeKeyResolver<T>
List<QueryResult<T>> resolveKey(T root, String key, NodeHandler<T> handler);
/**
+ * Performs a query for the specified key on the given root node returning
+ * only node results. Some operations require results of type node and do
+ * not support attributes (e.g. for tracking nodes). This operation can be
+ * used in such cases. It works like {@code resolveKey()}, but filters only
+ * for results of type node.
+ *
+ * @param root the root node
+ * @param key the key to be resolved
+ * @param handler the {@code NodeHandler}
+ * @return a list with the resolved nodes
+ */
+ List<T> resolveNodeKey(T root, String key, NodeHandler<T> handler);
+
+ /**
* Resolves a key of an add operation. Result is a {@code NodeAddData}
* object containing all information for actually performing the add
* operation at the specified key.
@@ -76,4 +91,20 @@ public interface NodeKeyResolver<T>
*/
NodeUpdateData<T> resolveUpdateKey(T root, String key, Object newValue,
NodeHandler<T> handler);
+
+ /**
+ * Generates a unique key for the specified node. This method is used if
+ * keys have to be generated for nodes received as query results. An
+ * implementation must generate a canonical key which is compatible with the
+ * current expression engine. The passed in map can be used by an
+ * implementation as cache. It is created initially by the caller and then
+ * passed in subsequent calls. An implementation may use this to avoid that
+ * keys for nodes already encountered have to be generated again.
+ *
+ * @param node the node in question
+ * @param cache a map serving as cache
+ * @param handler the {@code NodeHandler}
+ * @return a key for the specified node
+ */
+ String nodeKey(T node, Map<T, String> cache, NodeHandler<T> handler);
}