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 $

Constructor Index

 o StringUtils()

Method Index

 o betweenTags(String, String, String)
Given a string containing markup tags, this function will separate out all elements between a given start and end tag.
 o blowAwayTags(String)
Given a string of HTML or other text containing URLs, this brutally simplistic function will singlemindedly strip out anything between < and > marks.
 o createCompactDateString()
Return a String containing a compact date/time using the current System time and date.
 o createCompactDateString(Calendar)
Return a String containing a compact date/time using the time and date provided.
 o createCompactDateString(Calendar, String, String, String)
Return a String containing a compact date/time using the specified time and date, with user-specified delimiters.
 o createCompactDateString(String, String, String)
Return a String containing a compact date/time using the current System time and date, with user-specified delimiters.
 o 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.
 o displayTimeUnits(long, boolean)
Converts millisecond sinto a human-readable String of days, hours, minutes, seconds, and milliseconds.
 o 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.
 o indexOfIgnoreCase(String, String)
indexOfIgnoreCase is an analog to the indexOf method for the String class.
 o indexOfIgnoreCase(String, String, int)
indexOfIgnoreCase is an analog to the indexOf method for the String class.
 o indexOfIgnoreCase(String, String, int, int)
indexOfIgnoreCase is an analog to the indexOf method for the String class.
 o isAlphaNumeric(String)
Determines whether a string contains any characters that are not alphanumeric.
 o isAlphaSafeString(String)
Determines whether a string contains any characters that are not either alphanumeric or period, underscore, space, or hyphen.
 o 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.
 o reasonableTimeUnits(long)
Converts millisecond sinto a human-readable String of days, hours, minutes, seconds, and milliseconds.
 o replaceSubstring(String, String, String)
Given a string, this will replace all instances of a given substring with another given string.
 o replaceSubstringIgnoreCase(String, String, String)
Given a string, this will replace all instances of a given substring with another given string.
 o singleBetweenTags(String, String, String)
Given a string containing markup tags, this function will return the first element between a given start and end tag.
 o 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
 o toMixedCase(String)
This Function Will Convert A String To Start Each Word With An Upper Case Character.
 o 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.
 o 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.

Constructors

 o StringUtils
 public StringUtils()

Methods

 o 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
 o 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
 o 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
 o 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
 o isAlphaNumeric
 public static boolean isAlphaNumeric(String theString)
Determines whether a string contains any characters that are not alphanumeric.

Parameters:
theString - String to be searched
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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).
 o 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.
 o 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
 o 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
 o 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
 o 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.
 o 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".
 o 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".
 o 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.
 o 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.
 o 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.
 o 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