org.apache.lenya.util
Class NamespaceMap

java.lang.Object
  extended by org.apache.lenya.util.NamespaceMap

public class NamespaceMap
extends java.lang.Object

An object of this class provides an easy way to access Strings in a Map that are prefixed like "prefix.foo". The actual map wrapped by this object can contain more key-value-pairs, but you can access only the prefixed keys through the mapper.


Field Summary
static java.lang.String SEPARATOR
           
 
Constructor Summary
NamespaceMap(java.util.Map map, java.lang.String prefix)
          Creates a new NamespaceMap.
NamespaceMap(java.lang.String prefix)
          Creates a new NamespaceMap object.
 
Method Summary
 java.lang.Object get(java.lang.String key)
          Returns the value for a prefixed key.
static java.lang.String getFullName(java.lang.String prefix, java.lang.String key)
          Returns the full (prefixed) key for a short (un-prefixed) key.
 java.util.Map getMap()
          Returns a map that contains only the un-prefixed key-value-pairs.
protected  java.util.Map getMapObject()
          Returns the namespace prefix.
 java.lang.String getPrefix()
          Returns the prefix.
 java.util.Map getPrefixedMap()
          Returns a map with prefixed keys.
static java.lang.String getShortName(java.lang.String prefix, java.lang.String key)
          Returns the short (un-prefixed) key for a full (prefixed) key.
 void put(java.lang.String key, java.lang.Object value)
          Puts a value for prefixed key into the map.
 void putAll(java.util.Map map)
          Puts all prefixed key-value-pairs of map into this map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEPARATOR

public static final java.lang.String SEPARATOR
See Also:
Constant Field Values
Constructor Detail

NamespaceMap

public NamespaceMap(java.lang.String prefix)
Creates a new NamespaceMap object.

Parameters:
prefix - The prefix.

NamespaceMap

public NamespaceMap(java.util.Map map,
                    java.lang.String prefix)
Creates a new NamespaceMap.

Parameters:
map - A map containing the prefixed key-value-pairs.
prefix - The prefix.
Method Detail

getPrefix

public java.lang.String getPrefix()
Returns the prefix.

Returns:
A string.

getMapObject

protected java.util.Map getMapObject()
Returns the namespace prefix.

Returns:
The namespace prefix.

getMap

public java.util.Map getMap()
Returns a map that contains only the un-prefixed key-value-pairs.

Returns:
The map.

put

public void put(java.lang.String key,
                java.lang.Object value)
Puts a value for prefixed key into the map.

Parameters:
key - The key without prefix.
value - The value.

get

public java.lang.Object get(java.lang.String key)
Returns the value for a prefixed key.

Parameters:
key - The key without prefix.
Returns:
The value.

getFullName

public static java.lang.String getFullName(java.lang.String prefix,
                                           java.lang.String key)
Returns the full (prefixed) key for a short (un-prefixed) key.

Parameters:
prefix - The prefix.
key - The un-prefixed key.
Returns:
A string (prefix + SEPARATOR + key).

getShortName

public static java.lang.String getShortName(java.lang.String prefix,
                                            java.lang.String key)
Returns the short (un-prefixed) key for a full (prefixed) key.

Parameters:
prefix - The prefix.
key - The full (prefixed) key.
Returns:
A string.

putAll

public void putAll(java.util.Map map)
Puts all prefixed key-value-pairs of map into this map.

Parameters:
map - A map.

getPrefixedMap

public java.util.Map getPrefixedMap()
Returns a map with prefixed keys.

Returns:
A map.


Copyright © 1999-2005 Apache Software Foundation. All Rights Reserved.