aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/itmill/toolkit/terminal/KeyMapper.java
diff options
context:
space:
mode:
authorMarc Englund <marc.englund@itmill.com>2007-11-19 14:03:05 +0000
committerMarc Englund <marc.englund@itmill.com>2007-11-19 14:03:05 +0000
commitf2e3722df9676436680afc0f1991e91e1696fb99 (patch)
tree6f255ff78abaf96f1e71a1f2c9ecd3b66647f4a2 /src/com/itmill/toolkit/terminal/KeyMapper.java
parent93291f532db9d545cf2a8dd98e2671f27cd197b0 (diff)
downloadvaadin-framework-f2e3722df9676436680afc0f1991e91e1696fb99.tar.gz
vaadin-framework-f2e3722df9676436680afc0f1991e91e1696fb99.zip
MASS REFORMAT.
According to http://toolkit.intra.itmill.com/trac/itmilltoolkit/wiki/CodingConventions svn changeset:2864/svn branch:trunk
Diffstat (limited to 'src/com/itmill/toolkit/terminal/KeyMapper.java')
-rw-r--r--src/com/itmill/toolkit/terminal/KeyMapper.java160
1 files changed, 81 insertions, 79 deletions
diff --git a/src/com/itmill/toolkit/terminal/KeyMapper.java b/src/com/itmill/toolkit/terminal/KeyMapper.java
index 59967f2d32..16460de64c 100644
--- a/src/com/itmill/toolkit/terminal/KeyMapper.java
+++ b/src/com/itmill/toolkit/terminal/KeyMapper.java
@@ -41,83 +41,85 @@ import java.util.Hashtable;
*/
public class KeyMapper {
- private int lastKey = 0;
-
- private Hashtable objectKeyMap = new Hashtable();
-
- private Hashtable keyObjectMap = new Hashtable();
-
- /**
- * Gets key for an object.
- *
- * @param o
- * the object.
- */
- public String key(Object o) {
-
- if (o == null)
- return "null";
-
- // If the object is already mapped, use existing key
- String key = (String) objectKeyMap.get(o);
- if (key != null)
- return key;
-
- // If the object is not yet mapped, map it
- key = String.valueOf(++lastKey);
- objectKeyMap.put(o, key);
- keyObjectMap.put(key, o);
-
- return key;
- }
-
- /**
- * Checks if the key belongs to a new id.
- * <p>
- * Usage of new id:s are specific to components, but for example Select
- * component uses newItemId:s for selection of newly added items in
- * <code>allowNewItems</code>-mode.
- *
- * @param key
- * @return <code>true</code> if the key belongs to the new id,otherwise
- * <code>false</code>.
- */
- public boolean isNewIdKey(String key) {
- return "NEW".equals(key);
- }
-
- /**
- * Retrieves object with the key.
- *
- * @param key
- * the name with the desired value.
- * @return the object with the key.
- */
- public Object get(String key) {
-
- return keyObjectMap.get(key);
- }
-
- /**
- * Removes object from the mapper.
- *
- * @param removeobj
- * the object to be removed.
- */
- public void remove(Object removeobj) {
- String key = (String) objectKeyMap.get(removeobj);
-
- if (key != null) {
- objectKeyMap.remove(key);
- keyObjectMap.remove(removeobj);
- }
- }
-
- /**
- * Removes all objects from the mapper.
- */
- public void removeAll() {
- objectKeyMap.clear();
- keyObjectMap.clear();
- }
+ private int lastKey = 0;
+
+ private Hashtable objectKeyMap = new Hashtable();
+
+ private Hashtable keyObjectMap = new Hashtable();
+
+ /**
+ * Gets key for an object.
+ *
+ * @param o
+ * the object.
+ */
+ public String key(Object o) {
+
+ if (o == null) {
+ return "null";
+ }
+
+ // If the object is already mapped, use existing key
+ String key = (String) objectKeyMap.get(o);
+ if (key != null) {
+ return key;
+ }
+
+ // If the object is not yet mapped, map it
+ key = String.valueOf(++lastKey);
+ objectKeyMap.put(o, key);
+ keyObjectMap.put(key, o);
+
+ return key;
+ }
+
+ /**
+ * Checks if the key belongs to a new id.
+ * <p>
+ * Usage of new id:s are specific to components, but for example Select
+ * component uses newItemId:s for selection of newly added items in
+ * <code>allowNewItems</code>-mode.
+ *
+ * @param key
+ * @return <code>true</code> if the key belongs to the new id,otherwise
+ * <code>false</code>.
+ */
+ public boolean isNewIdKey(String key) {
+ return "NEW".equals(key);
+ }
+
+ /**
+ * Retrieves object with the key.
+ *
+ * @param key
+ * the name with the desired value.
+ * @return the object with the key.
+ */
+ public Object get(String key) {
+
+ return keyObjectMap.get(key);
+ }
+
+ /**
+ * Removes object from the mapper.
+ *
+ * @param removeobj
+ * the object to be removed.
+ */
+ public void remove(Object removeobj) {
+ String key = (String) objectKeyMap.get(removeobj);
+
+ if (key != null) {
+ objectKeyMap.remove(key);
+ keyObjectMap.remove(removeobj);
+ }
+ }
+
+ /**
+ * Removes all objects from the mapper.
+ */
+ public void removeAll() {
+ objectKeyMap.clear();
+ keyObjectMap.clear();
+ }
}