net.xineo.xml.util
Class ElementName

java.lang.Object
  |
  +--net.xineo.xml.util.ElementName

public class ElementName
extends java.lang.Object

This class contains information about the name of an XML element. This name is composed of either a namespace URI and a local name or a qualified name.


Field Summary
static ElementName WILDCARD
          This specific instance will match any alement name.
 
Constructor Summary
ElementName(org.w3c.dom.Element element)
          Constructs an element name from the prefix and tag name of a DOM element.
ElementName(java.lang.String qName)
          Constructs an element name defined by a qualified name.
ElementName(java.lang.String namespaceURI, java.lang.String localName)
          Constructs an element name defined by a namespace URI and a local name.
ElementName(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)
          Constructs an element name defined by either a namespace URI and a local name or a qualified name, depending on the null values of the given parameters (which have the same meaning as paramteres passed to SAX handlers).
 
Method Summary
 java.lang.String getLocalName()
          Returns the local name of the element.
 java.lang.String getName()
          Returns the "simple name" of the element.
 java.lang.String getNamespaceURI()
          Returns the namespace URI of the element name.
 java.lang.String getQName()
          Returns the qualified name of the element.
 boolean hasNamespace()
          Returns true if this element has a namespace
 boolean matches(org.w3c.dom.Element element)
          Checks is the name of the given DOM element matches this element name
 boolean matches(ElementName elementName)
          Checks if this element name matches another element name.
 boolean matches(java.lang.String elementName)
          Checks if this element name matches a simple qualified name.
static ElementName parseString(java.lang.String elementName)
          Creates an element name, parsing a string that may contain a simple element name or a name containing a namespace in a XML format.
 java.lang.String toString()
          Converts this element name to a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

WILDCARD

public static ElementName WILDCARD
This specific instance will match any alement name.

Constructor Detail

ElementName

public ElementName(java.lang.String qName)
Constructs an element name defined by a qualified name.

Parameters:
qName - qualified name of the element

ElementName

public ElementName(java.lang.String namespaceURI,
                   java.lang.String localName)
Constructs an element name defined by a namespace URI and a local name.

Parameters:
namespaceURI - Namespace URI of the element.
localName - Local name of the element

ElementName

public ElementName(java.lang.String namespaceURI,
                   java.lang.String localName,
                   java.lang.String qName)
Constructs an element name defined by either a namespace URI and a local name or a qualified name, depending on the null values of the given parameters (which have the same meaning as paramteres passed to SAX handlers).

Parameters:
namespaceURI - Namespace URI of the element name. Should be defined along with the local name.
localName - Local name of the element. Should be defined along with the namespace URI.
qName - Qualified name of the element.

ElementName

public ElementName(org.w3c.dom.Element element)
Constructs an element name from the prefix and tag name of a DOM element.

Parameters:
element - The DOM element
Method Detail

hasNamespace

public boolean hasNamespace()
Returns true if this element has a namespace

Returns:
true if this element has a namespace, false otherwise.

getNamespaceURI

public java.lang.String getNamespaceURI()
Returns the namespace URI of the element name.

Returns:
The namespace URI of the element name

getLocalName

public java.lang.String getLocalName()
Returns the local name of the element.

Returns:
The local name of the element

getQName

public java.lang.String getQName()
Returns the qualified name of the element.

Returns:
The qualified name of the element

getName

public java.lang.String getName()
Returns the "simple name" of the element. If the element is a qualified name, this one is returned. If the element name specifies a namespace, the local name is returned.

Returns:
The "simple name" of the element

matches

public boolean matches(ElementName elementName)
Checks if this element name matches another element name. Two element names match when they are both defined the same way (either local name plus namespace URI or qualified name), and if the corresponding attributes match.

Parameters:
elementName - The element name to compare with
Returns:
True if the element names match, and false otherwise

matches

public boolean matches(java.lang.String elementName)
Checks if this element name matches a simple qualified name.


matches

public boolean matches(org.w3c.dom.Element element)
Checks is the name of the given DOM element matches this element name


toString

public java.lang.String toString()
Converts this element name to a string.

Overrides:
toString in class java.lang.Object
Returns:
The element name as a string

parseString

public static ElementName parseString(java.lang.String elementName)
Creates an element name, parsing a string that may contain a simple element name or a name containing a namespace in a XML format. If elementName equals "*", the wildcard is returned.

Parameters:
elementName - The simple or complex element name
Returns:
The element name object, or null if the string is not a valid element name


Copyright © 2002 Frédérik Bilhaut - Xineo.NET