org.clapper.util.misc
Class PropertiesMap

java.lang.Object
  extended by java.util.AbstractMap<java.lang.String,java.lang.String>
      extended by org.clapper.util.misc.PropertiesMap
All Implemented Interfaces:
java.io.Serializable, java.util.Map<java.lang.String,java.lang.String>

public class PropertiesMap
extends java.util.AbstractMap<java.lang.String,java.lang.String>
implements java.io.Serializable

An PropertiesMap provides a thin Map<String,String> wrapper around a java.util.Properties object, allowing the Properties object to be used where a type-safe Map is expected. (One such place is with a VariableSubstituter class.)

Version:
$Revision: 6735 $
Author:
Copyright © 2004-2007 Brian M. Clapper
See Also:
Properties, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
PropertiesMap(java.util.Properties properties)
          Construct a map to wrap the specified Properties object.
 
Method Summary
 void clear()
          Remove all mappings from this map.
 boolean containsKey(java.lang.Object key)
          Determine whether this map contains a mapping for a given key.
 boolean containsValue(java.lang.Object value)
          Determine whether this map contains a given value.
 java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.String>> entrySet()
          Get a set view of the mappings in this map.
 java.lang.String get(java.lang.Object key)
          Retrieve an object from the map.
 boolean isEmpty()
          Determine whether this map is empty or not.
 java.util.Set<java.lang.String> keySet()
          Return a Set view of the keys in the map.
 java.lang.String put(java.lang.String key, java.lang.String value)
          Associates the specified value with the specified key in this map.
 java.lang.String remove(java.lang.Object key)
          Removes the mapping for a key, if there is one.
 int size()
          Get the number of entries in the map.
 
Methods inherited from class java.util.AbstractMap
clone, equals, hashCode, putAll, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PropertiesMap

public PropertiesMap(java.util.Properties properties)
Construct a map to wrap the specified Properties object.

Parameters:
properties - the Properties object
Method Detail

clear

public void clear()
Remove all mappings from this map.

Specified by:
clear in interface java.util.Map<java.lang.String,java.lang.String>
Overrides:
clear in class java.util.AbstractMap<java.lang.String,java.lang.String>

containsKey

public boolean containsKey(java.lang.Object key)
Determine whether this map contains a mapping for a given key. Note that this implementation of containsKey() does not refresh the object in the cache.

Specified by:
containsKey in interface java.util.Map<java.lang.String,java.lang.String>
Overrides:
containsKey in class java.util.AbstractMap<java.lang.String,java.lang.String>
Parameters:
key - the key to find
Returns:
true if the key is in the map, false if not

containsValue

public boolean containsValue(java.lang.Object value)
Determine whether this map contains a given value. Note that this implementation of containsValue() does not refresh the objects in the cache.

Specified by:
containsValue in interface java.util.Map<java.lang.String,java.lang.String>
Overrides:
containsValue in class java.util.AbstractMap<java.lang.String,java.lang.String>
Parameters:
value - the value to find
Returns:
true if the value is in the map, false if not

entrySet

public java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.String>> entrySet()
Get a set view of the mappings in this map. Each element in this set is a Map.Entry. The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa. The collection supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Collection.remove, removeAll, retainAll, and clear operations. It does not support the add or addAll operations.

Specified by:
entrySet in interface java.util.Map<java.lang.String,java.lang.String>
Specified by:
entrySet in class java.util.AbstractMap<java.lang.String,java.lang.String>
Returns:
nothing
Throws:
java.lang.UnsupportedOperationException - unconditionally

get

public java.lang.String get(java.lang.Object key)
Retrieve an object from the map. Retrieving an object from an LRU map "refreshes" the object so that it is among the most recently used objects.

Specified by:
get in interface java.util.Map<java.lang.String,java.lang.String>
Overrides:
get in class java.util.AbstractMap<java.lang.String,java.lang.String>
Parameters:
key - the object's key in the map. Must be a string.
Returns:
the associated object, or null if not found
Throws:
java.lang.ClassCastException - if key is not a string

isEmpty

public boolean isEmpty()
Determine whether this map is empty or not.

Specified by:
isEmpty in interface java.util.Map<java.lang.String,java.lang.String>
Overrides:
isEmpty in class java.util.AbstractMap<java.lang.String,java.lang.String>
Returns:
true if the map has no mappings, false otherwise

keySet

public java.util.Set<java.lang.String> keySet()

Return a Set view of the keys in the map. The set is partially backed by the map. Changes to the map are not necessarily reflected in the set, and vice-versa. The set does not support element removal.

Specified by:
keySet in interface java.util.Map<java.lang.String,java.lang.String>
Overrides:
keySet in class java.util.AbstractMap<java.lang.String,java.lang.String>
Returns:
the set of keys in this map

put

public java.lang.String put(java.lang.String key,
                            java.lang.String value)
Associates the specified value with the specified key in this map. If the key already has a value in this map, the existing value is replaced by the new value, and the old value is replaced. If the key already exists in the map, it is moved to the end of the key insertion order list.

Specified by:
put in interface java.util.Map<java.lang.String,java.lang.String>
Overrides:
put in class java.util.AbstractMap<java.lang.String,java.lang.String>
Parameters:
key - the key with which the specified value is to be associated
value - the value to associate with the specified key
Returns:
the previous value associated with the key, or null if (a) there was no previous value, or (b) the previous value was a null

remove

public java.lang.String remove(java.lang.Object key)
Removes the mapping for a key, if there is one. Not supported by this class.

Specified by:
remove in interface java.util.Map<java.lang.String,java.lang.String>
Overrides:
remove in class java.util.AbstractMap<java.lang.String,java.lang.String>
Parameters:
key - the key to remove
Returns:
the previous value associated with the key, or null if (a) there was no previous value, or (b) the previous value was a null
Throws:
java.lang.UnsupportedOperationException - unconditionally

size

public int size()
Get the number of entries in the map. Note that this value can temporarily exceed the maximum capacity of the map. See the class documentation for details.

Specified by:
size in interface java.util.Map<java.lang.String,java.lang.String>
Overrides:
size in class java.util.AbstractMap<java.lang.String,java.lang.String>
Returns:
the number of entries in the map


Copyright © 2004-2007 Brian M. Clapper. All Rights Reserved.