org.dom4j.tree
Class FlyweightEntity

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

public class FlyweightEntity
extends AbstractEntity

FlyweightEntity is a Flyweight pattern implementation of a singly linked, read-only XML entity.

This node could be shared across documents and elements though it does not support the parent relationship.

Often this node needs to be created and then the text content added later (for example in SAX) so this implementation allows a call to setText(java.lang.String) providing the entity has no text already.

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

Field Summary
protected  java.lang.String name
          The name of the Entity
protected  java.lang.String text
          The text of the Entity
 
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
protected FlyweightEntity()
          A default constructor for implementors to use.
  FlyweightEntity(java.lang.String name)
          Creates the Entity with the specified name
  FlyweightEntity(java.lang.String name, java.lang.String text)
          Creates the Entity with the specified name and text.
 
Method Summary
protected  Node createXPathResult(Element parent)
           
 java.lang.String getName()
          getName returns the name of this node.
 java.lang.String getText()
          Returns the text of this node.
 void setText(java.lang.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.
 
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, getParent, getPath, getUniquePath, hasContent, isReadOnly, matches, numberValueOf, selectNodes, selectNodes, selectNodes, selectObject, selectSingleNode, setDocument, setName, setParent, supportsParent, 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, getParent, getPath, getUniquePath, hasContent, isReadOnly, matches, numberValueOf, selectNodes, selectNodes, selectNodes, selectObject, selectSingleNode, setDocument, setName, setParent, supportsParent, valueOf
 

Field Detail

name

protected java.lang.String name
The name of the Entity


text

protected java.lang.String text
The text of the Entity

Constructor Detail

FlyweightEntity

protected FlyweightEntity()
A default constructor for implementors to use.


FlyweightEntity

public FlyweightEntity(java.lang.String name)
Creates the Entity with the specified name

Parameters:
name - is the name of the entity

FlyweightEntity

public FlyweightEntity(java.lang.String name,
                       java.lang.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
Method Detail

getName

public java.lang.String getName()
Description copied from interface: Node

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.

Specified by:
getName in interface Node
Overrides:
getName in class AbstractNode
Returns:
the name of the entity

getText

public java.lang.String getText()
Description copied from interface: Node

Returns the text of this node.

Specified by:
getText in interface Node
Overrides:
getText in class AbstractNode
Returns:
the text of the entity

setText

public void setText(java.lang.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.

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

createXPathResult

protected Node createXPathResult(Element parent)
Overrides:
createXPathResult in class AbstractNode


Copyright © 2004 MetaStuff Ltd. All Rights Reserved. Hosted by

SourceForge Logo