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