Package org.jdom
Class Namespace
- java.lang.Object
-
- org.jdom.Namespace
-
- All Implemented Interfaces:
Serializable
public final class Namespace extends Object implements Serializable
An XML namespace representation, as well as a factory for creating XML namespace objects. All methods on Namespace (includinggetNamespace(String)
andgetNamespace(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.- See Also:
NamespaceAware
, Serialized Form
-
-
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(Object ob)
This tests for equality - TwoNamespaces
are equal if and only if their URIs are byte-for-byte equals.static Namespace
getNamespace(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(String prefix, String uri)
This will retrieve (if in existence) or create (if not) aNamespace
for the supplied prefix and uri.String
getPrefix()
This returns the prefix mapped to thisNamespace
.String
getURI()
This returns the namespace URI for thisNamespace
.int
hashCode()
This returns the hash code for theNamespace
that conforms to the 'equals()' contract.String
toString()
This returns aString
representation of thisNamespace
, suitable for use in debugging.
-
-
-
Method Detail
-
getNamespace
public static Namespace getNamespace(String prefix, String uri)
This will retrieve (if in existence) or create (if not) aNamespace
for the supplied prefix and uri. This method is thread-safe.- 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.- See Also:
Verifier.checkNamespacePrefix(String)
,Verifier.checkNamespaceURI(String)
-
getNamespace
public static Namespace getNamespace(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. This method is thread-safe.- Parameters:
uri
-String
URI of newNamespace
.- Returns:
Namespace
- ready to use namespace.
-
getPrefix
public String getPrefix()
This returns the prefix mapped to thisNamespace
.- Returns:
String
- prefix for thisNamespace
.
-
getURI
public String getURI()
This returns the namespace URI for thisNamespace
.- Returns:
String
- URI for thisNamespace
.
-
equals
public boolean equals(Object ob)
This tests for equality - TwoNamespaces
are equal if and only if their URIs are byte-for-byte equals.
-
toString
public String toString()
This returns aString
representation of thisNamespace
, suitable for use in debugging.
-
hashCode
public int hashCode()
This returns the hash code for theNamespace
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.
-
-