Class HtmlElement<T extends HtmlElement>

  • Type Parameters:
    T - Class derived from HtmlElement
    All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, org.jdom2.NamespaceAware, org.jdom2.Parent
    Direct Known Subclasses:
    AbstractNonSelfClosingHtmlElement, Area, Image, Source

    @ConsumerType
    public class HtmlElement<T extends HtmlElement>
    extends AbstractHtmlElementFactory<T>
    Html element wrapper object. This element class is an extension of JDOM Element.
    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 
      Constructor Description
      HtmlElement​(java.lang.String name)
      Initializes html element.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <HtmlElementType extends HtmlElement>
      HtmlElementType
      add​(HtmlElementType element)
      Appends the child to the end of the element's content list.
      T addCssClass​(java.lang.String value)
      Html "class" attribute.
      java.lang.String getCssClass()
      Html "class" attribute.
      java.lang.String getData​(java.lang.String attributeName)
      Custom Html5 "data-*" attribute.
      protected boolean getEmptyAttributeValueAsBoolean​(java.lang.String attributeName)
      Gets "empty" attribute value as boolean (i.e. for "checked" attribute).
      java.lang.String getId()
      Html "id" attribute.
      java.lang.String getStyle​(java.lang.String styleAttribute)
      Html "style" attribute.
      java.util.Map<java.lang.String,​java.lang.String> getStyles()
      Html "style" attribute.
      java.lang.String getStyleString()
      Html "style" attribute.
      java.lang.String getTitle()
      Html "title" attribute.
      T setCssClass​(java.lang.String value)
      Sets Html "class" attribute - unless you're really sure that you want to replace existing classes, you probably should call addCssClass(String) instead.
      T setData​(java.lang.String attributeName, java.lang.String value)
      Custom Html5 "data-*" attribute.
      protected T setEmptyAttributeValueAsBoolean​(java.lang.String attributeName, boolean value)
      Sets "empty" attribute value as boolean (i.e. for "checked" attribute).
      T setId​(java.lang.String value)
      Html "id" attribute.
      T setStyle​(java.lang.String styleAttribute, java.lang.String styleValue)
      Html "style" attribute.
      T setStyleString​(java.lang.String value)
      Html "style" attribute.
      T setTitle​(java.lang.String value)
      Html "title" attribute.
      • 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, 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

      • HtmlElement

        public HtmlElement​(java.lang.String name)
        Initializes html element.
        Parameters:
        name - Element name
    • Method Detail

      • add

        public final <HtmlElementType extends HtmlElement> HtmlElementType add​(HtmlElementType 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:
        HtmlElementType - Type that extends HtmlElement
        Parameters:
        element - Element to add. Null values are ignored.
        Returns:
        The added element.
      • getEmptyAttributeValueAsBoolean

        protected final boolean getEmptyAttributeValueAsBoolean​(java.lang.String attributeName)
        Gets "empty" attribute value as boolean (i.e. for "checked" attribute).
        Parameters:
        attributeName - Attribute name
        Returns:
        Attribute value as boolean or false if not set.
      • setEmptyAttributeValueAsBoolean

        protected final T setEmptyAttributeValueAsBoolean​(java.lang.String attributeName,
                                                          boolean value)
        Sets "empty" attribute value as boolean (i.e. for "checked" attribute).
        Parameters:
        attributeName - Attribute name
        value - Attribute value as boolean
        Returns:
        Self reference
      • getId

        public final java.lang.String getId()
        Html "id" attribute.
        Returns:
        Value of attribute
      • setId

        public final T setId​(java.lang.String value)
        Html "id" attribute.
        Parameters:
        value - Value of attribute
        Returns:
        Self reference
      • getCssClass

        public final java.lang.String getCssClass()
        Html "class" attribute.
        Returns:
        Value of attribute
      • setCssClass

        public final T setCssClass​(java.lang.String value)
        Sets Html "class" attribute - unless you're really sure that you want to replace existing classes, you probably should call addCssClass(String) instead.
        Parameters:
        value - Value of attribute
        Returns:
        Self reference
      • addCssClass

        public final T addCssClass​(java.lang.String value)
        Html "class" attribute. Adds a single, space-separated value while preserving existing ones.
        Parameters:
        value - Value of attribute
        Returns:
        Self reference
      • getStyleString

        public final java.lang.String getStyleString()
        Html "style" attribute.
        Returns:
        Value of attribute with style key/value pairs
      • getStyles

        public final java.util.Map<java.lang.String,​java.lang.String> getStyles()
        Html "style" attribute.
        Returns:
        Returns map of style key/value pairs.
      • getStyle

        public final java.lang.String getStyle​(java.lang.String styleAttribute)
        Html "style" attribute. Returns single style attribute value.
        Parameters:
        styleAttribute - Style attribute name
        Returns:
        Style attribute value
      • setStyleString

        public final T setStyleString​(java.lang.String value)
        Html "style" attribute.
        Parameters:
        value - Value of attribute with style key/value pairs
        Returns:
        Self reference
      • setStyle

        public final T setStyle​(java.lang.String styleAttribute,
                                java.lang.String styleValue)
        Html "style" attribute. Sets single style attribute value.
        Parameters:
        styleAttribute - Style attribute name
        styleValue - Style attribute value
        Returns:
        Self reference
      • getTitle

        public final java.lang.String getTitle()
        Html "title" attribute.
        Returns:
        Value of attribute
      • setTitle

        public final T setTitle​(java.lang.String value)
        Html "title" attribute.
        Parameters:
        value - Value of attribute
        Returns:
        Self reference
      • getData

        public final java.lang.String getData​(java.lang.String attributeName)
        Custom Html5 "data-*" attribute.
        Parameters:
        attributeName - Name of HTML5 data attribute (without the 'data-' prefix).
        Returns:
        Value of attribute
      • setData

        public final T setData​(java.lang.String attributeName,
                               java.lang.String value)
        Custom Html5 "data-*" attribute.
        Parameters:
        attributeName - Name of HTML5 data attribute (without the 'data-' prefix).
        value - Value of attribute
        Returns:
        Self reference