Package org.xwiki.xml.html.filter
Class AbstractHTMLFilter
- java.lang.Object
-
- org.xwiki.xml.html.filter.AbstractHTMLFilter
-
- All Implemented Interfaces:
HTMLFilter
,HTMLConstants
public abstract class AbstractHTMLFilter extends Object implements HTMLFilter, HTMLConstants
Abstract implementation ofHTMLFilter
providing utility methods for various common w3c dom operations.- Since:
- 1.8M2
- Version:
- $Id: 85b4f1fe10154404ed00f11bfc8b78ef2aaf8dd7 $
-
-
Field Summary
-
Fields inherited from interface org.xwiki.xml.html.HTMLConstants
ATTRIBUTE_ALIGN, ATTRIBUTE_ALT, ATTRIBUTE_CLASS, ATTRIBUTE_FONTCOLOR, ATTRIBUTE_FONTFACE, ATTRIBUTE_FONTSIZE, ATTRIBUTE_HREF, ATTRIBUTE_ID, ATTRIBUTE_NAME, ATTRIBUTE_REL, ATTRIBUTE_ROWSPAN, ATTRIBUTE_SRC, ATTRIBUTE_STYLE, ATTRIBUTE_TARGET, TAG_A, TAG_ABBR, TAG_ACRONYM, TAG_ADDRESS, TAG_ARTICLE, TAG_ASIDE, TAG_B, TAG_BLOCKQUOTE, TAG_BODY, TAG_BR, TAG_CENTER, TAG_CITE, TAG_CODE, TAG_DATA, TAG_DEL, TAG_DETAILS, TAG_DFN, TAG_DIV, TAG_DL, TAG_EM, TAG_EMBED, TAG_FIELDSET, TAG_FIGCAPTION, TAG_FIGURE, TAG_FONT, TAG_FOOTER, TAG_FORM, TAG_H1, TAG_H2, TAG_H3, TAG_H4, TAG_H5, TAG_H6, TAG_HEAD, TAG_HEADER, TAG_HGROUP, TAG_HR, TAG_HTML, TAG_I, TAG_IMG, TAG_INS, TAG_KBD, TAG_LI, TAG_MAIN, TAG_MATH, TAG_MENU, TAG_NAV, TAG_NOSCRIPT, TAG_OL, TAG_P, TAG_PRE, TAG_Q, TAG_S, TAG_SAMP, TAG_SCRIPT, TAG_SECTION, TAG_SPAN, TAG_STRIKE, TAG_STRONG, TAG_STYLE, TAG_SVG, TAG_TABLE, TAG_TD, TAG_TEMPLATE, TAG_TH, TAG_TR, TAG_TT, TAG_U, TAG_UL, TAG_VAR, WHITE_SPACE_CHARS
-
-
Constructor Summary
Constructors Constructor Description AbstractHTMLFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected List<Element>
filterChildren(Element parent, String tagName)
Utility method for filtering an element's children with a tagName.protected List<Element>
filterDescendants(Element parent, String[] tagNames)
Utility method for filtering an element's descendants by their tag names.protected List<Element>
filterDescendants(Element parent, String[] tagNames, ElementSelector elementSelector)
Utility method for filtering an element's descendants by their tag names and anElementSelector
.protected boolean
hasAttribute(List<Element> elements, String attributeName, boolean checkValue)
Utility method for checking if a list of elements have the same attribute set.protected void
moveChildren(Element parent, Element destination)
Moves all child elements of the parent into destination element.protected void
replaceWithChildren(Element element)
Replaces the givenElement
with it's children.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.xwiki.xml.html.filter.HTMLFilter
filter
-
-
-
-
Method Detail
-
filterChildren
protected List<Element> filterChildren(Element parent, String tagName)
Utility method for filtering an element's children with a tagName.- Parameters:
parent
- the parentElement
.tagName
- expected tagName of the children elements.- Returns:
- list of children elements with the provided tagName.
-
filterDescendants
protected List<Element> filterDescendants(Element parent, String[] tagNames)
Utility method for filtering an element's descendants by their tag names.- Parameters:
parent
- the parentElement
.tagNames
- an array of tagNames.- Returns:
- list of descendants of the parent element having one of given tag names.
-
filterDescendants
protected List<Element> filterDescendants(Element parent, String[] tagNames, ElementSelector elementSelector)
Utility method for filtering an element's descendants by their tag names and anElementSelector
.- Parameters:
parent
- the parentElement
.tagNames
- an array of tagNames.elementSelector
- anElementSelector
that allows further filtering of elements.- Returns:
- list of descendants of the parent element having one of given tag names.
-
hasAttribute
protected boolean hasAttribute(List<Element> elements, String attributeName, boolean checkValue)
Utility method for checking if a list of elements have the same attribute set. If the checkValue is true, the values of the given attribute will be checked for equivalency.- Parameters:
elements
- the list of elements.attributeName
- Name of the attribute.checkValue
- flag indicating if the value of the attribute should be equal among all the elements.- Returns:
- true if the given attribute is present and the value check is passing.
-
replaceWithChildren
protected void replaceWithChildren(Element element)
Replaces the givenElement
with it's children.- Parameters:
element
- theElement
to be replaced.
-
-