All Packages Class Hierarchy This Package Previous Next Index
Class com.andthehorseyourodeinon.utils.StringUtils
java.lang.Object
|
+----com.andthehorseyourodeinon.utils.StringUtils
- public class StringUtils
- extends Object
StringUtils is a collection of static functions for String manipulation,
formatting, and creation.
- Version:
- $Id: StringUtils.java,v 1.1 2000/05/16 22:45:10 samuelg Exp $
-
StringUtils()
-
-
betweenTags(String, String, String)
- Given a string containing markup tags, this function will separate out all
elements between a given start and end tag.
-
blowAwayTags(String)
- Given a string of HTML or other text containing URLs, this brutally simplistic function
will singlemindedly strip out anything between < and > marks.
-
createCompactDateString()
- Return a String containing a compact date/time using the current System time and date.
-
createCompactDateString(Calendar)
- Return a String containing a compact date/time using the time and date
provided.
-
createCompactDateString(Calendar, String, String, String)
- Return a String containing a compact date/time using the specified time and date, with
user-specified delimiters.
-
createCompactDateString(String, String, String)
- Return a String containing a compact date/time using the current System time and date, with
user-specified delimiters.
-
createRFC1123DateString()
- Return a String containing an RFC 1123-compliant date String (RFC 1123 supercedes the date
specifications of RFC 822) using the current System time and date.
-
displayTimeUnits(long, boolean)
- Converts millisecond sinto a human-readable
String of days, hours, minutes, seconds, and
milliseconds.
-
extractURLs(String)
- Given a string of HTML or other text containing URLs, this rather simplistic function
will attempt to extract the URLs, which it will return as a Vector of
Strings.
-
indexOfIgnoreCase(String, String)
- indexOfIgnoreCase is an analog to the indexOf method for the String class.
-
indexOfIgnoreCase(String, String, int)
- indexOfIgnoreCase is an analog to the indexOf method for the String class.
-
indexOfIgnoreCase(String, String, int, int)
- indexOfIgnoreCase is an analog to the indexOf method for the String class.
-
isAlphaNumeric(String)
- Determines whether a string contains any characters that are
not alphanumeric.
-
isAlphaSafeString(String)
- Determines whether a string contains any characters that are
not either alphanumeric or period, underscore, space, or hyphen.
-
oldExtractURLs(String)
- Given a string of HTML or other text containing URLs, this rather simplistic function
will attempt to extract the URLs, which it will return as a Vector of
Strings.
-
reasonableTimeUnits(long)
- Converts millisecond sinto a human-readable
String of days, hours, minutes, seconds, and
milliseconds.
-
replaceSubstring(String, String, String)
- Given a string, this will replace all instances of a given substring with
another given string.
-
replaceSubstringIgnoreCase(String, String, String)
- Given a string, this will replace all instances of a given substring with
another given string.
-
singleBetweenTags(String, String, String)
- Given a string containing markup tags, this function will return the first
element between a given start and end tag.
-
timestampFilespec(String, String)
- Create a date/time based file spec using the current System time and date.
Example: timestampFilespec("log","txt")
returns: log20000505-101501.txt
-
toMixedCase(String)
- This Function Will Convert A String To Start Each Word With An Upper Case
Character.
-
toRFC1123DateString(Calendar)
- Return a String containing an RFC 1123-compliant date String (RFC 1123 supercedes the date
specifications of RFC 822) using the specified time and date.
-
truncateNicely(String, int)
- Given a string and a length, this will truncate the String to fit
within that character length, adding ellipsis to indicate that the
String has been shortened.
StringUtils
public StringUtils()
indexOfIgnoreCase
public static int indexOfIgnoreCase(String source,
String searchString)
- indexOfIgnoreCase is an analog to the indexOf method for the String class.
- Parameters:
- source - String to be searched
- searchString - the String to be found within src
- Returns:
- integer position of the first match
indexOfIgnoreCase
public static int indexOfIgnoreCase(String source,
String searchString,
int startPoint)
- indexOfIgnoreCase is an analog to the indexOf method for the String class.
- Parameters:
- source - String to be searched
- searchString - the String to be found within src
- startPoint - index into src where the search will begin.
- Returns:
- integer position of the first match
indexOfIgnoreCase
public static int indexOfIgnoreCase(String source,
String searchString,
int startPoint,
int maxRange)
- indexOfIgnoreCase is an analog to the indexOf method for the String class.
- Parameters:
- source - String to be searched
- searchString - the String to be found within src
- startPoint - index into src where the search will begin.
- maxRange - the maximum distance from startPoint to look for a match
- Returns:
- integer position of the first match
isAlphaSafeString
public static boolean isAlphaSafeString(String theString)
- Determines whether a string contains any characters that are
not either alphanumeric or period, underscore, space, or hyphen.
- Parameters:
- theString - String to be searched
isAlphaNumeric
public static boolean isAlphaNumeric(String theString)
- Determines whether a string contains any characters that are
not alphanumeric.
- Parameters:
- theString - String to be searched
replaceSubstring
public static String replaceSubstring(String original,
String find,
String replace)
- Given a string, this will replace all instances of a given substring with
another given string.
- Parameters:
- original - String to be modified.
- find - the String to be replaced.
- replace - the String to replace with.
- Returns:
- a string with the completed substitutions.
replaceSubstringIgnoreCase
public static String replaceSubstringIgnoreCase(String original,
String find,
String replace)
- Given a string, this will replace all instances of a given substring with
another given string. This will replace instances without regard to case.
- Parameters:
- original - String to be modified.
- find - the String to be replaced.
- replace - the String to replace with.
- Returns:
- a string with the completed substitutions.
betweenTags
public static Vector betweenTags(String source,
String startTag,
String endTag)
- Given a string containing markup tags, this function will separate out all
elements between a given start and end tag. It will return these elements
as a Vector of Strings. Tags are not case sensitive.
- Parameters:
- source - String to be processed.
- startTag - String representing the tag indicating the start of an element.
- endTag - String representing the tag indicating the end of an element.
- Returns:
- a Vector of Strings.
singleBetweenTags
public static String singleBetweenTags(String source,
String startTag,
String endTag)
- Given a string containing markup tags, this function will return the first
element between a given start and end tag. It will return this element as a
String. Tags are not case sensitive.
- Parameters:
- source - String to be processed.
- startTag - String representing the tag indicating the start of an element.
- endTag - String representing the tag indicating the end of an element.
- Returns:
- a Vector of Strings.
extractURLs
public static Vector extractURLs(String source)
- Given a string of HTML or other text containing URLs, this rather simplistic function
will attempt to extract the URLs, which it will return as a Vector of
Strings. It only finds URLs that include the HTTP method (i.e., "http://"),
and it does not return this method with the URLs it extracts.
- Parameters:
- source - String to be processed.
- Returns:
- a Vector of Strings.
oldExtractURLs
public static Vector oldExtractURLs(String source)
- Given a string of HTML or other text containing URLs, this rather simplistic function
will attempt to extract the URLs, which it will return as a Vector of
Strings. It only finds URLs that include the HTTP method (i.e., "http://"),
and it does not return this method with the URLs it extracts.
- Parameters:
- source - String to be processed.
- Returns:
- a Vector of Strings.
blowAwayTags
public static String blowAwayTags(String source)
- Given a string of HTML or other text containing URLs, this brutally simplistic function
will singlemindedly strip out anything between < and > marks. It uses no
intelligence to determine whether or not these have anything to
do with tags whatsoever.
- Parameters:
- source - String to be processed.
- Returns:
- a String without tags (and possibly without equations, if they were there).
truncateNicely
public static String truncateNicely(String source,
int maxLen)
- Given a string and a length, this will truncate the String to fit
within that character length, adding ellipsis to indicate that the
String has been shortened. Ellipsis will only be added at word breaks.
- Parameters:
- source - the String to be truncated.
- maxLen - the maximum number of characters for the resultant String
- Returns:
- a truncated String.
reasonableTimeUnits
public static String reasonableTimeUnits(long ms)
- Converts millisecond sinto a human-readable
String of days, hours, minutes, seconds, and
milliseconds.
- Parameters:
- ms - number of milliseconds
- Returns:
- human-readable String
displayTimeUnits
public static String displayTimeUnits(long ms,
boolean abbreviated)
- Converts millisecond sinto a human-readable
String of days, hours, minutes, seconds, and
milliseconds. There is an option to abbreviate the String; this would
result in days being labeled with a "d" rather than the word "days," etc.
- Parameters:
- ms - number of milliseconds
- abbreviated - boolean telling whether to use long or short labels.
- Returns:
- human-readable String
toMixedCase
public static String toMixedCase(String st)
- This Function Will Convert A String To Start Each Word With An Upper Case
Character.
- Parameters:
- st - String To Be Converted
- Returns:
- A Mixed Case String
timestampFilespec
public static String timestampFilespec(String prefix,
String extension)
- Create a date/time based file spec using the current System time and date.
Example: timestampFilespec("log","txt")
returns: log20000505-101501.txt
- Parameters:
- prefix - String with which to prefix the filespec
- extension - String to use as a file-type extension. Should not include the dot.
- Returns:
- A filespec.
createCompactDateString
public static String createCompactDateString()
- Return a String containing a compact date/time using the current System time and date.
- Returns:
- A String of the form "2000-05-05 10:15:01".
createCompactDateString
public static String createCompactDateString(Calendar when)
- Return a String containing a compact date/time using the time and date
provided.
- Parameters:
- when - the Calendar object to use for creating the String.
- Returns:
- A String of the form "2000-05-05 10:15:01".
createCompactDateString
public static String createCompactDateString(String yearDelimiter,
String splitDelimiter,
String hourDelimiter)
- Return a String containing a compact date/time using the current System time and date, with
user-specified delimiters.
- Parameters:
- yearDelimiter - the String to use to separate the digits representing year, month, and day.
- splitDelimiter - the String to use to separate the digits representing date and time.
- hourDelimiter - the String to use to separate the digits representing hour, minute, and second.
- Returns:
- A String containing the date using the specified delimiters.
createCompactDateString
public static String createCompactDateString(Calendar when,
String yearDelimiter,
String splitDelimiter,
String hourDelimiter)
- Return a String containing a compact date/time using the specified time and date, with
user-specified delimiters.
- Parameters:
- when - the Calendar object to use for creating the String.
- yearDelimiter - the String to use to separate the digits representing year, month, and day.
- splitDelimiter - the String to use to separate the digits representing date and time.
- hourDelimiter - the String to use to separate the digits representing hour, minute, and second.
- Returns:
- A String containing the date using the specified delimiters.
createRFC1123DateString
public static String createRFC1123DateString()
- Return a String containing an RFC 1123-compliant date String (RFC 1123 supercedes the date
specifications of RFC 822) using the current System time and date.
- Returns:
- A String containing the date.
toRFC1123DateString
public static String toRFC1123DateString(Calendar when)
- Return a String containing an RFC 1123-compliant date String (RFC 1123 supercedes the date
specifications of RFC 822) using the specified time and date.
- Parameters:
- when - the Calendar object to use for creating the String.
- Returns:
- A String containing the date.
All Packages Class Hierarchy This Package Previous Next Index