Package org.jdom
Class Namespace
- java.lang.Object
-
- org.jdom.Namespace
-
public final class Namespace extends java.lang.Object
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.- Version:
- $Revision: 1.44 $, $Date: 2008/12/17 23:22:48 $
- Author:
- Brett McLaughlin, Elliotte Rusty Harold, Jason Hunter, Wesley Biggs
-
-
Field Summary
Fields Modifier and Type Field Description static Namespace
NO_NAMESPACE
Define aNamespace
for when not in a namespacestatic Namespace
XML_NAMESPACE
Define aNamespace
for the standard xml prefix.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object ob)
This tests for equality - TwoNamespaces
are equal if and only if their URIs are byte-for-byte equals.static Namespace
getNamespace(java.lang.String uri)
This will retrieve (if in existence) or create (if not) aNamespace
for the supplied URI, and make it usable as a default namespace, as no prefix is supplied.static Namespace
getNamespace(java.lang.String prefix, java.lang.String uri)
This will retrieve (if in existence) or create (if not) aNamespace
for the supplied prefix and URI.java.lang.String
getPrefix()
This returns the prefix mapped to thisNamespace
.java.lang.String
getURI()
This returns the namespace URI for thisNamespace
.int
hashCode()
This returns a probably unique hash code for theNamespace
.java.lang.String
toString()
This returns aString
representation of thisNamespace
, suitable for use in debugging.
-
-
-
Method Detail
-
getNamespace
public static Namespace getNamespace(java.lang.String prefix, java.lang.String uri)
This will retrieve (if in existence) or create (if not) aNamespace
for the supplied prefix and URI.- Parameters:
prefix
-String
prefix to map toNamespace
.uri
-String
URI of newNamespace
.- Returns:
Namespace
- ready to use namespace.- Throws:
IllegalNameException
- if the given prefix and uri make up an illegal namespace name.
-
getNamespace
public static Namespace getNamespace(java.lang.String uri)
This will retrieve (if in existence) or create (if not) aNamespace
for the supplied URI, and make it usable as a default namespace, as no prefix is supplied.- Parameters:
uri
-String
URI of newNamespace
.- Returns:
Namespace
- ready to use namespace.
-
getPrefix
public java.lang.String getPrefix()
This returns the prefix mapped to thisNamespace
.- Returns:
String
- prefix for thisNamespace
.
-
getURI
public java.lang.String getURI()
This returns the namespace URI for thisNamespace
.- Returns:
String
- URI for thisNamespace
.
-
equals
public boolean equals(java.lang.Object ob)
This tests for equality - TwoNamespaces
are equal if and only if their URIs are byte-for-byte equals.- Overrides:
equals
in classjava.lang.Object
- Parameters:
ob
-Object
to compare to thisNamespace
.- Returns:
boolean
- whether the supplied object is equal to thisNamespace
.
-
toString
public java.lang.String toString()
This returns aString
representation of thisNamespace
, suitable for use in debugging.- Overrides:
toString
in classjava.lang.Object
- Returns:
String
- information about this instance.
-
hashCode
public int hashCode()
This returns a probably unique hash code for theNamespace
. If two namespaces have the same URI, they are equal and have the same hash code, even if they have different prefixes.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
int
- hash code for thisNamespace
.
-
-