public class TextUtils
extends java.lang.Object
| Constructor and Description |
|---|
TextUtils() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
escapeForHTML(java.lang.String s)
Minimally escapes a string so that it can be placed inside XML/HTML
attribute.
|
static java.lang.String |
escapeForHTMLJavascript(java.lang.String s)
Escapes a string so that it can be passed as an argument to a javscript
in a JSP page.
|
static java.lang.String |
escapeForMarkupAttribute(java.lang.String s)
Escapes a string so that it can be placed inside XML/HTML attribute.
|
static java.lang.String |
exceptionToString(java.lang.String message,
java.lang.Throwable e) |
static java.lang.String |
getFirstWord(java.lang.String s) |
static java.util.regex.Matcher |
getMatcher(java.lang.String pattern,
java.lang.CharSequence input)
Get a matcher object for a precompiled regex pattern.
|
static boolean |
matches(java.lang.String pattern,
java.lang.CharSequence input)
Utility method using a precompiled pattern instead of using the matches
method of the String class.
|
static void |
recycleMatcher(java.util.regex.Matcher m) |
static java.lang.String |
replaceAll(java.lang.String pattern,
java.lang.CharSequence input,
java.lang.String replacement)
Utility method using a precompiled pattern instead of using the
replaceAll method of the String class.
|
static java.lang.String |
replaceFirst(java.lang.String pattern,
java.lang.CharSequence input,
java.lang.String replacement)
Utility method using a precompiled pattern instead of using the
replaceFirst method of the String class.
|
static java.lang.String[] |
split(java.lang.String pattern,
java.lang.CharSequence input)
Utility method using a precompiled pattern instead of using the split
method of the String class.
|
static java.lang.CharSequence |
unescapeHtml(java.lang.CharSequence cs)
Replaces HTML Entity Encodings.
|
static java.lang.String |
urlEscape(java.lang.String s)
Exception- and warning-free URL-escaping utility method.
|
static java.lang.String |
urlUnescape(java.lang.String s)
Exception- and warning-free URL-unescaping utility method.
|
static void |
writeEscapedForHTML(java.lang.String s,
java.io.Writer w)
Utility method for writing a (potentially large) String to a JspWriter,
escaping it for HTML display, without constructing another large String
of the whole content.
|
public static java.util.regex.Matcher getMatcher(java.lang.String pattern,
java.lang.CharSequence input)
pattern - the string pattern to useinput - the character sequence the matcher should be usingpublic static void recycleMatcher(java.util.regex.Matcher m)
public static java.lang.String replaceAll(java.lang.String pattern,
java.lang.CharSequence input,
java.lang.String replacement)
pattern - precompiled Pattern to match againstinput - the character sequence to checkreplacement - the String to substitute every match withPatternpublic static java.lang.String replaceFirst(java.lang.String pattern,
java.lang.CharSequence input,
java.lang.String replacement)
pattern - precompiled Pattern to match againstinput - the character sequence to checkreplacement - the String to substitute the first match withPatternpublic static boolean matches(java.lang.String pattern,
java.lang.CharSequence input)
pattern - precompiled Pattern to match againstinput - the character sequence to checkPatternpublic static java.lang.String[] split(java.lang.String pattern,
java.lang.CharSequence input)
pattern - precompiled Pattern to split byinput - the character sequence to splitPatternpublic static java.lang.String getFirstWord(java.lang.String s)
s - String to find first word in (Words are delimited by
whitespace).public static java.lang.String escapeForHTMLJavascript(java.lang.String s)
s - The string to escapepublic static java.lang.String escapeForMarkupAttribute(java.lang.String s)
s - The string to escapepublic static java.lang.String escapeForHTML(java.lang.String s)
s - The string to escapepublic static void writeEscapedForHTML(java.lang.String s,
java.io.Writer w)
throws java.io.IOException
s - String to writeout - destination JspWriterjava.io.IOExceptionpublic static java.lang.CharSequence unescapeHtml(java.lang.CharSequence cs)
cs - The CharSequence to remove html codes frompublic static java.lang.String exceptionToString(java.lang.String message,
java.lang.Throwable e)
message - Message to put at top of the string returned. May be
null.e - Exception to write into a string.public static java.lang.String urlEscape(java.lang.String s)
s - String to escapepublic static java.lang.String urlUnescape(java.lang.String s)
s - String do unescapeCopyright © 2019 The International Internet Preservation Consortium. All Rights Reserved.