Top Description Fields Constructors Methods
org.dom4j.tree

public Class FlyweightEntity

extends AbstractEntity
Class Inheritance
Known Direct Subclasses
org.dom4j.tree.DefaultEntity
Imports
org.dom4j.Element, .Node

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 providing the entity has no text already.

Author
James Strachan
Version
$Revision: 1.6 $

Field Summary

Modifier and TypeField and Description
protected String
name

The name of the Entity

protected String
text

The text of the Entity

Constructor Summary

AccessConstructor and Description
protected
FlyweightEntity()

A default constructor for implementors to use.

public
FlyweightEntity(String
is the name of the entity
name
)

Creates the Entity with the specified name

public
FlyweightEntity(String
is the name of the entity
name
,
String
is the text of the entity
text
)

Creates the Entity with the specified name and text.

Method Summary

Modifier and TypeMethod and Description
protected Node
public String

Returns:

the name of the entity
getName
()

Overrides org.dom4j.tree.AbstractNode.getName.

Implements org.dom4j.Node.getName.

DOCUMENT ME!
public String

Returns:

the text of the entity
getText
()

Overrides org.dom4j.tree.AbstractNode.getText.

Implements org.dom4j.Node.getText.

DOCUMENT ME!
public void
setText(String
DOCUMENT ME!
text
)

Overrides org.dom4j.tree.AbstractNode.setText.

Implements org.dom4j.Node.setText.

sets the value of the entity if it is not defined yet otherwise an UnsupportedOperationException is thrown as this class is read only.
Inherited from org.dom4j.tree.AbstractEntity:
acceptasXMLgetNodeTypegetPathgetStringValuegetUniquePathtoStringwrite

Field Detail

nameback to summary
protected String name

The name of the Entity

textback to summary
protected String text

The text of the Entity

Constructor Detail

FlyweightEntityback to summary
protected FlyweightEntity()

A default constructor for implementors to use.

FlyweightEntityback to summary
public FlyweightEntity(String name)

Creates the Entity with the specified name

Parameters
name:String

is the name of the entity

FlyweightEntityback to summary
public FlyweightEntity(String name, String text)

Creates the Entity with the specified name and text.

Parameters
name:String

is the name of the entity

text:String

is the text of the entity

Method Detail

createXPathResultback to summary
protected Node createXPathResult(Element parent)

Overrides org.dom4j.tree.AbstractNode.createXPathResult.

getNameback to summary
public String getName()

Overrides org.dom4j.tree.AbstractNode.getName.

Implements org.dom4j.Node.getName.

DOCUMENT ME!

Returns:String

the name of the entity

getTextback to summary
public String getText()

Overrides org.dom4j.tree.AbstractNode.getText.

Implements org.dom4j.Node.getText.

DOCUMENT ME!

Returns:String

the text of the entity

setTextback to summary
public void setText(String text)

Overrides org.dom4j.tree.AbstractNode.setText.

Implements org.dom4j.Node.setText.

sets the value of the entity if it is not defined yet otherwise an UnsupportedOperationException is thrown as this class is read only.

Parameters
text:String

DOCUMENT ME!

Exceptions
UnsupportedOperationException:
DOCUMENT ME!