Package org.jdom2

Class EntityRef

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, NamespaceAware
    Direct Known Subclasses:
    LocatedEntityRef

    public class EntityRef
    extends Content
    An XML entity reference. Methods allow the user to manage its name, public id, and system id.
    Author:
    Brett McLaughlin, Jason Hunter, Philip Nelson, Rolf Lear
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String name
      The name of the EntityRef
      protected java.lang.String publicID
      The PublicID of the EntityRef
      protected java.lang.String systemID
      The SystemID of the EntityRef
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected EntityRef()
      Default, no-args constructor for implementations to use if needed.
        EntityRef​(java.lang.String name)
      This will create a new EntityRef with the supplied name.
        EntityRef​(java.lang.String name, java.lang.String systemID)
      This will create a new EntityRef with the supplied name and system id.
        EntityRef​(java.lang.String name, java.lang.String publicID, java.lang.String systemID)
      This will create a new EntityRef with the supplied name, public id, and system id.
    • Field Detail

      • name

        protected java.lang.String name
        The name of the EntityRef
      • publicID

        protected java.lang.String publicID
        The PublicID of the EntityRef
      • systemID

        protected java.lang.String systemID
        The SystemID of the EntityRef
    • Constructor Detail

      • EntityRef

        protected EntityRef()
        Default, no-args constructor for implementations to use if needed.
      • EntityRef

        public EntityRef​(java.lang.String name)
        This will create a new EntityRef with the supplied name.
        Parameters:
        name - String name of element.
        Throws:
        IllegalNameException - if the given name is not a legal XML name.
      • EntityRef

        public EntityRef​(java.lang.String name,
                         java.lang.String systemID)
        This will create a new EntityRef with the supplied name and system id.
        Parameters:
        name - String name of element.
        systemID - system id of the entity reference being constructed
        Throws:
        IllegalNameException - if the given name is not a legal XML name.
        IllegalDataException - if the given system ID is not a legal system literal.
      • EntityRef

        public EntityRef​(java.lang.String name,
                         java.lang.String publicID,
                         java.lang.String systemID)
        This will create a new EntityRef with the supplied name, public id, and system id.
        Parameters:
        name - String name of element.
        publicID - public id of the entity reference being constructed
        systemID - system id of the entity reference being constructed
        Throws:
        IllegalDataException - if the given system ID is not a legal system literal or the the given public ID is not a legal public ID
        IllegalNameException - if the given name is not a legal XML name.
    • Method Detail

      • getName

        public java.lang.String getName()
        This returns the name of the EntityRef.
        Returns:
        String - entity name.
      • getValue

        public java.lang.String getValue()
        Returns the empty string since entity references don't have an XPath 1.0 string value.
        Specified by:
        getValue in class Content
        Returns:
        the empty string
      • getPublicID

        public java.lang.String getPublicID()
        This will return the publid ID of this EntityRef. If there is no public ID, then this returns null.
        Returns:
        public ID of this EntityRef
      • getSystemID

        public java.lang.String getSystemID()
        This will return the system ID of this EntityRef. If there is no system ID, then this returns null.
        Returns:
        system ID of this EntityRef
      • setName

        public EntityRef setName​(java.lang.String name)
        This will set the name of this EntityRef.
        Parameters:
        name - new name of the entity
        Returns:
        this EntityRef modified.
        Throws:
        IllegalNameException - if the given name is not a legal XML name.
      • setPublicID

        public EntityRef setPublicID​(java.lang.String publicID)
        This will set the public ID of this EntityRef.
        Parameters:
        publicID - new public id
        Returns:
        this EntityRef modified.
        Throws:
        IllegalDataException - if the given public ID is not a legal public ID.
      • setSystemID

        public EntityRef setSystemID​(java.lang.String systemID)
        This will set the system ID of this EntityRef.
        Parameters:
        systemID - new system id
        Returns:
        this EntityRef modified.
        Throws:
        IllegalDataException - if the given system ID is not a legal system literal.
      • toString

        public java.lang.String toString()
        This returns a String representation of the EntityRef, suitable for debugging.
        Overrides:
        toString in class java.lang.Object
        Returns:
        String - information about the EntityRef
      • detach

        public EntityRef detach()
        Description copied from class: Content
        Detaches this child from its parent or does nothing if the child has no parent.

        This method can be overridden by particular Content subclasses to return a specific type of Content (co-variant return type). All overriding subclasses must call super.detach();

        Overrides:
        detach in class Content
        Returns:
        this child detached
      • setParent

        protected EntityRef setParent​(Parent parent)
        Description copied from class: Content
        Sets the parent of this Content. The caller is responsible for removing any pre-existing parentage.

        This method can be overridden by particular Content subclasses to return a specific type of Content (co-variant return type). All overriding subclasses must call super.setParent(Parent);

        Overrides:
        setParent in class Content
        Parameters:
        parent - new parent element
        Returns:
        the target element
      • getParent

        public Element getParent()
        Description copied from class: Content
        Return this child's parent, or null if this child is currently not attached. The parent can be either an Element or a Document.

        This method can be overridden by particular Content subclasses to return a specific type of Parent (co-variant return type). All overriding subclasses must call super.getParent();

        Overrides:
        getParent in class Content
        Returns:
        this child's parent or null if none
      • clone

        public EntityRef clone()
        Return a deep clone of this instance. Even if this instance has a parent, the returned clone will not.

        All JDOM core classes are Cloneable, and never throw CloneNotSupportedException. Additionally all Cloneable JDOM classes return the correct type of instance from this method and there is no need to cast the result (co-variant return vaue).

        Subclasses of this should still call super.clone() in their clone method.

        Overrides:
        clone in class Content