Class FlyweightEntity

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, Entity, Node
    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.

    See Also:
    Serialized Form
    • 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()
        DOCUMENT ME!
        Specified by:
        getName in interface Node
        Overrides:
        getName in class AbstractNode
        Returns:
        the name of the entity
      • getText

        public java.lang.String getText()
        DOCUMENT ME!
        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
        Parameters:
        text - DOCUMENT ME!
        Throws:
        java.lang.UnsupportedOperationException - DOCUMENT ME!