Top Description Inners Fields Constructors Methods
org.jdom2

public final Class Namespace

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Static Imports
org.jdom2.JDOMConstants.*

An XML namespace representation, as well as a factory for creating XML namespace objects. All methods on Namespace (including getNamespace(String) and getNamespace(String, String)) are thread-safe.

See NamespaceAware for additional notes on how Namespaces are 'in-scope' in JDOM content, and how those in-scope Namespaces are accessed.

Authors
Brett McLaughlin, Elliotte Rusty Harold, Jason Hunter, Wesley Biggs, Rolf Lear
See Also
NamespaceAware

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static final ConcurrentMap<String, ConcurrentMap<String, Namespace>>
namespacemap

Factory list of namespaces.

public static final Namespace
NO_NAMESPACE

Define a Namespace for when not in a namespace

private final transient String
prefix

The prefix mapped to this namespace

private static final long
serialVersionUID

JDOM 2.0.0 Serialization version

private final transient String
uri

The URI for this namespace

public static final Namespace
XML_NAMESPACE

Define a Namespace for the standard xml prefix.

private static final Namespace

Constructor Summary

AccessConstructor and Description
private
Namespace(final String
String prefix to map to this namespace.
prefix
,
final String
String URI for namespace.
uri
)

This constructor handles creation of a Namespace object with a prefix and URI; it is intentionally left private so that it cannot be invoked by external programs/code.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

boolean - whether the supplied object is equal to this Namespace.
equals
(final Object
Object to compare to this Namespace.
ob
)

Overrides java.lang.Object.equals.

This tests for equality - Two Namespaces are equal if and only if their URIs are byte-for-byte equals.
public static Namespace

Returns:

Namespace - ready to use namespace.
getNamespace
(final String
String prefix to map to Namespace.
prefix
,
final String
String URI of new Namespace.
uri
)

This will retrieve (if in existence) or create (if not) a Namespace for the supplied prefix and uri.

public static Namespace

Returns:

Namespace - ready to use namespace.
getNamespace
(final String
String URI of new Namespace.
uri
)

This will retrieve (if in existence) or create (if not) a Namespace for the supplied URI, and make it usable as a default namespace, as no prefix is supplied.

public String

Returns:

String - prefix for this Namespace.
getPrefix
()

This returns the prefix mapped to this Namespace.

public String

Returns:

String - URI for this Namespace.
getURI
()

This returns the namespace URI for this Namespace.

public int

Returns:

int - hash code for this Namespace.
hashCode
()

Overrides java.lang.Object.hashCode.

This returns the hash code for the Namespace that conforms to the 'equals()' contract.
private Object

Returns:

nothing.
readResolve
()

Because Namespace is serialized by proxy, the reading of direct Namespace instances is illegal and prohibited.

public String

Returns:

String - information about this instance.
toString
()

Overrides java.lang.Object.toString.

This returns a String representation of this Namespace, suitable for use in debugging.
private Object

Returns:

the Namespace proxy instance.
writeReplace
()

Serializes Namespace by using a proxy serialization instance.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

namespacemapback to summary
private static final ConcurrentMap<String, ConcurrentMap<String, Namespace>> namespacemap

Factory list of namespaces. Keys are URI&prefix. Values are Namespace objects

NO_NAMESPACEback to summary
public static final Namespace NO_NAMESPACE

Define a Namespace for when not in a namespace

prefixback to summary
private final transient String prefix

The prefix mapped to this namespace

serialVersionUIDback to summary
private static final long serialVersionUID

JDOM 2.0.0 Serialization version

uriback to summary
private final transient String uri

The URI for this namespace

XML_NAMESPACEback to summary
public static final Namespace XML_NAMESPACE

Define a Namespace for the standard xml prefix.

XMLNS_NAMESPACEback to summary
private static final Namespace XMLNS_NAMESPACE

Constructor Detail

Namespaceback to summary
private Namespace(final String prefix, final String uri)

This constructor handles creation of a Namespace object with a prefix and URI; it is intentionally left private so that it cannot be invoked by external programs/code.

Parameters
prefix:String

String prefix to map to this namespace.

uri:String

String URI for namespace.

Method Detail

equalsback to summary
public boolean equals(final Object ob)

Overrides java.lang.Object.equals.

This tests for equality - Two Namespaces are equal if and only if their URIs are byte-for-byte equals.

Parameters
ob:Object

Object to compare to this Namespace.

Returns:boolean

boolean - whether the supplied object is equal to this Namespace.

Annotations
@Override
getNamespaceback to summary
public static Namespace getNamespace(final String prefix, final String uri)

This will retrieve (if in existence) or create (if not) a Namespace for the supplied prefix and uri. This method is thread-safe.

Parameters
prefix:String

String prefix to map to Namespace.

uri:String

String URI of new Namespace.

Returns:Namespace

Namespace - ready to use namespace.

Exceptions
IllegalNameException:
if the given prefix and uri make up an illegal namespace name.
See Also
Verifier#checkNamespacePrefix(String), Verifier#checkNamespaceURI(String)
getNamespaceback to summary
public static Namespace getNamespace(final String uri)

This will retrieve (if in existence) or create (if not) a Namespace for the supplied URI, and make it usable as a default namespace, as no prefix is supplied. This method is thread-safe.

Parameters
uri:String

String URI of new Namespace.

Returns:Namespace

Namespace - ready to use namespace.

getPrefixback to summary
public String getPrefix()

This returns the prefix mapped to this Namespace.

Returns:String

String - prefix for this Namespace.

getURIback to summary
public String getURI()

This returns the namespace URI for this Namespace.

Returns:String

String - URI for this Namespace.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

This returns the hash code for the Namespace that conforms to the 'equals()' contract.

If two namespaces have the same URI, they are equal and have the same hash code, even if they have different prefixes.

Returns:int

int - hash code for this Namespace.

Annotations
@Override
readResolveback to summary
private Object readResolve() throws InvalidObjectException

Because Namespace is serialized by proxy, the reading of direct Namespace instances is illegal and prohibited.

Returns:Object

nothing.

Exceptions
InvalidObjectException:
always
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

This returns a String representation of this Namespace, suitable for use in debugging.

Returns:String

String - information about this instance.

Annotations
@Override
writeReplaceback to summary
private Object writeReplace()

Serializes Namespace by using a proxy serialization instance.

Returns:Object

the Namespace proxy instance.

Serial data
The proxy deals with the protocol.
org.jdom2 back to summary

private final Class Namespace.NamespaceSerializationProxy

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable

Field Summary

Modifier and TypeField and Description
private final String
private final String
private static final long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private Object
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

pprefixback to summary
private final String pprefix
puriback to summary
private final String puri
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

NamespaceSerializationProxyback to summary
public NamespaceSerializationProxy(String pprefix, String puri)

Method Detail

readResolveback to summary
private Object readResolve()