Class StripHtmlFilter
java.lang.Object
org.shredzone.commons.text.filter.StripHtmlFilter
- All Implemented Interfaces:
Function<CharSequence,CharSequence>,TextFilter
A filter that strips HTML markup from a text.
This filter distinguishes between block and inline tags. Block tags are replaced by a whitespace (unless there already was a whitespace before the tag), while inline tags are just removed.
Rationale: "foo<br>bar" is converted to "foo bar", while "foo<i>bar</i>" is converted to "foobar", similar to the way it is displayed in a web browser.
- Author:
- Richard "Shred" Körber
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapply(CharSequence text)Applies the filter on aCharSequenceand returns a newCharSequencewith the modified text.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.shredzone.commons.text.TextFilter
toStringBuilder
-
Constructor Details
-
StripHtmlFilter
public StripHtmlFilter()
-
-
Method Details
-
apply
Description copied from interface:TextFilterApplies the filter on aCharSequenceand returns a newCharSequencewith the modified text.- Specified by:
applyin interfaceFunction<CharSequence,CharSequence>- Specified by:
applyin interfaceTextFilter- Parameters:
text-CharSequencewith the contents to be filtered. If this is aStringBuilderinstance, its contents may have changed after invocation, and this instance should not be used any more.- Returns:
CharSequencewith the filtered text.
-