| java.lang.Object org.archive.util.TextUtils
TextUtils | public class TextUtils (Code) | | |
Method Summary | |
public static String | escapeForHTML(String s) Minimally escapes a string so that it can be placed inside XML/HTML
attribute. | public static String | escapeForHTMLJavascript(String s) Escapes a string so that it can be passed as an argument to a javscript
in a JSP page. | public static String | escapeForMarkupAttribute(String s) Escapes a string so that it can be placed inside XML/HTML attribute. | public static String | exceptionToString(String message, Throwable e) Parameters: message - Message to put at top of the string returned. | public static String | getFirstWord(String s) Parameters: s - String to find first word in (Words are delimited bywhitespace). | public static Matcher | getMatcher(String pattern, CharSequence input) Get a matcher object for a precompiled regex pattern.
This method tries to reuse Matcher objects for efficiency.
It can hold for recycling one Matcher per pattern per thread. | public static boolean | matches(String pattern, CharSequence input) Utility method using a precompiled pattern instead of using the matches
method of the String class. | public static void | recycleMatcher(Matcher m) | public 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. | public 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. | public static String[] | split(String pattern, CharSequence input) Utility method using a precompiled pattern instead of using the split
method of the String class. | public static CharSequence | unescapeHtml(CharSequence cs) Replaces HTML Entity Encodings. | public static void | writeEscapedForHTML(String s, JspWriter out) 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. |
escapeForHTML | public static String escapeForHTML(String s)(Code) | | Minimally escapes a string so that it can be placed inside XML/HTML
attribute.
Escapes lt and amp.
Parameters: s - The string to escape The same string escaped. |
escapeForHTMLJavascript | public static String escapeForHTMLJavascript(String s)(Code) | | Escapes a string so that it can be passed as an argument to a javscript
in a JSP page. This method takes a string and returns the same string
with any single quote escaped by prepending the character with a
backslash. Linebreaks are also replaced with '\n'. Also,
less-than signs and ampersands are replaced with HTML entities.
Parameters: s - The string to escape The same string escaped. |
escapeForMarkupAttribute | public static String escapeForMarkupAttribute(String s)(Code) | | Escapes a string so that it can be placed inside XML/HTML attribute.
Replaces ampersand, less-than, greater-than, single-quote, and
double-quote with escaped versions.
Parameters: s - The string to escape The same string escaped. |
exceptionToString | public static String exceptionToString(String message, Throwable e)(Code) | | Parameters: message - Message to put at top of the string returned. May benull. Parameters: e - Exception to write into a string. Return formatted string made of passed message and stack traceof passed exception. |
getFirstWord | public static String getFirstWord(String s)(Code) | | Parameters: s - String to find first word in (Words are delimited bywhitespace). First word in the passed string else null if no word found. |
getMatcher | public static Matcher getMatcher(String pattern, CharSequence input)(Code) | | Get a matcher object for a precompiled regex pattern.
This method tries to reuse Matcher objects for efficiency.
It can hold for recycling one Matcher per pattern per thread.
Matchers retrieved should be returned for reuse via the
recycleMatcher() method, but no errors will occur if they
are not.
This method is a hotspot frequently accessed.
Parameters: pattern - the string pattern to use Parameters: input - the character sequence the matcher should be using a matcher object loaded with the submitted character sequence |
matches | public static boolean matches(String pattern, CharSequence input)(Code) | | Utility method using a precompiled pattern instead of using the matches
method of the String class. This method will also be reusing Matcher
objects.
See Also: java.util.regex.Pattern Parameters: pattern - precompiled Pattern to match against Parameters: input - the character sequence to check true if character sequence matches |
replaceAll | public static String replaceAll(String pattern, CharSequence input, String replacement)(Code) | | Utility method using a precompiled pattern instead of using the
replaceAll method of the String class. This method will also be reusing
Matcher objects.
See Also: java.util.regex.Pattern Parameters: pattern - precompiled Pattern to match against Parameters: input - the character sequence to check Parameters: replacement - the String to substitute every match with the String with all the matches substituted |
replaceFirst | public static String replaceFirst(String pattern, CharSequence input, String replacement)(Code) | | Utility method using a precompiled pattern instead of using the
replaceFirst method of the String class. This method will also be reusing
Matcher objects.
See Also: java.util.regex.Pattern Parameters: pattern - precompiled Pattern to match against Parameters: input - the character sequence to check Parameters: replacement - the String to substitute the first match with the String with the first match substituted |
split | public static String[] split(String pattern, CharSequence input)(Code) | | Utility method using a precompiled pattern instead of using the split
method of the String class.
See Also: java.util.regex.Pattern Parameters: pattern - precompiled Pattern to split by Parameters: input - the character sequence to split array of Strings split by pattern |
unescapeHtml | public static CharSequence unescapeHtml(CharSequence cs)(Code) | | Replaces HTML Entity Encodings.
Parameters: cs - The CharSequence to remove html codes from the same CharSequence or an escaped String. |
writeEscapedForHTML | public static void writeEscapedForHTML(String s, JspWriter out) throws IOException(Code) | | 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.
Parameters: s - String to write Parameters: out - destination JspWriter throws: IOException - |
|
|