All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class org.jdom.Namespace

java.lang.Object
   |
   +----org.jdom.Namespace

public final class Namespace
extends Object

Namespace defines both a factory for creating XML namespaces, and a namespace itself. This class represents an XML namespace in Java.

Elements and Attributes containing Namespaces can be serialized; however the Namespace class itself does not implement java.io.Serializable. This works because the Element and Attribute classes handle serialization of their Namespaces manually. The classes use the getNamespace() method on deserialization to ensure there may be only one unique Namespace object for any unique prefix/uri pair, something needed for efficiency reasons.

Version:
$Revision: 1.32 $, $Date: 2002/03/12 07:57:06 $
Author:
Brett McLaughlin, Elliotte Rusty Harold, Wesley Biggs

Variable Index

 o NO_NAMESPACE
Define a Namespace for when not in a namespace
 o XML_NAMESPACE

Method Index

 o equals(Object)

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

 o getNamespace(String)

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.

 o getNamespace(String, String)

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

 o getPrefix()

This returns the prefix mapped to this Namespace.

 o getURI()

This returns the namespace URI for this Namespace.

 o hashCode()

This returns a probably unique hash code for the Namespace.

 o toString()

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

Variables

 o NO_NAMESPACE
 public static final Namespace NO_NAMESPACE
Define a Namespace for when not in a namespace

 o XML_NAMESPACE
 public static final Namespace XML_NAMESPACE

Methods

 o getNamespace
 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 prefix to map to Namespace.
uri - String URI of new Namespace.
Returns:
Namespace - ready to use namespace.
Throws: IllegalNameException
if the given prefix and uri make up an illegal namespace name.
 o getNamespace
 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 URI of new Namespace.
Returns:
Namespace - ready to use namespace.
 o getPrefix
 public String getPrefix()

This returns the prefix mapped to this Namespace.

Returns:
String - prefix for this Namespace.
 o getURI
 public String getURI()

This returns the namespace URI for this Namespace.

Returns:
String - URI for this Namespace.
 o equals
 public boolean equals(Object ob)

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

Parameters:
ob - Object to compare to this Namespace.
Returns:
boolean - whether the supplied object is equal to this Namespace.
Overrides:
equals in class Object
 o toString
 public String toString()

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

Returns:
String - information about this instance.
Overrides:
toString in class Object
 o hashCode
 public int 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 - hash code for this Namespace.
Overrides:
hashCode in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index