Package org.jdom
Class Namespace
java.lang.Object
org.jdom.Namespace
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 -
Method Summary
Modifier and TypeMethodDescriptionbooleanThis tests for equality - TwoNamespacesare equal if and only if their URIs are byte-for-byte equals.static NamespacegetNamespace(String uri) This will retrieve (if in existence) or create (if not) aNamespacefor the supplied URI, and make it usable as a default namespace, as no prefix is supplied.static NamespacegetNamespace(String prefix, String uri) This will retrieve (if in existence) or create (if not) aNamespacefor the supplied prefix and URI.This returns the prefix mapped to thisNamespace.getURI()This returns the namespace URI for thisNamespace.inthashCode()This returns a probably unique hash code for theNamespace.toString()This returns aStringrepresentation of thisNamespace, suitable for use in debugging.
-
Field Details
-
NO_NAMESPACE
Define aNamespacefor when not in a namespace -
XML_NAMESPACE
Define aNamespacefor the standard xml prefix.
-
-
Method Details
-
getNamespace
This will retrieve (if in existence) or create (if not) aNamespacefor the supplied prefix and URI.- Parameters:
prefix-Stringprefix to map toNamespace.uri-StringURI of newNamespace.- Returns:
Namespace- ready to use namespace.- Throws:
IllegalNameException- if the given prefix and uri make up an illegal namespace name.
-
getNamespace
This will retrieve (if in existence) or create (if not) aNamespacefor the supplied URI, and make it usable as a default namespace, as no prefix is supplied.- Parameters:
uri-StringURI of newNamespace.- Returns:
Namespace- ready to use namespace.
-
getPrefix
This returns the prefix mapped to thisNamespace.- Returns:
String- prefix for thisNamespace.
-
getURI
This returns the namespace URI for thisNamespace.- Returns:
String- URI for thisNamespace.
-
equals
This tests for equality - TwoNamespacesare equal if and only if their URIs are byte-for-byte equals. -
toString
This returns aStringrepresentation of thisNamespace, suitable for use in debugging. -
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.
-