org.pentaho.reporting.libraries.xmlns.common

Class AttributeList

public class AttributeList extends Object

The attribute list is used by a writer to specify the attributes of an XML element in a certain order.

Author: Thomas Morgner

Nested Class Summary
static classAttributeList.AttributeEntry
A name/value pair of the attribute list.
Field Summary
static StringXMLNS_NAMESPACE
A constant containing the XML-Namespace namespace identifier.
static StringXML_NAMESPACE
A constant containing the XML namespace identifier.
Constructor Summary
AttributeList()
Creates an empty attribute list with no default values.
Method Summary
voidaddNamespaceDeclaration(String prefix, String namespaceUri)
Adds a namespace declaration.
StringgetAttribute(String namespace, String name)
Returns the attribute value for the given attribute name or null, if the attribute is not defined in this list.
StringgetAttribute(String namespace, String name, String defaultValue)
Returns the attribute value for the given attribute name or the given defaultvalue, if the attribute is not defined in this list.
booleanisEmpty()
Checks, whether this list is empty.
booleanisNamespacePrefixDefined(String prefix)
Checks, whether the given prefix is defined.
booleanisNamespaceUriDefined(String uri)
Checks, whether the given namespace URI has a defined prefix.
Iteratoriterator()
Returns an iterator over the entry list.
voidremoveAttribute(String namespace, String name)
Removes the attribute with the given name from the list.
voidremoveNamespaceDeclaration(String prefix)
Removes a namespace declaration from this attribute list.
voidsetAttribute(String namespace, String name, String value)
Defines an attribute.
AttributeList.AttributeEntry[]toArray()

Field Detail

XMLNS_NAMESPACE

public static final String XMLNS_NAMESPACE
A constant containing the XML-Namespace namespace identifier.

XML_NAMESPACE

public static final String XML_NAMESPACE
A constant containing the XML namespace identifier.

Constructor Detail

AttributeList

public AttributeList()
Creates an empty attribute list with no default values.

Method Detail

addNamespaceDeclaration

public void addNamespaceDeclaration(String prefix, String namespaceUri)
Adds a namespace declaration. In XML, Namespaces are declared by using a special attribute-syntax. As this syntax is confusing and complicated, this method encapsulates this and make defining namespaces less confusing.

Parameters: prefix the desired namespace prefix (can be null or empty to define the default namespace. namespaceUri the URI of the namespace.

getAttribute

public String getAttribute(String namespace, String name)
Returns the attribute value for the given attribute name or null, if the attribute is not defined in this list.

Parameters: namespace the namespace of the attribute. name the name of the attribute

Returns: the attribute value or null.

getAttribute

public String getAttribute(String namespace, String name, String defaultValue)
Returns the attribute value for the given attribute name or the given defaultvalue, if the attribute is not defined in this list.

Parameters: namespace the namespace of the attribute. name the name of the attribute. defaultValue the default value.

Returns: the attribute value or the defaultValue.

isEmpty

public boolean isEmpty()
Checks, whether this list is empty.

Returns: true, if the list is empty, false otherwise.

isNamespacePrefixDefined

public boolean isNamespacePrefixDefined(String prefix)
Checks, whether the given prefix is defined.

Parameters: prefix the namespace prefix.

Returns: true, if the prefix is defined, false otherwise.

isNamespaceUriDefined

public boolean isNamespaceUriDefined(String uri)
Checks, whether the given namespace URI has a defined prefix.

Parameters: uri the uri.

Returns: true, if there is at least one namespace declaration matching the given URI, false otherwise.

iterator

public Iterator iterator()

Deprecated: use toArray instead.

Returns an iterator over the entry list. The iterator returns AttributeList.AttributeEntry objects.

Returns: the iterator over the entries contained in this list.

removeAttribute

public void removeAttribute(String namespace, String name)
Removes the attribute with the given name from the list.

Parameters: namespace the namespace of the attribute that should be removed. name the name of the attribute which should be removed..

removeNamespaceDeclaration

public void removeNamespaceDeclaration(String prefix)
Removes a namespace declaration from this attribute list.

Parameters: prefix the declared namespace prefix.

setAttribute

public void setAttribute(String namespace, String name, String value)
Defines an attribute.

Parameters: namespace the namespace of the attribute. name the name of the attribute to be defined value the value of the attribute.

toArray

public AttributeList.AttributeEntry[] toArray()