Class HtmlElement

    • 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.
    • 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 HtmlElement 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 HtmlElement 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 HtmlElement 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 HtmlElement 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 HtmlElement setStyleString​(java.lang.String value)
        Html "style" attribute.
        Parameters:
        value - Value of attribute with style key/value pairs
        Returns:
        Self reference
      • setStyle

        public HtmlElement 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 HtmlElement 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 HtmlElement 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