Package io.wcm.handler.commons.dom
Class HtmlElement
- java.lang.Object
-
- org.jdom2.Content
-
- org.jdom2.Element
-
- io.wcm.handler.commons.dom.AbstractElement
-
- io.wcm.handler.commons.dom.AbstractHtmlElementFactory
-
- io.wcm.handler.commons.dom.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 extends AbstractHtmlElementFactory
Html element wrapper object. This element class is an extension of JDOM Element.- See Also:
- Serialized Form
-
-
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>
HtmlElementTypeadd(HtmlElementType element)
Appends the child to the end of the element's content list.HtmlElement
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.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.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 calladdCssClass(String)
instead.HtmlElement
setData(java.lang.String attributeName, java.lang.String value)
Custom Html5 "data-*" attribute.protected HtmlElement
setEmptyAttributeValueAsBoolean(java.lang.String attributeName, boolean value)
Sets "empty" attribute value as boolean (i.e.HtmlElement
setId(java.lang.String value)
Html "id" attribute.HtmlElement
setStyle(java.lang.String styleAttribute, java.lang.String styleValue)
Html "style" attribute.HtmlElement
setStyleString(java.lang.String value)
Html "style" attribute.HtmlElement
setTitle(java.lang.String value)
Html "title" attribute.-
Methods inherited from class io.wcm.handler.commons.dom.AbstractHtmlElementFactory
create, createAnchor, createAnchor, createAnchor, createAudio, createComment, createDiv, createFigCaption, createFigure, createImage, createImage, createImage, createImage, createImage, createNoScript, createScript, createScript, createSource, createSpan, createSpan, createVideo
-
Methods inherited from class io.wcm.handler.commons.dom.AbstractElement
add, addContent, addContent, addContent, addContent, addContent, getAttributeValueAsInteger, getAttributeValueAsLong, setAttribute, setAttribute, setAttributeValueAsInteger, setAttributeValueAsLong, setText, toString, 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
-
-
-
-
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 namevalue
- 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 calladdCssClass(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 namestyleValue
- 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
-
-