org.dom4j.tree
Class DefaultEntity

java.lang.Object
  extended byorg.dom4j.tree.AbstractNode
      extended byorg.dom4j.tree.AbstractEntity
          extended byorg.dom4j.tree.FlyweightEntity
              extended byorg.dom4j.tree.DefaultEntity
All Implemented Interfaces:
Cloneable, Entity, Node, Serializable
Direct Known Subclasses:
DOMEntityReference

public class DefaultEntity
extends FlyweightEntity

DefaultEntity is the default Entity implementation. It is a doubly linked node which supports the parent relationship and can be modified in place.

Version:
$Revision: 1.11 $
Author:
James Strachan
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.dom4j.tree.FlyweightEntity
name, text
 
Fields inherited from class org.dom4j.tree.AbstractNode
NODE_TYPE_NAMES
 
Fields inherited from interface org.dom4j.Node
ANY_NODE, ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_REFERENCE_NODE, MAX_NODE_TYPE, NAMESPACE_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE, UNKNOWN_NODE
 
Constructor Summary
DefaultEntity(Element parent, String name, String text)
          Creates the Entity with the specified name and text.
DefaultEntity(String name)
          Creates the Entity with the specified name
DefaultEntity(String name, String text)
          Creates the Entity with the specified name and text.
 
Method Summary
 Element getParent()
           getParent returns the parent Element if this node supports the parent relationship or null if it is the root element or does not support the parent relationship.
 boolean isReadOnly()
           isReadOnly returns true if this node is read only and cannot be modified.
 void setName(String name)
           Sets the text data of this node or this method will throw an UnsupportedOperationException if it is read-only.
 void setParent(Element parent)
           setParent sets the parent relationship of this node if the parent relationship is supported or does nothing if the parent relationship is not supported.
 void setText(String text)
          sets the value of the entity if it is not defined yet otherwise an UnsupportedOperationException is thrown as this class is read only.
 boolean supportsParent()
           supportsParent returns true if this node supports the parent relationship.
 
Methods inherited from class org.dom4j.tree.FlyweightEntity
createXPathResult, getName, getText
 
Methods inherited from class org.dom4j.tree.AbstractEntity
accept, asXML, getNodeType, getPath, getStringValue, getUniquePath, toString, write
 
Methods inherited from class org.dom4j.tree.AbstractNode
asXPathResult, clone, createPattern, createXPath, createXPathFilter, detach, getDocument, getDocumentFactory, getNodeTypeName, getPath, getUniquePath, hasContent, matches, numberValueOf, selectNodes, selectNodes, selectNodes, selectObject, selectSingleNode, setDocument, valueOf
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.dom4j.Node
asXPathResult, clone, createXPath, detach, getDocument, getNodeTypeName, getPath, getUniquePath, hasContent, matches, numberValueOf, selectNodes, selectNodes, selectNodes, selectObject, selectSingleNode, setDocument, valueOf
 

Constructor Detail

DefaultEntity

public DefaultEntity(String name)
Creates the Entity with the specified name

Parameters:
name - is the name of the entity

DefaultEntity

public DefaultEntity(String name,
                     String text)
Creates the Entity with the specified name and text.

Parameters:
name - is the name of the entity
text - is the text of the entity

DefaultEntity

public DefaultEntity(Element parent,
                     String name,
                     String text)
Creates the Entity with the specified name and text.

Parameters:
parent - is the parent element
name - is the name of the entity
text - is the text of the entity
Method Detail

setName

public void setName(String name)
Description copied from interface: Node

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

Specified by:
setName in interface Node
Overrides:
setName in class AbstractNode

setText

public void setText(String text)
Description copied from class: FlyweightEntity
sets the value of the entity if it is not defined yet otherwise an UnsupportedOperationException is thrown as this class is read only.

Specified by:
setText in interface Node
Overrides:
setText in class FlyweightEntity
Parameters:
text - DOCUMENT ME!

getParent

public Element getParent()
Description copied from interface: Node

getParent returns the parent Element if this node supports the parent relationship or null if it is the root element or does not support the parent relationship.

This method is an optional feature and may not be supported for all Node implementations.

Specified by:
getParent in interface Node
Overrides:
getParent in class AbstractNode

setParent

public void setParent(Element parent)
Description copied from interface: Node

setParent sets the parent relationship of this node if the parent relationship is supported or does nothing if the parent relationship is not supported.

This method should only be called from inside an Element implementation method and is not intended for general use.

Specified by:
setParent in interface Node
Overrides:
setParent in class AbstractNode

supportsParent

public boolean supportsParent()
Description copied from interface: Node

supportsParent returns true if this node supports the parent relationship.

Some XML tree implementations are singly linked and only support downward navigation through children relationships. The default case is that both parent and children relationships are supported though for memory and performance reasons the parent relationship may not be supported.

Specified by:
supportsParent in interface Node
Overrides:
supportsParent in class AbstractNode

isReadOnly

public boolean isReadOnly()
Description copied from interface: Node

isReadOnly returns true if this node is read only and cannot be modified. Any attempt to modify a read-only Node will result in an UnsupportedOperationException being thrown.

Specified by:
isReadOnly in interface Node
Overrides:
isReadOnly in class AbstractNode


Copyright © 2001-2005 MetaStuff Ltd.. All Rights Reserved.