Class AbstractElement

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, org.jdom2.NamespaceAware, org.jdom2.Parent
    Direct Known Subclasses:
    AbstractHtmlElementFactory

    @ConsumerType
    public abstract class AbstractElement
    extends org.jdom2.Element
    Generic DOM element. This element implementation is derived from JDOM element implementation.
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.jdom2.Content

        org.jdom2.Content.CType
    • Field Summary

      • Fields inherited from class org.jdom2.Element

        name, namespace
      • Fields inherited from class org.jdom2.Content

        ctype, parent
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractElement​(java.lang.String name)
      Initializes DOM element.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <T extends AbstractElement>
      T
      add​(T element)
      Appends the child to the end of the element's content list.
      org.jdom2.Element addContent​(int index, java.util.Collection collection)
      Inserts the content in a collection into the content list at the given index.
      org.jdom2.Element addContent​(int index, org.jdom2.Content content)
      Inserts the child into the content list at the given index
      org.jdom2.Element addContent​(java.lang.String text)
      This adds text content to this element.
      org.jdom2.Element addContent​(java.util.Collection collection)
      Appends all children in the given collection to the end of the content list.
      org.jdom2.Element addContent​(org.jdom2.Content content)
      Appends the child to the end of the element's content list
      int getAttributeValueAsInteger​(java.lang.String attributeName)
      Gets attribute value as integer.
      long getAttributeValueAsLong​(java.lang.String attributeName)
      Gets attribute value as long.
      org.jdom2.Element setAttribute​(java.lang.String name, java.lang.String value)
      This sets an attribute value for this element.
      org.jdom2.Element setAttribute​(java.lang.String name, java.lang.String value, org.jdom2.Namespace ns)
      This sets an attribute value for this element.
      AbstractElement setAttributeValueAsInteger​(java.lang.String name, int value)
      Sets attribute value as integer.
      AbstractElement setAttributeValueAsLong​(java.lang.String name, long value)
      Sets attribute value as long.
      org.jdom2.Element setText​(java.lang.String text)
      Sets the content of the element to be the text given.
      java.lang.String toString()  
      java.lang.String toStringContentOnly()  
      • Methods inherited from class org.jdom2.Element

        addNamespaceDeclaration, canContainContent, clone, cloneContent, coalesceText, detach, getAdditionalNamespaces, getAttribute, getAttribute, getAttributes, getAttributesSize, getAttributeValue, getAttributeValue, getAttributeValue, getAttributeValue, getChild, getChild, getChildren, getChildren, getChildren, getChildText, getChildText, getChildTextNormalize, getChildTextNormalize, getChildTextTrim, getChildTextTrim, getContent, getContent, getContent, getContentSize, getDescendants, getDescendants, getName, getNamespace, getNamespace, getNamespacePrefix, getNamespacesInherited, getNamespacesInScope, getNamespacesIntroduced, getNamespaceURI, getQualifiedName, getText, getTextNormalize, getTextTrim, getValue, getXMLBaseURI, hasAdditionalNamespaces, hasAttributes, indexOf, isAncestor, isRootElement, removeAttribute, removeAttribute, removeAttribute, removeChild, removeChild, removeChildren, removeChildren, removeContent, removeContent, removeContent, removeContent, removeNamespaceDeclaration, setAttribute, setAttributes, setContent, setContent, setContent, setContent, setName, setNamespace, sortAttributes, sortChildren, sortContent, sortContent
      • Methods inherited from class org.jdom2.Content

        equals, getCType, getDocument, getParent, getParentElement, hashCode, setParent
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface org.jdom2.Parent

        getDocument, getParent
    • Constructor Detail

      • AbstractElement

        protected AbstractElement​(java.lang.String name)
        Initializes DOM element.
        Parameters:
        name - Element name
    • Method Detail

      • getAttributeValueAsInteger

        public final int getAttributeValueAsInteger​(java.lang.String attributeName)
        Gets attribute value as integer.
        Parameters:
        attributeName - Attribute name
        Returns:
        Attribute value as integer or 0 if not set.
      • setAttributeValueAsLong

        public AbstractElement setAttributeValueAsLong​(java.lang.String name,
                                                       long value)
        Sets attribute value as long.
        Parameters:
        name - Attribute name
        value - Attribute value as long
        Returns:
        Self reference
      • getAttributeValueAsLong

        public final long getAttributeValueAsLong​(java.lang.String attributeName)
        Gets attribute value as long.
        Parameters:
        attributeName - Attribute name
        Returns:
        Attribute value as long or 0 if not set.
      • setAttributeValueAsInteger

        public final AbstractElement setAttributeValueAsInteger​(java.lang.String name,
                                                                int value)
        Sets attribute value as integer.
        Parameters:
        name - Attribute name
        value - Attribute value as integer
        Returns:
        Self reference
      • addContent

        public final org.jdom2.Element addContent​(org.jdom2.Content content)
        Appends the child to the end of the element's content list
        Specified by:
        addContent in interface org.jdom2.Parent
        Overrides:
        addContent in class org.jdom2.Element
        Parameters:
        content - Child to append to end of content list. Null values are ignored.
        Returns:
        The element on which the method was called.
      • addContent

        public final org.jdom2.Element addContent​(int index,
                                                  org.jdom2.Content content)
        Inserts the child into the content list at the given index
        Specified by:
        addContent in interface org.jdom2.Parent
        Overrides:
        addContent in class org.jdom2.Element
        Parameters:
        index - Location for adding the collection
        content - Child to append to end of content list. Null values are ignored.
        Returns:
        The element on which the method was called.
      • addContent

        public final org.jdom2.Element addContent​(java.lang.String text)
        This adds text content to this element. It does not replace the existing content as does setText().
        Overrides:
        addContent in class org.jdom2.Element
        Parameters:
        text - String to add. Null values are ignored.
        Returns:
        This element modified
      • addContent

        public final org.jdom2.Element addContent​(java.util.Collection collection)
        Appends all children in the given collection to the end of the content list. In event of an exception during add the original content will be unchanged and the objects in the supplied collection will be unaltered.
        Specified by:
        addContent in interface org.jdom2.Parent
        Overrides:
        addContent in class org.jdom2.Element
        Parameters:
        collection - Collection to append. Null values are ignored.
        Returns:
        the element on which the method was called
      • addContent

        public final org.jdom2.Element addContent​(int index,
                                                  java.util.Collection collection)
        Inserts the content in a collection into the content list at the given index. In event of an exception the original content will be unchanged and the objects in the supplied collection will be unaltered.
        Specified by:
        addContent in interface org.jdom2.Parent
        Overrides:
        addContent in class org.jdom2.Element
        Parameters:
        index - Location for adding the collection
        collection - Collection to insert. Null values are ignored.
        Returns:
        The parent on which the method was called
      • add

        public final <T extends AbstractElement> T add​(T element)
        Appends the child to the end of the element's content list. Returns not the element itself (contrary to addContent), but a reference to the newly added element.
        Type Parameters:
        T - Type that extends Element
        Parameters:
        element - Element to add. Null values are ignored.
        Returns:
        The added element.
      • setText

        public org.jdom2.Element setText​(java.lang.String text)
        Sets the content of the element to be the text given. All existing text content and non-text context is removed. If this element should have both textual content and nested elements, use Element.setContent(java.util.Collection<? extends org.jdom2.Content>) instead. Setting a null text value is equivalent to setting an empty string value.
        Overrides:
        setText in class org.jdom2.Element
        Parameters:
        text - new text content for the element
        Returns:
        the target element
        Throws:
        org.jdom2.IllegalDataException - if the assigned text contains an illegal character such as a vertical tab (as determined by Verifier.checkCharacterData(java.lang.String))
      • setAttribute

        public final org.jdom2.Element setAttribute​(java.lang.String name,
                                                    java.lang.String value,
                                                    org.jdom2.Namespace ns)

        This sets an attribute value for this element. Any existing attribute with the same name and namespace URI is removed.

        Overrides:
        setAttribute in class org.jdom2.Element
        Parameters:
        name - name of the attribute to set
        value - value of the attribute to set
        ns - namespace of the attribute to set
        Returns:
        this element modified
        Throws:
        org.jdom2.IllegalNameException - if the given name is illegal as an attribute name, or if the namespace is an unprefixed default namespace
        org.jdom2.IllegalDataException - if the given attribute value is illegal character data (as determined by Verifier.checkCharacterData(java.lang.String)).
        org.jdom2.IllegalAddException - if the attribute namespace prefix collides with another namespace prefix on the element.
      • setAttribute

        public final org.jdom2.Element setAttribute​(java.lang.String name,
                                                    java.lang.String value)

        This sets an attribute value for this element. Any existing attribute with the same name and namespace URI is removed.

        Overrides:
        setAttribute in class org.jdom2.Element
        Parameters:
        name - name of the attribute to set
        value - value of the attribute to set
        Returns:
        this element modified
        Throws:
        org.jdom2.IllegalNameException - if the given name is illegal as an attribute name.
        org.jdom2.IllegalDataException - if the given attribute value is illegal character data (as determined by Verifier.checkCharacterData(java.lang.String)).
      • toString

        public final java.lang.String toString()
        Overrides:
        toString in class org.jdom2.Element
      • toStringContentOnly

        public final java.lang.String toStringContentOnly()
        Returns:
        Content of element serialized as string