Top Description Fields Constructors Methods
org.jdom

public final Class Namespace

extends Object
Class Inheritance
Imports
java.util.*

An XML namespace representation, as well as a factory for creating XML namespace objects. Namespaces are not Serializable, however objects that use namespaces have special logic to handle serialization manually. These classes call the getNamespace() method on deserialization to ensure there is one unique Namespace object for any unique prefix/uri pair.
Authors
Brett McLaughlin, Elliotte Rusty Harold, Jason Hunter, Wesley Biggs
Version
$Revision: 1.44 $, $Date: 2008/12/17 23:22:48 $

Field Summary

Modifier and TypeField and Description
private static final String
private static HashMap<K, V>
namespaces

Factory list of namespaces.

public static final Namespace
NO_NAMESPACE

Define a Namespace for when not in a namespace

private String
prefix

The prefix mapped to this namespace

private String
uri

The URI for this namespace

public static final Namespace
XML_NAMESPACE

Define a Namespace for the standard xml prefix.

Constructor Summary

AccessConstructor and Description
private
Namespace(String
String prefix to map to this namespace.
prefix
,
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
(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
(String
String prefix to map to Namespace.
prefix
,
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
(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 a probably unique hash code for the Namespace.
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.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

CVS_IDback to summary
private static final String CVS_ID
namespacesback to summary
private static HashMap<K, V> namespaces

Factory list of namespaces. Keys are prefix&URI. 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 String prefix

The prefix mapped to this namespace

uriback to summary
private 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.

Constructor Detail

Namespaceback to summary
private Namespace(String prefix, 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(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.

getNamespaceback to summary
public static Namespace getNamespace(String prefix, String uri)

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

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.
getNamespaceback to summary
public static Namespace getNamespace(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.

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 a probably unique hash code for the Namespace. 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.

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.