public final class Filters extends Object
| Modifier and Type | Field and Description |
|---|---|
static Pattern |
COLORS_PATTERN
The regular expression which matches ANSI escape
sequences for colors.
|
static Pattern |
NON_PRINTABLE_PATTERN
The regular expression which matches non printable characters:
[\x00\x08\x0B\x0C\x0E-\x1F]. |
| Modifier and Type | Method and Description |
|---|---|
static Filter |
chain(Filter... filters)
Combines the filters in a filter chain.
|
static Filter |
removeColors()
Creates a filter which removes ANSI
escape sequences for colors in the input.
|
static Filter |
removeNonPrintable()
Creates a filter which removes all the non-printable characters matching
NON_PRINTABLE_PATTERN in the
input string. |
static Filter |
replaceInBuffer(Pattern regexp,
String replacement)
Creates a filter which replaces every substring in the input buffer that matches the given
regular expression
and replaces it with given replacement.
|
static Filter |
replaceInBuffer(String regexp,
String replacement)
Equivalent to
replaceInBuffer(java.util.regex.Pattern,
String) but takes the regular expression
as string. |
static Filter |
replaceInString(Pattern regexp,
String replacement)
Equivalent to
replaceInString(java.util.regex.Pattern,
String, int) but takes the regular expression
as string and default overlap in 80 characters. |
static Filter |
replaceInString(Pattern regexp,
String replacement,
int overlap)
Creates a filter which replaces every substring in the input string that matches the given
regular expression
and replaces it with given replacement.
|
static Filter |
replaceInString(String regexp,
String replacement)
Equivalent to
replaceInString(java.util.regex.Pattern,
String) but takes the regular expression
as string and default overlap in 80 characters. |
public static final Pattern COLORS_PATTERN
public static final Pattern NON_PRINTABLE_PATTERN
[\x00\x08\x0B\x0C\x0E-\x1F].public static Filter removeNonPrintable()
NON_PRINTABLE_PATTERN in the
input string.public static Filter replaceInString(Pattern regexp, String replacement, int overlap)
String.replaceAll(String, String) for the input string.regexp - the regular expressionreplacement - the string to be substituted for each matchoverlap - the number of characters prepended to the matching string from the
previous data chunk before matchpublic static Filter replaceInString(String regexp, String replacement)
replaceInString(java.util.regex.Pattern,
String) but takes the regular expression
as string and default overlap in 80 characters.regexp - the regular expressionreplacement - the string to be substituted for each matchpublic static Filter replaceInString(Pattern regexp, String replacement)
replaceInString(java.util.regex.Pattern,
String, int) but takes the regular expression
as string and default overlap in 80 characters.regexp - the regular expressionreplacement - the string to be substituted for each matchpublic static Filter removeColors()
public static Filter replaceInBuffer(String regexp, String replacement)
replaceInBuffer(java.util.regex.Pattern,
String) but takes the regular expression
as string.regexp - the regular expressionreplacement - the string to be substituted for each matchpublic static Filter replaceInBuffer(Pattern regexp, String replacement)
String.replaceAll(String, String) for the entire buffer
contents every time new
data arrives,regexp - the regular expressionreplacement - the string to be substituted for each matchpublic static Filter chain(Filter... filters)
Filter.beforeAppend(String, StringBuilder) method of one filter is passed a
parameter to the next one if it is not null. If it is null,
then the beforeAppend
won't be called any more and the latest non-null result is appended to the expect internal
buffer.
If the return value of the Filter.afterAppend(StringBuilder) method is true,
then all the calls
of this method on the consequent filters will be suppressed.filters - the filters, not nullCopyright © 2014–2018 Alexey Gavrilov and contributors. All rights reserved.