com.novell.xml.util
Class ExpandedQName

java.lang.Object
  extended bycom.novell.xml.util.ExpandedQName
All Implemented Interfaces:
Comparable

public class ExpandedQName
extends Object
implements Comparable

Class to contain an expanded QName. An expanded QName has the namespace prefix expanded to the actual URI value (the namespace name)


Field Summary
static String UNKNOWN_NAMESPACE
           
 
Constructor Summary
ExpandedQName(NamespaceName namespace_name, String local_part)
          Construct an expanded qname from a NamespaceName and a local_part.
ExpandedQName(NamespaceName namespace_name, String local_part, String prefix)
          Construct an expanded qname from a namespace name and a local-part.
ExpandedQName(Node node)
          Construct an expanded QName for a node
ExpandedQName(String qName, Node contextNode)
          Construct an expanded QName from an unexpanded QName and a context node.
ExpandedQName(String namespace_name, String local_part)
          Construct an expanded qname from a uri (namespace name) and a local_part.
ExpandedQName(String prefix, String local_part, Node contextNode)
          Construct an expanded QName from a prefix, a local-part and a context node.
ExpandedQName(String namespace_name, String local_part, String prefix)
          Construct an expanded qname from a uri (namespace name) and a local_part.
 
Method Summary
 int compareTo(Object rhs)
          Implementation of Comparable interface.
 boolean equals(ExpandedQName rhs)
          Compare this ExpandedQName instance with another ExpandedQName instance.
 boolean equals(Object rhs)
          Compare this object with another object.
 String getLocalPart()
          Return the local part of the expanded qname.
 NamespaceName getNamespaceName()
          Return the namespace name of the expaned qname (the URI part)
 String getNamespaceURI()
          Return the namespace URI string of the namespace name part of this ExpandedQName
 String getPrefix()
          Return the prefix for the expanded QName, if known.
 String getQName()
          Return the expanded QName in its original form, if possible
 int hashCode()
          Return a hash code based on the uri and local-part of this ExpandedQName
 boolean localPartEquals(ExpandedQName rhs)
          Return true if the local parts of this ExpandedQName and the passed ExpandedQName are equal.
 boolean localPartEquals(String rhs)
          Return true if the local-part of this object is equal to the passed string
 boolean namespaceNameEquals(ExpandedQName rhs)
          Return true if the namespace names (URIs) of this ExpandedQName and the passed ExpandedQName are equal.
 boolean namespaceNameEquals(NamespaceName rhs)
          Return true if the passed NamespaceName is equal to the namespace name of this ExpandedQName
 boolean namespaceNameEquals(String rhs)
          Return true if the namespace name for this object is equal to the passed string
 String toString()
          Convert the expanded QName to a single string.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

UNKNOWN_NAMESPACE

public static final String UNKNOWN_NAMESPACE
See Also:
Constant Field Values
Constructor Detail

ExpandedQName

public ExpandedQName(String namespace_name,
                     String local_part)
Construct an expanded qname from a uri (namespace name) and a local_part.

Parameters:
namespace_name - The expanded prefix (URI)
local_part - The local part of the QName

ExpandedQName

public ExpandedQName(NamespaceName namespace_name,
                     String local_part)
Construct an expanded qname from a NamespaceName and a local_part.

Parameters:
namespace_name - The namespace name
local_part - The local part of the QName

ExpandedQName

public ExpandedQName(Node node)
Construct an expanded QName for a node

Parameters:
node - The node for which the ExpandedQName is to be created

ExpandedQName

public ExpandedQName(String qName,
                     Node contextNode)
Construct an expanded QName from an unexpanded QName and a context node.

Parameters:
qName - The unexpanded QName. This must follow the production for QName in http://www.w3.org/TR/1999/REC-xml-names
contextNode - The node relative to which to resolve the QName prefix.

ExpandedQName

public ExpandedQName(String prefix,
                     String local_part,
                     Node contextNode)
Construct an expanded QName from a prefix, a local-part and a context node.

Parameters:
prefix - The QName namespace prefix.
local_part - The QName local part
contextNode - The node relative to which to resolve the QName prefix.

ExpandedQName

public ExpandedQName(String namespace_name,
                     String local_part,
                     String prefix)
Construct an expanded qname from a uri (namespace name) and a local_part. In addition, track the original prefix

Parameters:
namespace_name - The expanded prefix (URI)
local_part - The local part of the QName
prefix - The original prefix part of the QName

ExpandedQName

public ExpandedQName(NamespaceName namespace_name,
                     String local_part,
                     String prefix)
Construct an expanded qname from a namespace name and a local-part. In addition, track the original prefix

Parameters:
namespace_name - The namespace name
local_part - The local part of the QName
prefix - The original prefix part of the QName
Method Detail

hashCode

public int hashCode()
Return a hash code based on the uri and local-part of this ExpandedQName

Returns:
The hash code value for this object

equals

public boolean equals(Object rhs)
Compare this object with another object.

Parameters:
rhs - The object to compare to/
Returns:
true if and only if the rhs object is an instance of ExpandedQName and the namespace names and local parts match character for character.

equals

public boolean equals(ExpandedQName rhs)
Compare this ExpandedQName instance with another ExpandedQName instance.

Parameters:
rhs - The ExpandedQName instance against which to compare
Returns:
true if both the namespace name and local parts of the two ExpandedQNames are equal

namespaceNameEquals

public boolean namespaceNameEquals(ExpandedQName rhs)
Return true if the namespace names (URIs) of this ExpandedQName and the passed ExpandedQName are equal. This method should be used rather than comparing the strings because the underlying implementation of ExpandedQName will be faster.

Parameters:
rhs - The ExpandedQName with which to compare namespace names
Returns:
true if the passed namespace name is equal to this namespace name

namespaceNameEquals

public boolean namespaceNameEquals(NamespaceName rhs)
Return true if the passed NamespaceName is equal to the namespace name of this ExpandedQName

Parameters:
rhs - The namespace name to which to compare
Returns:
true if the namespace name of this object is equal to the passed namespace name.

namespaceNameEquals

public boolean namespaceNameEquals(String rhs)
Return true if the namespace name for this object is equal to the passed string

Parameters:
rhs - The string to compare against
Returns:
True if the passed string is equal to the namespace name of this object

localPartEquals

public boolean localPartEquals(ExpandedQName rhs)
Return true if the local parts of this ExpandedQName and the passed ExpandedQName are equal. This method should be used rather than comparing the strings because the underlying implementation of ExpandedQName may be faster.

Parameters:
rhs - The ExpandedQName with which to compare namespace names
Returns:
True if the passed local part name is equal to this namespace name

localPartEquals

public boolean localPartEquals(String rhs)
Return true if the local-part of this object is equal to the passed string

Parameters:
rhs - The string to compare against
Returns:
True if the passed string is equal to the local-part name of this object

compareTo

public int compareTo(Object rhs)
Implementation of Comparable interface.

Specified by:
compareTo in interface Comparable
Parameters:
rhs - Object to compare to
Returns:
And int reflecting relative order of this object and the rhs object (< 0 this object is before rhs, == 0 objects are equal, > 0 this object is after rhs)

toString

public String toString()
Convert the expanded QName to a single string.

Returns:
The concatenation of the namespace name and the local part.

getQName

public String getQName()
Return the expanded QName in its original form, if possible

Returns:
The original QName, if the prefix is known, otherwise a name of form {Unknown}:local-part

getNamespaceName

public NamespaceName getNamespaceName()
Return the namespace name of the expaned qname (the URI part)

Returns:
The namespace name

getNamespaceURI

public String getNamespaceURI()
Return the namespace URI string of the namespace name part of this ExpandedQName

Returns:
The namespace URI string

getLocalPart

public String getLocalPart()
Return the local part of the expanded qname.

Returns:
The local part.

getPrefix

public String getPrefix()
Return the prefix for the expanded QName, if known. This will return null if the prefix is not known.

Returns:
The prefix string for the QName, or null if the prefix is unknown.