org.pentaho.reporting.libraries.xmlns.writer
Class DeclaredNamespaces

java.lang.Object
  extended by org.pentaho.reporting.libraries.xmlns.writer.DeclaredNamespaces

public final class DeclaredNamespaces
extends java.lang.Object

A immutable namespace collection. Any attempt to modify the declared namespaces creates a new copy of the map.

Author:
Thomas Morgner

Constructor Summary
DeclaredNamespaces()
          Creates a new namespaces collection.
DeclaredNamespaces(DeclaredNamespaces namespaces)
          Creates a new namespaces collection using the given namespaces as initial values.
 
Method Summary
 DeclaredNamespaces add(AttributeList attributes)
          Adds all declared namespaces from the given attribute-list into the namespaces collection.
 DeclaredNamespaces add(java.util.HashMap newNamespaces)
          Adds all namespaces from the given hashmap into this map.
 DeclaredNamespaces add(java.lang.String uri, java.lang.String prefix)
          Adds a single namespace definition to the collection.
 java.util.Map getNamespaces()
          Returns all known namespaces as unmodifiable map.
 java.lang.String getPrefix(java.lang.String uri)
          Looksup the prefix for the given URI.
 boolean isNamespaceDefined(java.lang.String uri)
          Checks, whether the namespace marked by the given URI is defined in this collection.
 boolean isPrefixDefined(java.lang.String prefix)
          Checks whether the given prefix is already defined in the collection.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DeclaredNamespaces

public DeclaredNamespaces()
Creates a new namespaces collection.


DeclaredNamespaces

public DeclaredNamespaces(DeclaredNamespaces namespaces)
Creates a new namespaces collection using the given namespaces as initial values.

Parameters:
namespaces - the namespaces, never null.
Method Detail

add

public DeclaredNamespaces add(java.util.HashMap newNamespaces)
Adds all namespaces from the given hashmap into this map. The namespaces map must only contain string keys and string values and must not contain either null-keys or null-values.

Parameters:
newNamespaces - the namespaces collection.
Returns:
the created namespaces object.

add

public DeclaredNamespaces add(AttributeList attributes)
Adds all declared namespaces from the given attribute-list into the namespaces collection.

Parameters:
attributes - the attribute list containing namespace definitions.
Returns:
the new namespaces collection.

add

public DeclaredNamespaces add(java.lang.String uri,
                              java.lang.String prefix)
Adds a single namespace definition to the collection.

Parameters:
uri - the URI of the namespace.
prefix - the prefix to be used for the namespace.
Returns:
the new namespaces collection.

getPrefix

public java.lang.String getPrefix(java.lang.String uri)
Looksup the prefix for the given URI. This returns null if the URI is not a declared namespace.

Parameters:
uri - the URI.
Returns:
the prefix for the given URI or null, if the URI is not part of this collection.

isNamespaceDefined

public boolean isNamespaceDefined(java.lang.String uri)
Checks, whether the namespace marked by the given URI is defined in this collection.

Parameters:
uri - the URI to be checked.
Returns:
true, if the URI is known, false otherwise.

getNamespaces

public java.util.Map getNamespaces()
Returns all known namespaces as unmodifiable map.

Returns:
the namespaces.

isPrefixDefined

public boolean isPrefixDefined(java.lang.String prefix)
Checks whether the given prefix is already defined in the collection.

Parameters:
prefix - the prefix.
Returns:
true, if the prefix is already used, false otherwise.