Package org.opensextant.giscore
Class Namespace
java.lang.Object
org.opensextant.giscore.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.43 $, $Date: 2007/11/10 05:28:59 $
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionboolean
This tests for equality - TwoNamespaces
are equal if and only if their URIs are byte-for-byte equals.static @NotNull 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 @NotNull Namespace
getNamespace
(String prefix, String uri) This will retrieve (if in existence) or create (if not) aNamespace
for the supplied prefix and URI.@NotNull String
This returns the prefix mapped to thisNamespace
.@NotNull String
getURI()
This returns the namespace URI for thisNamespace
.int
hashCode()
This returns a probably unique hash code for theNamespace
.toString()
This returns aString
representation of thisNamespace
, suitable for use in debugging.
-
Field Details
-
NO_NAMESPACE
Define aNamespace
for when not in a namespace -
XML_NAMESPACE
Define aNamespace
for the standard xml prefix.
-
-
Method Details
-
getNamespace
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:
IllegalArgumentException
- if the given prefix and uri make up an illegal namespace name.
-
getNamespace
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
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 - TwoNamespaces
are equal if and only if their URIs are byte-for-byte equals. -
toString
This returns aString
representation 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.
-