Top Description Fields Constructors Methods
org.dom4j

public Class Namespace

extends AbstractNode
Class Inheritance
Known Direct Subclasses
org.dom4j.tree.DefaultNamespace
Imports
org.dom4j.tree.AbstractNode, .DefaultNamespace, .NamespaceCache

Namespace is a Flyweight Namespace that can be shared amongst nodes.
Author
James Strachan
Version
$Revision: 1.22 $

Field Summary

Modifier and TypeField and Description
protected static final NamespaceCache
CACHE

Cache of Namespace instances

private int
hashCode

A cached version of the hashcode for efficiency

public static final Namespace
NO_NAMESPACE

No Namespace present

private String
prefix

The prefix mapped to this namespace

private String
uri

The URI for this namespace

public static final Namespace
XML_NAMESPACE

XML Namespace

Inherited from org.dom4j.tree.AbstractNode:
NODE_TYPE_NAMES

Constructor Summary

AccessConstructor and Description
public
Namespace(String
is the prefix for this namespace
prefix
,
String
is the URI for this namespace
uri
)

DOCUMENT ME!

Method Summary

Modifier and TypeMethod and Description
public void
accept(Visitor
is the visitor in the Visitor Pattern
visitor
)

Implements org.dom4j.Node.accept.

accept is the method used in the Visitor Pattern.

public String
asXML()

Implements org.dom4j.Node.asXML.

asXML returns the textual XML representation of this node.

protected int

Returns:

DOCUMENT ME!
createHashCode
()

Factory method to create the hashcode allowing derived classes to change the behaviour

protected Node
public boolean

Returns:

DOCUMENT ME!
equals
(Object
DOCUMENT ME!
object
)

Overrides java.lang.Object.equals.

Checks whether this Namespace equals the given Namespace.
public static Namespace

Returns:

an interned Namespace object
get
(String
DOCUMENT ME!
prefix
,
String
DOCUMENT ME!
uri
)

A helper method to return the Namespace instance for the given prefix and URI

public static Namespace

Returns:

an interned Namespace object
get
(String
DOCUMENT ME!
uri
)

A helper method to return the Namespace instance for no prefix and the URI

public short
getNodeType()

Overrides org.dom4j.tree.AbstractNode.getNodeType.

Implements org.dom4j.Node.getNodeType.

Returns the code according to the type of node.
public String
getPath(Element
is the parent context from which the relative path should start. If the context is null or the context is not an ancestor of this node then the path will be absolute and start from the document and so begin with the '/' character.
context
)

Implements org.dom4j.Node.getPath.

Returns the relative XPath expression which will return a node set containing the given node such as a/b/@c.
public String

Returns:

the prefix for this Namespace.
getPrefix
()

DOCUMENT ME!

public String
getStringValue()

Overrides org.dom4j.tree.AbstractNode.getStringValue.

Implements org.dom4j.Node.getStringValue.

Returns the XPath string-value of this node.
public String
getText()

Overrides org.dom4j.tree.AbstractNode.getText.

Implements org.dom4j.Node.getText.

Returns the text of this node.

public String
getUniquePath(Element
is the parent context from which the path should start. If the context is null or the context is not an ancestor of this node then the path will start from the document and so begin with the '/' character.
context
)

Implements org.dom4j.Node.getUniquePath.

Returns the relative unique XPath expression from the given context which will return a nodeset of one node which is the current node.

public String

Returns:

the URI for this Namespace.
getURI
()

DOCUMENT ME!

public String
public int

Returns:

the hash code based on the qualified name and the URI of the namespace.
hashCode
()

Overrides java.lang.Object.hashCode.

DOCUMENT ME!
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from org.dom4j.tree.AbstractNode:
asXPathResultclonecreatePatterncreateXPathcreateXPathFilterdetachgetDocumentgetDocumentFactorygetNamegetNodeTypeNamegetParentgetPathgetUniquePathhasContentisReadOnlymatchesnumberValueOfselectNodesselectNodesselectNodesselectObjectselectSingleNodesetDocumentsetNamesetParentsetTextsupportsParentvalueOfwrite

Field Detail

CACHEback to summary
protected static final NamespaceCache CACHE

Cache of Namespace instances

hashCodeback to summary
private int hashCode

A cached version of the hashcode for efficiency

NO_NAMESPACEback to summary
public static final Namespace NO_NAMESPACE

No Namespace present

prefixback to summary
private String prefix

The prefix mapped to this namespace

uriback to summary
private String uri

The URI for this namespace

XML_NAMESPACEback to summary
public static final Namespace XML_NAMESPACE

XML Namespace

Constructor Detail

Namespaceback to summary
public Namespace(String prefix, String uri)

DOCUMENT ME!

Parameters
prefix:String

is the prefix for this namespace

uri:String

is the URI for this namespace

Method Detail

acceptback to summary
public void accept(Visitor visitor)

Implements org.dom4j.Node.accept.

Doc from org.dom4j.Node.accept.

accept is the method used in the Visitor Pattern.

Parameters
visitor:Visitor

is the visitor in the Visitor Pattern

asXMLback to summary
public String asXML()

Implements org.dom4j.Node.asXML.

Doc from org.dom4j.Node.asXML.

asXML returns the textual XML representation of this node.

Returns:String

the XML representation of this node

createHashCodeback to summary
protected int createHashCode()

Factory method to create the hashcode allowing derived classes to change the behaviour

Returns:int

DOCUMENT ME!

createXPathResultback to summary
protected Node createXPathResult(Element parent)

Overrides org.dom4j.tree.AbstractNode.createXPathResult.

equalsback to summary
public boolean equals(Object object)

Overrides java.lang.Object.equals.

Checks whether this Namespace equals the given Namespace. Two Namespaces are equals if their URI and prefix are equal.

Parameters
object:Object

DOCUMENT ME!

Returns:boolean

DOCUMENT ME!

getback to summary
public static Namespace get(String prefix, String uri)

A helper method to return the Namespace instance for the given prefix and URI

Parameters
prefix:String

DOCUMENT ME!

uri:String

DOCUMENT ME!

Returns:Namespace

an interned Namespace object

getback to summary
public static Namespace get(String uri)

A helper method to return the Namespace instance for no prefix and the URI

Parameters
uri:String

DOCUMENT ME!

Returns:Namespace

an interned Namespace object

getNodeTypeback to summary
public short getNodeType()

Overrides org.dom4j.tree.AbstractNode.getNodeType.

Implements org.dom4j.Node.getNodeType.

Doc from org.dom4j.Node.getNodeType.

Returns the code according to the type of node. This makes processing nodes polymorphically much easier as the switch statement can be used instead of multiple if (instanceof) statements.

Returns:short

a W3C DOM complient code for the node type such as ELEMENT_NODE or ATTRIBUTE_NODE

getPathback to summary
public String getPath(Element context)

Implements org.dom4j.Node.getPath.

Doc from org.dom4j.Node.getPath.

Returns the relative XPath expression which will return a node set containing the given node such as a/b/@c. No indexing will be used to restrict the path if multiple elements with the same name occur on the path.

Parameters
context:Element

is the parent context from which the relative path should start. If the context is null or the context is not an ancestor of this node then the path will be absolute and start from the document and so begin with the '/' character.

Returns:String

the XPath expression relative to the given context which will return a nodeset containing at least this node.

getPrefixback to summary
public String getPrefix()

DOCUMENT ME!

Returns:String

the prefix for this Namespace.

getStringValueback to summary
public String getStringValue()

Overrides org.dom4j.tree.AbstractNode.getStringValue.

Implements org.dom4j.Node.getStringValue.

Doc from org.dom4j.Node.getStringValue.

Returns the XPath string-value of this node. The behaviour of this method is defined in the XPath specification .

Returns:String

the text from all the child Text and Element nodes appended together.

getTextback to summary
public String getText()

Overrides org.dom4j.tree.AbstractNode.getText.

Implements org.dom4j.Node.getText.

Doc from org.dom4j.Node.getText.

Returns the text of this node.

Returns:String

the text for this node.

getUniquePathback to summary
public String getUniquePath(Element context)

Implements org.dom4j.Node.getUniquePath.

Doc from org.dom4j.Node.getUniquePath.

Returns the relative unique XPath expression from the given context which will return a nodeset of one node which is the current node. This method will use the XPath index operator to restrict the path if multiple elements with the same name occur on the path.

Parameters
context:Element

is the parent context from which the path should start. If the context is null or the context is not an ancestor of this node then the path will start from the document and so begin with the '/' character.

Returns:String

the XPath expression relative to the given context which will return a nodeset containing just this node.

getURIback to summary
public String getURI()

DOCUMENT ME!

Returns:String

the URI for this Namespace.

getXPathNameStepback to summary
public String getXPathNameStep()
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

DOCUMENT ME!

Returns:int

the hash code based on the qualified name and the URI of the namespace.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.