org.rhq.test
Class TokenReplacingProperties

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<String,String>
          extended by org.rhq.test.TokenReplacingProperties
All Implemented Interfaces:
Serializable, Cloneable, Map<String,String>

public class TokenReplacingProperties
extends HashMap<String,String>

This map is basically an extension of the Properties class that can resolve the references to values of other keys inside the values.

I.e., if the map is initialized with the following mappings:

name => world
hello => Hello ${name}!

then the call to:

get("hello")

will return: "Hello world!"

To access and modify the underlying unprocessed values, one can use the "raw" counterparts of the standard map methods (e.g. instead of get(Object), use getRaw(Object), etc.).

Author:
Lukas Krejci
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Constructor Summary
TokenReplacingProperties(Map<String,String> wrapped)
           
TokenReplacingProperties(Properties properties)
           
 
Method Summary
 void clear()
           
 boolean containsKey(Object key)
           
 boolean containsRawValue(Object value)
          Checks whether this map contains the unprocessed value.
 boolean containsValue(Object value)
           
 Set<Map.Entry<String,String>> entrySet()
          The returned set IS NOT backed by this map (unlike in the default map implementations).
 String get(Object key)
           
 String getRaw(Object key)
           
 Set<Map.Entry<String,String>> getRawEntrySet()
           
 Collection<String> getRawValues()
           
 Set<String> keySet()
           
 String put(String key, String value)
           
 void putAll(Map<? extends String,? extends String> m)
           
 void putAll(Properties properties)
           
 String remove(Object key)
           
 int size()
           
 Collection<String> values()
          Unlike in the default implementation the collection returned from this method IS NOT backed by this map.
 
Methods inherited from class java.util.HashMap
clone, isEmpty
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

TokenReplacingProperties

public TokenReplacingProperties(Map<String,String> wrapped)

TokenReplacingProperties

public TokenReplacingProperties(Properties properties)
Method Detail

get

public String get(Object key)
Specified by:
get in interface Map<String,String>
Overrides:
get in class HashMap<String,String>

getRaw

public String getRaw(Object key)

put

public String put(String key,
                  String value)
Specified by:
put in interface Map<String,String>
Overrides:
put in class HashMap<String,String>

putAll

public void putAll(Map<? extends String,? extends String> m)
Specified by:
putAll in interface Map<String,String>
Overrides:
putAll in class HashMap<String,String>

putAll

public void putAll(Properties properties)

clear

public void clear()
Specified by:
clear in interface Map<String,String>
Overrides:
clear in class HashMap<String,String>

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map<String,String>
Overrides:
containsKey in class HashMap<String,String>

keySet

public Set<String> keySet()
Specified by:
keySet in interface Map<String,String>
Overrides:
keySet in class HashMap<String,String>

containsValue

public boolean containsValue(Object value)
Specified by:
containsValue in interface Map<String,String>
Overrides:
containsValue in class HashMap<String,String>

containsRawValue

public boolean containsRawValue(Object value)
Checks whether this map contains the unprocessed value.

Parameters:
value -
Returns:

entrySet

public Set<Map.Entry<String,String>> entrySet()
The returned set IS NOT backed by this map (unlike in the default map implementations).

The Map.Entry.setValue(Object) method does modify this map though.

Specified by:
entrySet in interface Map<String,String>
Overrides:
entrySet in class HashMap<String,String>

getRawEntrySet

public Set<Map.Entry<String,String>> getRawEntrySet()

remove

public String remove(Object key)
Specified by:
remove in interface Map<String,String>
Overrides:
remove in class HashMap<String,String>

size

public int size()
Specified by:
size in interface Map<String,String>
Overrides:
size in class HashMap<String,String>

values

public Collection<String> values()
Unlike in the default implementation the collection returned from this method IS NOT backed by this map.

Specified by:
values in interface Map<String,String>
Overrides:
values in class HashMap<String,String>

getRawValues

public Collection<String> getRawValues()


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.