| java.lang.Object com.nabhinc.util.StringUtil
StringUtil | public class StringUtil (Code) | | Provides utility methods for string manipulation.
author: Padmanabh Dabke author: (c) 2001,2003 Nabh Information Systems, Inc. All Rights Reserved. |
Method Summary | |
final public static String | encodeHTML(String str) | final public static String | encodeHTML(String str, boolean encodeNewLine) | final public static void | encodeHTML(String str, StringBuffer ret) | final public static void | encodeHTML(String str, StringBuffer ret, boolean encodeNewline) | final public static String | encodeXML(String str) | final public static void | encodeXML(String str, StringBuffer ret) | public static String | escapeJavascript(String str) | public static String | extractHTML(String str) Extract (keep) JUST the HTML from the String. | public static String | extractLastToken(String path, String delim) Extracts the substring after last delimiter. | public static String | extractName(String path) Convinience method that calls extractLast token with / as
the delimiter. | public static String | extractParentPath(String path) Returns substring upto but not including the last
occurence of / in the original string.
null if path is null. | public static String | getErrorStackTraceString(Throwable ex) | public static String | getParentPath(String childPath) | public static boolean | isNotNullOrEmpty(String paramVal) | public static boolean | isNullOrEmpty(String paramValue) | public static String | join(String[] elements, String delimiter) Joins the array of string into one string with the specified
delimiter. | public static void | main(String[] args) Main method for testing StringUtil class. | public static String | removeHTML(String str, boolean addSpace) Taken from Roller blogger
Remove occurences of html, defined as any text
between the characters "<" and ">". | final public static String | removeNewLine(String str) | public static String | removeNonAlphanumeric(String str) Remove occurences of non-alphanumeric characters. | public static String | replaceNonAlphanumeric(String str) Replaces occurences of non-alphanumeric characters with an underscore. | public static String | replaceNonAlphanumeric(String str, char subst) Replaces occurences of non-alphanumeric characters with a
supplied char. | public static String | replacePathSeparator(String path) Replace all occurrence of "/" in the specified path with the system's path separator.
This helper method might not be needed in the future if java.lang.String 's
replaceAll() has overcome the replacement of double back-slashes ("\\"). | public static String[] | split(String str, String delimiter) Spits a string into an array of strings using the specified
delimiter. | public static int[] | splitAsInts(String str, String delimiter) Spits a string into an array of ints using the specified
delimiter. | public static String | substitute(String str, String orig, String sub) Substitutes first occurance of a substring by another string and returns it. | public static String | transformToURL(String path, String basePath) Transform relative or absolute path to a URL format. | public static String | truncateNicely(String str, int lower, int upper, String appendToEnd) This method based on code from the String taglib at Apache Jakarta:
http://cvs.apache.org/viewcvs/jakarta-taglibs/string/src/org/apache/taglibs/string/util/StringW.java?rev=1.16&content-type=text/vnd.viewcvs-markup
Copyright (c) 1999 The Apache Software Foundation. | public static String | truncateText(String str, int lower, int upper, String appendToEnd) | public static String | wrapInCDATA(String txt) Puts CDATA stuff around the text and returns it. |
LINE_FEED | public static String LINE_FEED(Code) | | Line feed string. Useful in writing multiline text files.
|
extractHTML | public static String extractHTML(String str)(Code) | | Extract (keep) JUST the HTML from the String.
Parameters: str - |
extractLastToken | public static String extractLastToken(String path, String delim)(Code) | | Extracts the substring after last delimiter. Used for picking
the file name out of a path string.
null if path is null, empty string is path is just thetoken, substring after the last occurrence of the delimiter inall other cases. Parameters: path - Original string Parameters: delim - Delimiter |
extractName | public static String extractName(String path)(Code) | | Convinience method that calls extractLast token with / as
the delimiter.
Substring after the last occurrence of / Parameters: path - Original string |
extractParentPath | public static String extractParentPath(String path)(Code) | | Returns substring upto but not including the last
occurence of / in the original string.
null if path is null. Substring uptobut not including / in all other cases. Parameters: path - Original string |
isNotNullOrEmpty | public static boolean isNotNullOrEmpty(String paramVal)(Code) | | |
isNullOrEmpty | public static boolean isNullOrEmpty(String paramValue)(Code) | | |
join | public static String join(String[] elements, String delimiter)(Code) | | Joins the array of string into one string with the specified
delimiter. Returns null if the supplied string array is null.
Returns an empty string if that array is of length 0.
Creation date: (9/1/99 5:48:36 PM)
Concatenated string Parameters: elements - Array of strings to be joined. Parameters: delimiter - Separator |
main | public static void main(String[] args)(Code) | | Main method for testing StringUtil class.
Creation date: (10/4/99 2:16:31 PM)
Parameters: args - Command line arguments. |
removeHTML | public static String removeHTML(String str, boolean addSpace)(Code) | | Taken from Roller blogger
Remove occurences of html, defined as any text
between the characters "<" and ">".
Optionally replace HTML tags with a space.
Parameters: str - Parameters: addSpace - |
removeNonAlphanumeric | public static String removeNonAlphanumeric(String str)(Code) | | Remove occurences of non-alphanumeric characters.
|
replaceNonAlphanumeric | public static String replaceNonAlphanumeric(String str)(Code) | | Replaces occurences of non-alphanumeric characters with an underscore.
|
replaceNonAlphanumeric | public static String replaceNonAlphanumeric(String str, char subst)(Code) | | Replaces occurences of non-alphanumeric characters with a
supplied char.
|
replacePathSeparator | public static String replacePathSeparator(String path)(Code) | | Replace all occurrence of "/" in the specified path with the system's path separator.
This helper method might not be needed in the future if java.lang.String 's
replaceAll() has overcome the replacement of double back-slashes ("\\").
Parameters: path - The path for path with system-dependent path separator character. |
split | public static String[] split(String str, String delimiter)(Code) | | Spits a string into an array of strings using the specified
delimiter. Returns null if the string is null. Returns the
original string into an array of size 1 if the delimiter is
null or an empty string.
An array of strings that were delimited by the specifieddelimiter. Parameters: str - String to be split. Parameters: delimiter - Separator string. |
splitAsInts | public static int[] splitAsInts(String str, String delimiter)(Code) | | Spits a string into an array of ints using the specified
delimiter. Returns null if the string is null. Returns one
int parsed from the entire string if the delimiter is
null or an empty string.
An array of strings that were delimited by the specifieddelimiter. Parameters: str - String to be split. Parameters: delimiter - Separator string. |
substitute | public static String substitute(String str, String orig, String sub)(Code) | | Substitutes first occurance of a substring by another string and returns it.
Creation date: (11/21/2001 11:30:37 PM)
java.lang.String Parameters: str - String in which the substitution will occure Parameters: orig - Substring to be replaced Parameters: sub - Substitute string |
transformToURL | public static String transformToURL(String path, String basePath)(Code) | | Transform relative or absolute path to a URL format. If a relative path
is provided, the base path is required. The base path can be a
local file system path, e.g.: C:/document or in a URL format,
e.g.: http://localhost
|
truncateNicely | public static String truncateNicely(String str, int lower, int upper, String appendToEnd)(Code) | | This method based on code from the String taglib at Apache Jakarta:
http://cvs.apache.org/viewcvs/jakarta-taglibs/string/src/org/apache/taglibs/string/util/StringW.java?rev=1.16&content-type=text/vnd.viewcvs-markup
Copyright (c) 1999 The Apache Software Foundation.
Author: timster@mac.com
Parameters: str - Parameters: lower - Parameters: upper - Parameters: appendToEnd - |
wrapInCDATA | public static String wrapInCDATA(String txt)(Code) | | Puts CDATA stuff around the text and returns it.
Escaped text Parameters: txt - Original text string |
|
|