APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.org.apache.xml.internal.utils

public Class QName

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
com.sun.org.apache.xml.internal.res.XMLErrorResources, .XMLMessages, java.util.Stack, .StringTokenizer, org.w3c.dom.Element

Class to represent a qualified name: "The name of an internal XSLT object, specifically a named template (see [7 Named Templates]), a mode (see [6.7 Modes]), an attribute set (see [8.1.4 Named Attribute Sets]), a key (see [14.2 Keys]), a locale (see [14.3 Number Formatting]), a variable or a parameter (see [12 Variables and Parameters]) is specified as a QName. If it has a prefix, then the prefix is expanded into a URI reference using the namespace declarations in effect on the attribute in which the name occurs. The expanded name consisting of the local part of the name and the possibly null URI reference is used as the name of the object. The default namespace is not used for unprefixed names."

Field Summary

Modifier and TypeField and Description
protected String
_localName

The local name.

protected String
_namespaceURI

The namespace URI.

protected String
_prefix

The namespace prefix.

private int
m_hashCode

The cached hashcode, which is calculated at construction time.

public static final String
S_XMLNAMESPACEURI

The XML namespace.

pack-priv static final long

Constructor Summary

AccessConstructor and Description
public
QName()

Constructs an empty QName.

public
QName(String
The namespace URI if known, or null
namespaceURI
,
String
The local name
localName
)

Constructs a new QName with the specified namespace URI and local name.

public
QName(String
The namespace URI if known, or null
namespaceURI
,
String
The local name
localName
,
boolean
If true the new QName will be validated and an IllegalArgumentException will be thrown if it is invalid.
validate
)

Constructs a new QName with the specified namespace URI and local name.

public
QName(String
The namespace URI if known, or null
namespaceURI
,
String
The namespace prefix is known, or null
prefix
,
String
The local name
localName
)

Constructs a new QName with the specified namespace URI, prefix and local name.

public
QName(String
The namespace URI if known, or null
namespaceURI
,
String
The namespace prefix is known, or null
prefix
,
String
The local name
localName
,
boolean
If true the new QName will be validated and an IllegalArgumentException will be thrown if it is invalid.
validate
)

Constructs a new QName with the specified namespace URI, prefix and local name.

public
QName(String
Local part of qualified name
localName
)

Construct a QName from a string, without namespace resolution.

public
QName(String
Local part of qualified name
localName
,
boolean
If true the new QName will be validated and an IllegalArgumentException will be thrown if it is invalid.
validate
)

Construct a QName from a string, without namespace resolution.

public
QName(String
Qualified name to resolve
qname
,
Stack<NameSpace>
Namespace stack to use to resolve namespace
namespaces
)

Construct a QName from a string, resolving the prefix using the given namespace stack.

public
QName(String
Qualified name to resolve
qname
,
Stack<NameSpace>
Namespace stack to use to resolve namespace
namespaces
,
boolean
If true the new QName will be validated and an IllegalArgumentException will be thrown if it is invalid.
validate
)

Construct a QName from a string, resolving the prefix using the given namespace stack.

public
QName(String
Qualified name to resolve
qname
,
Element
Namespace Context to use
namespaceContext
,
PrefixResolver
Prefix resolver for this context
resolver
)

Construct a QName from a string, resolving the prefix using the given namespace context and prefix resolver.

public
QName(String
Qualified name to resolve
qname
,
Element
Namespace Context to use
namespaceContext
,
PrefixResolver
Prefix resolver for this context
resolver
,
boolean
If true the new QName will be validated and an IllegalArgumentException will be thrown if it is invalid.
validate
)

Construct a QName from a string, resolving the prefix using the given namespace context and prefix resolver.

public
QName(String
Qualified name to resolve
qname
,
PrefixResolver
Prefix resolver for this context
resolver
)

Construct a QName from a string, resolving the prefix using the given namespace stack.

public
QName(String
Qualified name to resolve
qname
,
PrefixResolver
Prefix resolver for this context
resolver
,
boolean
If true the new QName will be validated and an IllegalArgumentException will be thrown if it is invalid.
validate
)

Construct a QName from a string, resolving the prefix using the given namespace stack.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

True if the local name and uri match
equals
(String
Namespace URI to compare to
ns
,
String
Local part of qualified name to compare to
localPart
)

Override equals and agree that we're equal if the passed object is a string and it matches the name of the arg.

public boolean

Returns:

True if the qualified names are equal
equals
(Object object)

Overrides java.lang.Object.equals.

Override equals and agree that we're equal if the passed object is a QName and it matches the name of the arg.

public String

Returns:

The local part of the qualified name
getLocalName
()

Returns the local part of the qualified name.

public String

Returns:

the local part of the qualified name
getLocalPart
()

Get the local part of the qualified name.

public static String

Returns:

Local part of the name if prefixed, or the given name if not
getLocalPart
(String
Input name
qname
)

Returns the local name of the given node.

public String

Returns:

the namespace URI of the qualified name
getNamespace
()

Get the namespace of the qualified name.

public String

Returns:

The namespace URI, or null
getNamespaceURI
()

Returns the namespace URI.

public String

Returns:

The namespace prefix, or null
getPrefix
()

Returns the namespace prefix.

public static String

Returns:

Prefix of attribute
getPrefixFromXMLNSDecl
(String
Raw name of attribute
attRawName
)

This function tells if a raw attribute name is a xmlns attribute.

public static String

Returns:

Prefix of name or empty string if none there
getPrefixPart
(String
Input name
qname
)

Returns the local name of the given node.

public static QName

Returns:

a QName object
getQNameFromString
(String
String to use to create QName
name
)

Given a string, create and return a QName object

public int

Returns:

the cached hashcode of the qualified name
hashCode
()

Overrides java.lang.Object.hashCode.

Return the cached hashcode of the qualified name.

public static boolean

Returns:

True if the attribute starts with or is equal to xmlns
isXMLNSDecl
(String
Raw name of attribute
attRawName
)

This function tells if a raw attribute name is a xmlns attribute.

public String

Returns:

the string representation of the namespace
toNamespacedString
()

Return the string representation of the qualified name using the the '{ns}foo' notation.

public String

Returns:

the string representation of the namespace
toString
()

Overrides java.lang.Object.toString.

Return the string representation of the qualified name, using the prefix if available, or the '{ns}foo' notation if not.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

_localNameback to summary
protected String _localName

The local name.

_namespaceURIback to summary
protected String _namespaceURI

The namespace URI.

_prefixback to summary
protected String _prefix

The namespace prefix.

m_hashCodeback to summary
private int m_hashCode

The cached hashcode, which is calculated at construction time.

S_XMLNAMESPACEURIback to summary
public static final String S_XMLNAMESPACEURI

The XML namespace.

serialVersionUIDback to summary
pack-priv static final long serialVersionUID

Constructor Detail

QNameback to summary
public QName()

Constructs an empty QName. 20001019: Try making this public, to support Serializable? -- JKESS

QNameback to summary
public QName(String namespaceURI, String localName)

Constructs a new QName with the specified namespace URI and local name.

Parameters
namespaceURI:String

The namespace URI if known, or null

localName:String

The local name

QNameback to summary
public QName(String namespaceURI, String localName, boolean validate)

Constructs a new QName with the specified namespace URI and local name.

Parameters
namespaceURI:String

The namespace URI if known, or null

localName:String

The local name

validate:boolean

If true the new QName will be validated and an IllegalArgumentException will be thrown if it is invalid.

QNameback to summary
public QName(String namespaceURI, String prefix, String localName)

Constructs a new QName with the specified namespace URI, prefix and local name.

Parameters
namespaceURI:String

The namespace URI if known, or null

prefix:String

The namespace prefix is known, or null

localName:String

The local name

QNameback to summary
public QName(String namespaceURI, String prefix, String localName, boolean validate)

Constructs a new QName with the specified namespace URI, prefix and local name.

Parameters
namespaceURI:String

The namespace URI if known, or null

prefix:String

The namespace prefix is known, or null

localName:String

The local name

validate:boolean

If true the new QName will be validated and an IllegalArgumentException will be thrown if it is invalid.

QNameback to summary
public QName(String localName)

Construct a QName from a string, without namespace resolution. Good for a few odd cases.

Parameters
localName:String

Local part of qualified name

QNameback to summary
public QName(String localName, boolean validate)

Construct a QName from a string, without namespace resolution. Good for a few odd cases.

Parameters
localName:String

Local part of qualified name

validate:boolean

If true the new QName will be validated and an IllegalArgumentException will be thrown if it is invalid.

QNameback to summary
public QName(String qname, Stack<NameSpace> namespaces)

Construct a QName from a string, resolving the prefix using the given namespace stack. The default namespace is not resolved.

Parameters
qname:String

Qualified name to resolve

namespaces:Stack<NameSpace>

Namespace stack to use to resolve namespace

QNameback to summary
public QName(String qname, Stack<NameSpace> namespaces, boolean validate)

Construct a QName from a string, resolving the prefix using the given namespace stack. The default namespace is not resolved.

Parameters
qname:String

Qualified name to resolve

namespaces:Stack<NameSpace>

Namespace stack to use to resolve namespace

validate:boolean

If true the new QName will be validated and an IllegalArgumentException will be thrown if it is invalid.

QNameback to summary
public QName(String qname, Element namespaceContext, PrefixResolver resolver)

Construct a QName from a string, resolving the prefix using the given namespace context and prefix resolver. The default namespace is not resolved.

Parameters
qname:String

Qualified name to resolve

namespaceContext:Element

Namespace Context to use

resolver:PrefixResolver

Prefix resolver for this context

QNameback to summary
public QName(String qname, Element namespaceContext, PrefixResolver resolver, boolean validate)

Construct a QName from a string, resolving the prefix using the given namespace context and prefix resolver. The default namespace is not resolved.

Parameters
qname:String

Qualified name to resolve

namespaceContext:Element

Namespace Context to use

resolver:PrefixResolver

Prefix resolver for this context

validate:boolean

If true the new QName will be validated and an IllegalArgumentException will be thrown if it is invalid.

QNameback to summary
public QName(String qname, PrefixResolver resolver)

Construct a QName from a string, resolving the prefix using the given namespace stack. The default namespace is not resolved.

Parameters
qname:String

Qualified name to resolve

resolver:PrefixResolver

Prefix resolver for this context

QNameback to summary
public QName(String qname, PrefixResolver resolver, boolean validate)

Construct a QName from a string, resolving the prefix using the given namespace stack. The default namespace is not resolved.

Parameters
qname:String

Qualified name to resolve

resolver:PrefixResolver

Prefix resolver for this context

validate:boolean

If true the new QName will be validated and an IllegalArgumentException will be thrown if it is invalid.

Method Detail

equalsback to summary
public boolean equals(String ns, String localPart)

Override equals and agree that we're equal if the passed object is a string and it matches the name of the arg.

Parameters
ns:String

Namespace URI to compare to

localPart:String

Local part of qualified name to compare to

Returns:boolean

True if the local name and uri match

equalsback to summary
public boolean equals(Object object)

Overrides java.lang.Object.equals.

Override equals and agree that we're equal if the passed object is a QName and it matches the name of the arg.

Returns:boolean

True if the qualified names are equal

getLocalNameback to summary
public String getLocalName()

Returns the local part of the qualified name.

Returns:String

The local part of the qualified name

getLocalPartback to summary
public String getLocalPart()

Get the local part of the qualified name.

Returns:String

the local part of the qualified name

getLocalPartback to summary
public static String getLocalPart(String qname)

Returns the local name of the given node.

Parameters
qname:String

Input name

Returns:String

Local part of the name if prefixed, or the given name if not

getNamespaceback to summary
public String getNamespace()

Get the namespace of the qualified name.

Returns:String

the namespace URI of the qualified name

getNamespaceURIback to summary
public String getNamespaceURI()

Returns the namespace URI. Returns null if the namespace URI is not known.

Returns:String

The namespace URI, or null

getPrefixback to summary
public String getPrefix()

Returns the namespace prefix. Returns null if the namespace prefix is not known.

Returns:String

The namespace prefix, or null

getPrefixFromXMLNSDeclback to summary
public static String getPrefixFromXMLNSDecl(String attRawName)

This function tells if a raw attribute name is a xmlns attribute.

Parameters
attRawName:String

Raw name of attribute

Returns:String

Prefix of attribute

getPrefixPartback to summary
public static String getPrefixPart(String qname)

Returns the local name of the given node.

Parameters
qname:String

Input name

Returns:String

Prefix of name or empty string if none there

getQNameFromStringback to summary
public static QName getQNameFromString(String name)

Given a string, create and return a QName object

Parameters
name:String

String to use to create QName

Returns:QName

a QName object

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Return the cached hashcode of the qualified name.

Returns:int

the cached hashcode of the qualified name

isXMLNSDeclback to summary
public static boolean isXMLNSDecl(String attRawName)

This function tells if a raw attribute name is a xmlns attribute.

Parameters
attRawName:String

Raw name of attribute

Returns:boolean

True if the attribute starts with or is equal to xmlns

toNamespacedStringback to summary
public String toNamespacedString()

Return the string representation of the qualified name using the the '{ns}foo' notation. Performs string concatenation, so beware of performance issues.

Returns:String

the string representation of the namespace

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Return the string representation of the qualified name, using the prefix if available, or the '{ns}foo' notation if not. Performs string concatenation, so beware of performance issues.

Returns:String

the string representation of the namespace