org.xwiki.xml.html.filter
Class AbstractHTMLFilter

java.lang.Object
  extended by org.xwiki.xml.html.filter.AbstractHTMLFilter
All Implemented Interfaces:
HTMLFilter, HTMLConstants

public abstract class AbstractHTMLFilter
extends Object
implements HTMLFilter, HTMLConstants

Abstract implementation of HTMLFilter providing utility methods for various common w3c dom operations.

Since:
1.8M2
Version:
$Id: ee4634d39d33856f5364744b22605899fa56d74e $

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_ROWSPAN, ATTRIBUTE_SRC, ATTRIBUTE_STYLE, TAG_A, TAG_ABBR, TAG_ACRONYM, TAG_ADDRESS, TAG_B, TAG_BLOCKQUOTE, TAG_BODY, TAG_BR, TAG_CENTER, TAG_CITE, TAG_CODE, TAG_DEL, TAG_DFN, TAG_DIV, TAG_DL, TAG_EM, TAG_FIELDSET, TAG_FONT, TAG_FORM, TAG_H1, TAG_H2, TAG_H3, TAG_H4, TAG_H5, TAG_H6, TAG_HEAD, TAG_HR, TAG_HTML, TAG_I, TAG_IMG, TAG_INS, TAG_KBD, TAG_LI, TAG_NOSCRIPT, TAG_OL, TAG_P, TAG_PRE, TAG_Q, TAG_S, TAG_SAMP, TAG_SCRIPT, TAG_SPAN, TAG_STRIKE, TAG_STRONG, TAG_STYLE, TAG_TABLE, TAG_TD, TAG_TH, TAG_TR, TAG_U, TAG_UL, TAG_VAR, WHITE_SPACE_CHARS
 
Constructor Summary
AbstractHTMLFilter()
           
 
Method Summary
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 an ElementSelector.
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 given Element 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
 

Constructor Detail

AbstractHTMLFilter

public AbstractHTMLFilter()
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 parent Element.
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 parent Element.
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 an ElementSelector.

Parameters:
parent - the parent Element.
tagNames - an array of tagNames.
elementSelector - an ElementSelector 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 given Element with it's children.

Parameters:
element - the Element to be replaced.

moveChildren

protected void moveChildren(Element parent,
                            Element destination)
Moves all child elements of the parent into destination element.

Parameters:
parent - the parent Element.
destination - the destination Element.


Copyright © 2004-2013 XWiki. All Rights Reserved.