From db52e4d66d60184d53a27ba4d6772461daacc03d Mon Sep 17 00:00:00 2001 From: tknall Date: Fri, 22 Mar 2013 08:57:51 +0000 Subject: Maintenance update (bugfixes, new features, cleanup...) Refer to /dok/RELEASE_NOTES-3.3.txt for further information. git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/pdf-as/trunk@931 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../knowcenter/wag/egov/egiz/cfg/PropertyTree.java | 82 +++++++++++++++------- 1 file changed, 57 insertions(+), 25 deletions(-) (limited to 'pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/cfg/PropertyTree.java') diff --git a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/cfg/PropertyTree.java b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/cfg/PropertyTree.java index 49ba003..e9276b8 100644 --- a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/cfg/PropertyTree.java +++ b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/cfg/PropertyTree.java @@ -38,7 +38,7 @@ import java.util.Vector; * the values of a configuration is stored in nested hashes. The keys in an area are stored in a * HashMap. The values of a key are stored in a Vector to overload some keys. The property tree can * be used to extract sub nodes and sub keys of different tree levels. - * + * * @author wlackner * @see java.util.HashMap * @see java.util.Vector @@ -49,7 +49,7 @@ public class PropertyTree implements Serializable { * SVUID. */ private static final long serialVersionUID = -1686170519955886222L; - + /** * The key split string. A key can be a complex key. Sub keys are separated from each other with * the split string. This string is used to devide the complex key. @@ -77,7 +77,7 @@ public class PropertyTree implements Serializable { * the tree will be created. The last part of the key (last splitted element) adds the value to * there own value data structure (Vector).
* Example: setKeyValue("key.1_level.2_level","the value for k_1_2")null if the key is not a subtree referece */ @@ -129,7 +129,7 @@ public class PropertyTree implements Serializable { * This method return the subtree that corresponds to a particular key. The key does not split. * Therefore the key must be a children of the current node. Search only in the key map of the * current node. - * + * * @param key the key that has to be a sub node * @return a sub tree (PropertyTree) or null if the key is not a children of the * current node @@ -142,7 +142,7 @@ public class PropertyTree implements Serializable { * Returns the last value (keys can be overloaded) of a key. The key are splitted into subnodes * and the last node of the key is the current value holder. If a key or subnode is not in the sub * tree the return value is null. - * + * * @param key the key that holds the value (can be a nested key like "key.1.2.3") * @return the value of the key (last node of the key) or null otherwise */ @@ -162,7 +162,7 @@ public class PropertyTree implements Serializable { * Returns the first value (keys can be overloaded) of a key. The key are splitted into subnodes * and the last node of the key is the current value holder. If a key or subnode is not in the sub * tree the return value is null. - * + * * @param key the key that holds the value (can be a nested key like "key.1.2.3") * @return the value of the key (last node of the key) or null otherwise */ @@ -180,7 +180,7 @@ public class PropertyTree implements Serializable { /** * This method return all values of the current node. The values are stored as String values. - * + * * @return the values (type String) of the current node * @see Vector */ @@ -191,7 +191,7 @@ public class PropertyTree implements Serializable { /** * This method return all keys (sub tree references) of the current node as a Map. The keys are * stored as String values. - * + * * @return the keys (type String) of the current node * @see Map */ @@ -202,7 +202,7 @@ public class PropertyTree implements Serializable { /** * This method return all keys (sub tree references) of the current node as an ArrayList. The keys * are stored as String values. - * + * * @return the keys (type String) of the current node * @see ArrayList */ @@ -219,10 +219,10 @@ public class PropertyTree implements Serializable { } /** - * + * * This method return all sub tree references of a key as an ArrayList. The keys are stored as * String values. - * + * * @param key (can be a nested key like "key.1.2.3") * @return the keys (type String) of the current node * @see ArrayList @@ -237,7 +237,7 @@ public class PropertyTree implements Serializable { /** * This method return all values of a key. The values are stored as String values. - * + * * @param key (can be a nested key like "key.1.2.3") * @return the values (type Vector) of the key or null if the key is not in the sub * tree of the current node @@ -254,7 +254,7 @@ public class PropertyTree implements Serializable { /** * Store a sub tree (type PropertyTree) in the current node. The key and it's sub tree are stored * in a HashMap. - * + * * @param key the reference of the sub tree * @param tree the sub tree of the key * @see HashMap @@ -270,7 +270,7 @@ public class PropertyTree implements Serializable { * Extracts a sub tree of a nested key. The Method returns the last sub tree of the nested key. * Example: if the key is like: key.1.2.3 the sub tree of the last * node 3 is returned. - * + * * @param key the reference of the sub tree * @return a sub tree of the key or null if the key can not be found */ @@ -280,7 +280,7 @@ public class PropertyTree implements Serializable { /** * This method checks if a key is a reference to a sub tree in the current node. - * + * * @param key a simple key that is a parent reference of a sub tree * @return true if the key is found, false otherwise */ @@ -291,7 +291,7 @@ public class PropertyTree implements Serializable { /** * The default toString method. It starts with the current node recursively downwards and return * the String representation of the node. - * + * * @return the string representation of the node */ public String toString() { @@ -300,9 +300,9 @@ public class PropertyTree implements Serializable { /** * This is a helper function to define the prefix for different levels in the toString method, not - * realy nice ;-). - * It replaces all "." chars with " ". - * + * realy nice ;-).

+ * In other words: Fills {@code key} with spaces (of same length). + * * @param key * @return a replaces prefix string */ @@ -312,7 +312,7 @@ public class PropertyTree implements Serializable { /** * This method concatenates all values of the current node and return them as a combinded string. - * + * * @param prefix * @param tree * @return the string representation of the node values @@ -330,7 +330,7 @@ public class PropertyTree implements Serializable { /** * The toString method. It starts with a special level prefix, sub tree and recursively adds all * sub trees. - * + * * @param prefix the prefix for this node * @param tree the current node * @return the string representation of the node @@ -351,8 +351,40 @@ public class PropertyTree implements Serializable { } return os; } - + public void removeEntry(String key) { - this.keys_.remove(key); + this.keys_.remove(key); } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((keys_ == null) ? 0 : keys_.hashCode()); + result = prime * result + ((values_ == null) ? 0 : values_.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + PropertyTree other = (PropertyTree) obj; + if (keys_ == null) { + if (other.keys_ != null) + return false; + } else if (!keys_.equals(other.keys_)) + return false; + if (values_ == null) { + if (other.values_ != null) + return false; + } else if (!values_.equals(other.values_)) + return false; + return true; + } + } \ No newline at end of file -- cgit v1.2.3