Class XmlCleaningResponseFilter
- java.lang.Object
-
- org.apache.wicket.response.filter.XmlCleaningResponseFilter
-
- All Implemented Interfaces:
IResponseFilter
public class XmlCleaningResponseFilter extends java.lang.Object implements IResponseFilter
An IResponseFilter that removes all invalid XML characters. By default it is used only for Wicket Ajax responses.If the application needs to use it for other use cases then it can either override shouldFilter(AppendingStringBuffer) in the case it is used as IResponseFilter or stripNonValidXMLCharacters(AppendingStringBuffer) can be used directly.
Usage: MyApplication.java
public void init() { super.init(); getRequestCycleSettings().addResponseFilter(new XmlCleaningResponseFilter()); }
-
-
Constructor Summary
Constructors Constructor Description XmlCleaningResponseFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.wicket.util.string.AppendingStringBufferfilter(org.apache.wicket.util.string.AppendingStringBuffer responseBuffer)Filters the response buffer and returns the filtered response that can be used in the next filter or returned to the real output itself.protected booleanisValidXmlChar(int codePoint)Checks whether the character represented by this codePoint is a valid in XML documents.protected booleanshouldFilter(org.apache.wicket.util.string.AppendingStringBuffer responseBuffer)Decides whether the filter should be applied.org.apache.wicket.util.string.AppendingStringBufferstripNonValidXMLCharacters(org.apache.wicket.util.string.AppendingStringBuffer input)This method ensures that the output String has only valid XML unicode characters as specified by the XML 1.0 standard.
-
-
-
Method Detail
-
filter
public org.apache.wicket.util.string.AppendingStringBuffer filter(org.apache.wicket.util.string.AppendingStringBuffer responseBuffer)
Description copied from interface:IResponseFilterFilters the response buffer and returns the filtered response that can be used in the next filter or returned to the real output itself. A filter may alter the response buffer and return the response buffer itself.- Specified by:
filterin interfaceIResponseFilter- Parameters:
responseBuffer- The response buffer to be filtered- Returns:
- The changed buffer or the response buffer itself (changed or not)
-
shouldFilter
protected boolean shouldFilter(org.apache.wicket.util.string.AppendingStringBuffer responseBuffer)
Decides whether the filter should be applied.- Parameters:
responseBuffer- The buffer to filter- Returns:
trueif the buffer brings Ajax response
-
stripNonValidXMLCharacters
public org.apache.wicket.util.string.AppendingStringBuffer stripNonValidXMLCharacters(org.apache.wicket.util.string.AppendingStringBuffer input)
This method ensures that the output String has only valid XML unicode characters as specified by the XML 1.0 standard. For reference, please see the standard. This method will return an empty String if the input is null or empty.- Parameters:
input- The StringBuffer whose non-valid characters we want to remove.- Returns:
- The in String, stripped of non-valid characters.
-
isValidXmlChar
protected boolean isValidXmlChar(int codePoint)
Checks whether the character represented by this codePoint is a valid in XML documents.- Parameters:
codePoint- The codePoint for the checked character- Returns:
trueif the character can be used in XML documents
-
-