Top Description Fields Constructors Methods
org.dom4j.tree

public abstract Class AbstractAttribute

extends AbstractNode
implements Attribute
Class Inheritance
All Implemented Interfaces
org.dom4j.Attribute, org.dom4j.Node, java.lang.Cloneable
Known Direct Subclasses
org.dom4j.tree.FlyweightAttribute, org.dom4j.bean.BeanAttribute, org.dom4j.datatype.DatatypeAttribute
Imports
org.dom4j.*, java.io.IOException, .Writer

AbstractNamespace is an abstract base class for tree implementors to use for implementation inheritence.

Author
James Strachan
Version
$Revision: 1.21 $

Field Summary

Inherited from org.dom4j.tree.AbstractNode:
NODE_TYPE_NAMES

Constructor Summary

AccessConstructor and Description
public

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 Node
public Object
getData()

Implements org.dom4j.Attribute.getData.

Accesses the data of this attribute which may implement data typing bindings such as XML Schema or Java Bean bindings or will return the same value as Node#getText().
public String
getName()

Overrides org.dom4j.tree.AbstractNode.getName.

Implements org.dom4j.Node.getName.

getName returns the name of this node.

public Namespace
getNamespace()

Implements org.dom4j.Attribute.getNamespace.

Returns the Namespace of this element if one exists otherwise null is returned returned.
public String
getNamespacePrefix()

Implements org.dom4j.Attribute.getNamespacePrefix.

Returns the namespace prefix of this element if one exists otherwise an empty String is returned.
public String
getNamespaceURI()

Implements org.dom4j.Attribute.getNamespaceURI.

Returns the URI mapped to the namespace of this element if one exists otherwise an empty String is returned.
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
getQualifiedName()

Implements org.dom4j.Attribute.getQualifiedName.

Returns the fully qualified name of this element.
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 void
setData(Object
the attribute data
data
)

Implements org.dom4j.Attribute.setData.

Sets the data value of this attribute if this element supports data binding or calls Node#setText(String)if it doesn't.
public void
setNamespace(Namespace
is the Namespace to associate with this element
namespace
)

Implements org.dom4j.Attribute.setNamespace.

Sets the Namespace of this element or if this element is read only then an UnsupportedOperationException is thrown.
public void
setText(String
is the new textual value of this node
text
)

Overrides org.dom4j.tree.AbstractNode.setText.

Implements org.dom4j.Node.setText.

Sets the text data of this node or this method will throw an UnsupportedOperationException if it is read-only.

public void
setValue(String
is the new value of this attribute
value
)

Implements org.dom4j.Attribute.setValue.

Sets the value of this attribute or this method will throw an UnsupportedOperationException if it is read-only.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public void
write(Writer
is the Writer to output the XML to
writer
)

Overrides org.dom4j.tree.AbstractNode.write.

Implements org.dom4j.Node.write.

write writes this node as the default XML notation for this node.

Inherited from org.dom4j.tree.AbstractNode:
asXPathResultclonecreatePatterncreateXPathcreateXPathFilterdetachgetDocumentgetDocumentFactorygetNodeTypeNamegetParentgetPathgetStringValuegetUniquePathhasContentisReadOnlymatchesnumberValueOfselectNodesselectNodesselectNodesselectObjectselectSingleNodesetDocumentsetNamesetParentsupportsParentvalueOf

Constructor Detail

AbstractAttributeback to summary
public AbstractAttribute()

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

createXPathResultback to summary
protected Node createXPathResult(Element parent)

Overrides org.dom4j.tree.AbstractNode.createXPathResult.

getDataback to summary
public Object getData()

Implements org.dom4j.Attribute.getData.

Doc from org.dom4j.Attribute.getData.

Accesses the data of this attribute which may implement data typing bindings such as XML Schema or Java Bean bindings or will return the same value as Node#getText().

Returns:Object

the attribute data

getNameback to summary
public String getName()

Overrides org.dom4j.tree.AbstractNode.getName.

Implements org.dom4j.Node.getName.

Doc from org.dom4j.Node.getName.

getName returns the name of this node. This is the XML local name of the element, attribute, entity or processing instruction. For CDATA and Text nodes this method will return null.

Returns:String

the XML name of this node

getNamespaceback to summary
public Namespace getNamespace()

Implements org.dom4j.Attribute.getNamespace.

Doc from org.dom4j.Attribute.getNamespace.

Returns the Namespace of this element if one exists otherwise null is returned returned.

Returns:Namespace

the Namespace associated with this node

getNamespacePrefixback to summary
public String getNamespacePrefix()

Implements org.dom4j.Attribute.getNamespacePrefix.

Doc from org.dom4j.Attribute.getNamespacePrefix.

Returns the namespace prefix of this element if one exists otherwise an empty String is returned.

Returns:String

the prefix of the Namespace of this element or an empty String

getNamespaceURIback to summary
public String getNamespaceURI()

Implements org.dom4j.Attribute.getNamespaceURI.

Doc from org.dom4j.Attribute.getNamespaceURI.

Returns the URI mapped to the namespace of this element if one exists otherwise an empty String is returned.

Returns:String

the URI for the Namespace of this element or an empty String

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.

getQualifiedNameback to summary
public String getQualifiedName()

Implements org.dom4j.Attribute.getQualifiedName.

Doc from org.dom4j.Attribute.getQualifiedName.

Returns the fully qualified name of this element. This will be the same as the value returned from Node#getName() if this element has no namespace attached to this element or an expression of the form

getNamespacePrefix() + ":" + getName()
will be returned.
Returns:String

the fully qualified name of the element

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.

setDataback to summary
public void setData(Object data)

Implements org.dom4j.Attribute.setData.

Doc from org.dom4j.Attribute.setData.

Sets the data value of this attribute if this element supports data binding or calls Node#setText(String)if it doesn't.

Parameters
data:Object

the attribute data

setNamespaceback to summary
public void setNamespace(Namespace namespace)

Implements org.dom4j.Attribute.setNamespace.

Doc from org.dom4j.Attribute.setNamespace.

Sets the Namespace of this element or if this element is read only then an UnsupportedOperationException is thrown.

Parameters
namespace:Namespace

is the Namespace to associate with this element

setTextback to summary
public void setText(String text)

Overrides org.dom4j.tree.AbstractNode.setText.

Implements org.dom4j.Node.setText.

Doc from org.dom4j.Node.setText.

Sets the text data of this node or this method will throw an UnsupportedOperationException if it is read-only.

Parameters
text:String

is the new textual value of this node

setValueback to summary
public void setValue(String value)

Implements org.dom4j.Attribute.setValue.

Doc from org.dom4j.Attribute.setValue.

Sets the value of this attribute or this method will throw an UnsupportedOperationException if it is read-only.

Parameters
value:String

is the new value of this attribute

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.

writeback to summary
public void write(Writer writer) throws IOException

Overrides org.dom4j.tree.AbstractNode.write.

Implements org.dom4j.Node.write.

Doc from org.dom4j.Node.write.

write writes this node as the default XML notation for this node. If you wish to control the XML output (such as for pretty printing, changing the indentation policy etc.) then please use org.dom4j.io.XMLWriter or its derivations.

Parameters
writer:Writer

is the Writer to output the XML to

Exceptions
IOException:
DOCUMENT ME!