com.isti.util
Class UtilFns

java.lang.Object
  extended by com.isti.util.UtilFns
All Implemented Interfaces:
StringConstants, TimeConstants

public class UtilFns
extends java.lang.Object
implements StringConstants, TimeConstants

Class UtilFns contains various static utility methods.


Field Summary
static int colorPropertyStringLength
           
static java.lang.String DEF_SPECIAL_CHARS_STR
          String of special characters for 'insertQuoteChars()' method.
static java.lang.String[] FAKE_IP_ADDRS
          List of IP addresses for 'getLocalHostName()' to try to ignore.
static java.util.TimeZone GMT_TIME_ZONE_OBJ
          TimeZone object setup for "GMT".
static java.lang.String newline
          A static string containing the proper system-dependent value for the "newline" character sequence.
static CfgPropValidator timeZoneValidator
           
 
Fields inherited from interface com.isti.util.StringConstants
ALPHA_CAP_CHARS, ALPHA_CHARS, ALPHA_LOW_CHARS, ALPHANUM_CHARS_STRING, ALPHANUMERIC_CHARS, BOOLEAN_FALSE_TEXT, BOOLEAN_TRUE_TEXT, DATE_FORMAT_AMPM_STR, DATE_FORMAT_RFC_822_STR, DATE_FORMAT24_STR, DEFAULT_JAVA_VERSION_STRING, DEFAULT_NULL_STR, DEFAULT_SEP_STR, EFLOAT_CHARS, EMPTY_STRING, FLOAT_CHARS, HEX_ALPHA_CAP_CHARS, HEX_ALPHA_LOW_CHARS, HEX_CHARS, INTEGER_CHARS, INVALID_FILENAME_CHARS, QUOTE_STRING, SIGNED_EFLOAT_CHARS, SIGNED_FLOAT_CHARS, SIGNED_INT_CHARS, SPACE_STRING, TOD_CHARS, WHITE_SPACE_CHARS, WILDCARD_ALL_CHAR, WILDCARD_CHARS, WILDCARD_SINGLE_CHAR
 
Fields inherited from interface com.isti.util.TimeConstants
HOURS_PER_DAY, MINUTES_PER_DAY, MINUTES_PER_HOUR, MS_PER_DAY, MS_PER_HOUR, MS_PER_MINUTE, MS_PER_SECOND, SECONDS_PER_DAY, SECONDS_PER_MINUTE
 
Method Summary
static void addDataChangedListener(DataChangedListener listenerObj)
          Registers the given 'DataChangedListener' object to be notified when the data such as the default locale is changed.
static void beep()
          Emits an audio beep.
static java.lang.String booleanToString(boolean b)
          Converts the given boolean value to a string.
static java.lang.Boolean booleanValueOf(boolean b)
          Converts the given boolean value to a Boolean.
static java.lang.Boolean booleanValueOf(java.lang.String s)
          Converts the given string to a Boolean.
static java.lang.String capFirstLetter(java.lang.String str)
          Returns a new version of the given string that has its first character capitialized (if possible).
static java.lang.String charToString(char ch)
          Returns a string containing the given single character.
static boolean checkJavaVersion(java.lang.String javaVersionString, java.lang.String minJavaVersionString)
          Checks the Java version.
static java.lang.String colorRGBToString(int colorRGBVal)
          Converts the given integer color RGB value to a string name corresponding to the color.
static java.lang.String colorRGBToString(int colorRGBVal, boolean useHexFlag)
          Converts the given integer color RGB value to a string name corresponding to the color.
static java.lang.String colorToPropertyString(java.awt.Color colorObj)
          Converts the given integer color value to a property string name corresponding to the color.
static int compareVersionStrings(java.lang.String ver1Str, java.lang.String ver2Str)
          Compares two version strings containing version number values separated by periods ('.').
static java.lang.String createCenteredString(java.lang.String inString, int fieldLen)
          Returns a "centered" version of the given string.
static java.text.DateFormat createDateFormatObj(java.lang.String patternStr)
          Creates a 'DateFormat' object and applies the given pattern string to it.
static java.text.DateFormat createDateFormatObj(java.lang.String patternStr, java.util.Locale localeObj)
          Creates a 'DateFormat' object and applies the given pattern string to it.
static java.text.DateFormat createDateFormatObj(java.lang.String patternStr, java.util.TimeZone timeZoneObj)
          Creates a 'DateFormat' object and applies the given pattern string to it.
static java.text.DateFormat createDateFormatObj(java.lang.String patternStr, java.util.TimeZone timeZoneObj, java.util.Locale localeObj)
          Creates a 'DateFormat' object and applies the given pattern string to it.
static java.text.NumberFormat createFloatNumberFormat()
          Creates a float number formatter.
static java.text.NumberFormat createFloatNumberFormat(int numDigits)
          Creates a float number formatter.
static java.text.NumberFormat createFloatNumberFormat(int minDigits, int maxDigits)
          Creates a float number formatter.
static java.text.NumberFormat createFloatNumberFormat(int minDigits, int maxDigits, java.util.Locale localeObj)
          Creates a float number formatter.
static java.text.NumberFormat createFloatNumberFormat(int numDigits, java.util.Locale localeObj)
          Creates a float number formatter.
static java.text.NumberFormat createFloatNumberFormat(java.util.Locale localeObj)
          Creates a float number formatter.
static java.text.NumberFormat createFloatNumberFormat(java.lang.String patternStr)
          Creates a float number formatter.
static java.text.NumberFormat createFloatNumberFormat(java.lang.String patternStr, java.util.Locale localeObj)
          Creates a float number formatter.
static java.util.Timer createNamedTimerObj(java.lang.String nameStr, boolean daemonFlag)
          Creates a new "java.util.Timer" object whose associated thread has the specified name, and may be specified to run as a daemon.
static java.awt.Color createOpaqueColor(java.awt.Color colorObj)
          Returns a fully opaque version of the given color (with alpha = 255).
static java.lang.String dateToRFC_822String(java.util.Date date)
          Converts the given Date into a RFC-822 date/time string.
static java.lang.String durationMillisToString(long durationMs)
          Returns a duration-time string for the given time value.
static java.lang.String durationMillisToString(long durationMs, boolean showDaysFlag)
          Returns a duration-time string for the given time value.
static java.lang.String durationMillisToString(long durationMs, boolean showDaysFlag, boolean showSecsFlag)
          Returns a duration-time string for the given time value.
static java.lang.String durationMillisToString(long durationMs, boolean showDaysFlag, boolean showSecsFlag, boolean verboseFlag)
          Returns a duration-time string for the given time value.
static boolean endsWith(java.lang.String str, java.lang.String suffix, boolean ignoreCase)
          Check if a string ends with a specified suffix (optionally case insensitive).
static boolean endsWithIgnoreCase(java.lang.String str, java.lang.String suffix)
          Case insensitive check if a string ends with a specified prefix.
static java.util.Iterator enumToIterator(java.util.Enumeration e)
          Converts the enumeration to an iterator.
static java.lang.String enumToListString(java.util.Enumeration e)
          Returns a string representation of the data elements referenced by the given enumeration.
static java.lang.String enumToQuotedStrings(java.util.Enumeration enumObj)
          Returns a String of substrings gathered from the given enumeration.
static java.lang.String enumToQuotedStrings(java.util.Enumeration enumObj, char sepChar, boolean quoteCharsFlag)
          Returns a String of substrings gathered from the given enumeration.
static java.lang.String enumToQuotedStrings(java.util.Enumeration enumObj, java.lang.String sepStr, boolean quoteCharsFlag)
          Returns a String of substrings gathered from the given enumeration.
static java.lang.String enumToString(java.util.Enumeration e)
          Returns a string representation of the data elements referenced by the given enumeration.
static java.lang.String fileNameToString(java.lang.String fNameStr)
          Converts a file-name string that was encoded via 'stringToFileName()' back to its original form.
static int findCharPos(java.lang.String str, char ch)
          Searches the entire given string for the position of the given character.
static int findCharPos(java.lang.String str, char ch, int startPos)
          Searches the given string for the position of the given character.
static int findCharPos(java.lang.String str, java.lang.String searchCharsStr)
          Searches the given string for the first occurrence of any character in the given search string.
static int findCharPos(java.lang.String str, java.lang.String searchCharsStr, int startPos)
          Searches the given string for the first occurrence of any character in the given search string.
static void fireDataChanged(java.lang.Object sourceObj)
          Called to indicate that this object has changed.
static java.lang.String fixStringLen(java.lang.String inString, int outLen)
          Returns the given string "fixed" to the desired length, truncating or adding spaces as necessary.
static java.lang.String fixStringLen(java.lang.String inString, int outLen, boolean rightJustFlag)
          Returns the given string "fixed" to the desired length, truncating or adding spaces as necessary.
static java.lang.String fixStringLen(java.lang.String inString, int outLen, boolean rightJustFlag, boolean truncateFlag)
          Returns the given string "fixed" to the desired length, (possibly) truncating or adding spaces as necessary.
static java.lang.String floatNumberToPropertyString(java.lang.Object value)
          Converts the given float number value to a property string.
static java.lang.String floatNumberToString(double value)
          Converts the given float number value to a string where the value displayed will be at least one fractional digit and will always be non-zero as long as the value is greater than zero.
static java.lang.String floatNumberToString(double value, int digits)
          Converts the given float number value to a string.
static java.lang.String floatNumberToString(double value, int digits, int columns, java.lang.Comparable maxValueObj)
          Converts the given float number value to a string.
static java.lang.String getColorDisplayName(int value)
          Gets the display name for the specifed color value.
static int getColorDisplayNameIndex(int value)
          Gets the display name index for the specifed color value.
static java.lang.String[] getColorDisplayNames()
          Gets a list of string color display names.
static int getColorDisplayNameValue(int index)
          Gets the value for the specified display name index.
static char getDecimalSeparator()
          Gets the decimal separator character.
static java.util.Locale getDefaultLocale()
          Gets the default locale.
static java.lang.String getJavaVersion()
          Gets the Java version.
static java.net.InetAddress getLocalHostAddrObj()
          Returns an Internet-address object for the local host.
static java.net.InetAddress getLocalHostAddrObj(boolean preferIP4Flag)
          Returns an Internet-address object for the local host.
static java.net.InetAddress getLocalHostAddrObj(boolean preferIP4Flag, java.lang.StringBuffer addrInfoBuff)
          Returns an Internet-address object for the local host.
static java.lang.String getLocalHostIP()
          Returns the local host IP.
static java.lang.String getLocalHostIP(java.net.InetAddress addrObj)
          Returns the host IP address for the given address object.
static java.lang.String getLocalHostName()
          Returns the local host name.
static java.lang.String getLocalHostName(java.net.InetAddress addrObj)
          Returns the local host name.
static java.lang.String getMemoryInfoStr()
          Returns a string of memory information.
static java.lang.String getPrettyString(java.lang.String str)
          Returns a pretty version of the specified string: Capatilizes the first letter of every word.
static java.lang.String getPrettyString(java.lang.String str, boolean allUpperFlag)
          Returns a pretty version of the specified string: Replaces periods with spaces.
static java.lang.ThreadGroup getRootThreadGroupObj()
          Returns the root ThreadGroup object.
static java.lang.String getSpacerString(int numSpaces)
          Returns a string containing the given number of space characters.
static java.lang.String getStackTraceString(java.lang.Throwable throwObj)
          Fetches stack trace data from a throwable and returns it in a string.
static java.util.Locale getSystemLocale()
          Gets the system locale.
static long getSystemTimeSec()
          Returns the current time in seconds since midnight, January 1, 1970 UTC.
static java.lang.String getTableContentsString(java.util.Map tableObj)
          Creates a string of "key" = "value" items from the given table/map, with ", " separating the items.
static java.lang.String getTableContentsString(java.util.Map tableObj, java.lang.String sepStr)
          Creates a string of "key" = "value" items from the given table/map.
static java.lang.String[] getTimeZoneIDs()
          Gets all the available time zone IDs supported.
static int getTotalThreadCount()
          Returns a count of the total number of threads in the JVM.
static java.lang.String getUserConsoleString()
          Inputs a line of data from the user console (System.in).
static int indexOfWhitespace(java.lang.String str)
          Searches the given string for the first occurrence of a whitespace character.
static int indexOfWhitespace(java.lang.String str, int startPos)
          Searches the given string for the first occurrence of a whitespace character.
static java.lang.String insertQuoteChars(java.lang.String dataStr, java.lang.String specialChars)
          Returns a string with a backslash quote character ('\') inserted in front of each occurance of a "special" character in the given source string.
static long intTimeToLong(int intTime)
          Converts a 32-bit integer value to a 64-bit long as if the value is unsigned.
static boolean isBlank(java.lang.String str)
          Checks if a string is blank (trimmed to "" or null).
static boolean isEmpty(java.lang.String str)
          Checks if a string is empty ("" or null).
static boolean isFakeIPAddress(java.lang.String str)
          Returns true if the given string contains a "fake" IP address (one that cannot be used as a "real" Internet address).
static boolean isIPAddress(java.lang.String str)
          Returns true if the contents of the given string qualify as a valid IP address (in the from #.#.#.#); otherwise returns false.
static boolean isURLAddress(java.lang.String str)
          Returns true if the contents of the given string qualify as a valid URL address; otherwise returns false.
static boolean isValidFileNameChar(char ch)
          Determines if the character is valid for a filename.
static java.util.Enumeration iteratorToEnum(java.util.Iterator it)
          Converts the iterator to an enumeration.
static java.lang.String listObjToListStr(java.util.List listObj, java.lang.String sepStr)
          Returns a String of substrings gathered from the given list.
static java.util.Vector listStringToVector(java.lang.String str)
          Returns a Vector of substrings from the given list string.
static java.util.Vector listStringToVector(java.lang.String str, char sepChar, boolean trimFlag)
          Returns a Vector of substrings from the given list string.
static boolean moveListElement(java.util.List listObj, int index, java.lang.Object element)
          Moves the specified element to the specified position in the specified list if it already present, otherwise it adds it at the position.
static java.lang.String normalizeString(java.lang.String str)
          Returns a new string with all surrounding whitespace removed and internal whitespace normalized to a single space.
static Archivable parseArchivable(Archivable defaultValueObj, java.lang.String dataStr)
          Converts the given data string to an 'Archivable' object.
static Archivable parseArchivable(java.lang.Class valueClass, java.lang.String dataStr)
          Converts the given data string to an 'Archivable' object.
static java.awt.Color parseColor(java.lang.String colorString)
          Converts the given property string name to a color value.
static int parseLeadingInt(java.lang.String numStr)
          Parses the leading digits of string as an integer while ignoring any trailing non-digit characters.
static java.lang.Number parseNumber(java.lang.String str)
          Converts the given string to a 'Number' object.
static java.lang.Number parseNumber(java.lang.String str, java.lang.Class valueClass)
          Converts the given string to a 'Number' object.
static java.lang.Object parseObject(java.lang.Class valueClass, java.lang.String dataStr)
          Converts the given data string to an object.
static java.lang.Object parseObject(java.lang.Object defaultValueObj, java.lang.String dataStr)
          Converts the given data string to an object.
static java.lang.String[] parseSeparatedSubstrings(java.lang.String dataStr, java.lang.String sepStr)
          Parses a string of substrings using the given separator.
static java.lang.String[] parseSeparatedSubstrings(java.lang.String dataStr, java.lang.String sepStr, char quoteChar, boolean trimFlag)
          Parses a string of substrings using the given separator.
static java.lang.String[] parseSeparatedSubstrings(java.lang.String dataStr, java.lang.String sepStr, char quoteChar, boolean trimFlag, boolean removeQuotesFlag)
          Parses a string of substrings using the given separator.
static java.util.ArrayList parseSeparatedSubstrsToList(java.lang.String dataStr, java.lang.String sepStr)
          Parses a string of substrings using the given separator.
static java.util.ArrayList parseSeparatedSubstrsToList(java.lang.String dataStr, java.lang.String sepStr, char quoteChar, boolean trimFlag)
          Parses a string of substrings using the given separator.
static java.util.ArrayList parseSeparatedSubstrsToList(java.lang.String dataStr, java.lang.String sepStr, char quoteChar, boolean trimFlag, boolean removeQuotesFlag)
          Parses a string of substrings using the given separator.
static java.util.Date parseStringToDate(java.lang.String s)
          Parses the given time value string using the 24-hour clock format and the local time zone.
static java.util.Date parseStringToDate(java.lang.String s, boolean gmtFlag)
          Parses the given time value string using the 24-hour clock format.
static java.util.Date parseStringToDate(java.lang.String dateStr, boolean gmtFlag, boolean amPmFlag)
          Parses the given time value string.
static java.util.TimeZone parseTimeZoneID(java.lang.String id)
          Parses the time zone ID property.
static java.lang.Integer[] parseVersionNumbers(java.lang.String verStr)
          Parses a version string into integer values.
static java.util.Vector quotedStringsToVector(java.lang.String str)
          Returns a Vector of substrings from the given string.
static java.util.Vector quotedStringsToVector(java.lang.String str, char sepChar)
          Returns a Vector of substrings from the given string.
static java.util.Vector quotedStringsToVector(java.lang.String str, char sepChar, boolean strictFlag)
          Returns a Vector of substrings from the given string.
static java.util.Vector quotedStringsToVector(java.lang.String str, java.lang.String sepCharsStr, boolean strictFlag)
          Returns a Vector of substrings from the given string.
static void removeDataChangedListener(DataChangedListener listenerObj)
          Unregisters the given 'DataChangedListener' object from the list of listeners for data.
static java.util.Vector removeEmptyStrings(java.util.Vector vec)
          Removes items from the given Vector that are empty string or null.
static java.lang.String removeNonAlphanumChars(java.lang.String str)
          Returns a new string with all non-alphnumeric characters removed.
static java.lang.String removeQuoteChars(java.lang.String dataStr)
          Removes the backslash quote characters ('\') put in by 'insertQuoteChars()'.
static java.lang.String removeQuoteChars(java.lang.String dataStr, boolean removeDblFlag)
          Removes the backslash quote characters ('\') put in by 'insertQuoteChars()'.
static java.lang.String removeSpecifiedChars(java.lang.String str, java.lang.String keepCharsStr)
          Returns a new string with all characters not matching the given keep-characters string removed.
static java.lang.String replaceAllSubstrings(java.lang.String dataStr, java.lang.String oldStr, java.lang.String newStr)
          Replace all of the occurrences of a given substring with a new substring.
static java.lang.String replaceSubstring(java.lang.String dataStr, java.lang.String oldStr, java.lang.String newStr)
          Replace the first occurrence of a given substring with a new substring.
static boolean setDateFormatPattern(java.text.DateFormat formatObj, java.lang.String patternStr)
          Sets the pattern string for the given 'DateFormat' object.
static void setDateFormatSymbols(java.text.DateFormat formatObj, java.text.DateFormatSymbols newSymbols)
          Sets the date format symbols for the date format object.
static void setDecimalFormatSymbols(java.text.NumberFormat formatObj, java.text.DecimalFormatSymbols newSymbols)
          Sets the decimal format symbols for the number format object.
static void setDefaultLocale(java.util.Locale localeObj)
          Sets the default locale.
static java.net.URL setURLReference(java.net.URL urlObj, java.lang.String refStr)
          Creates a new URL containing the given reference (anchor) string.
static java.lang.String shortClassString(java.lang.Class classObj)
          Converts the given Class object to "short" String name (with "java.lang." removed).
static boolean sleep(long millisecs)
          Delays for the given number of milliseconds.
static java.lang.String softWordWrapString(java.lang.String srcStr, int lineWidth, java.lang.String indentStr)
          Performs a "soft" word-wrap of the given data.
static java.lang.String softWordWrapString(java.lang.String srcStr, int lineWidth, java.lang.String indentStr, java.lang.String newLineStr)
          Performs a "soft" word-wrap of the given data.
static java.lang.String softWordWrapString(java.lang.String srcStr, int lineWidth, java.lang.String indentStr, java.lang.String newLineStr, java.lang.String sepCharsStr)
          Performs a "soft" word-wrap of the given data.
static boolean startsWith(java.lang.String str, java.lang.String prefix, boolean ignoreCase)
          Check if a string starts with a specified prefix (optionally case insensitive).
static boolean startsWithIgnoreCase(java.lang.String str, java.lang.String prefix)
          Case insensitive check if a string starts with a specified prefix.
static java.lang.String stringArrayToString(java.lang.String[] strArr)
          Converts an array of strings to a single string containing all the strings in the array (each separated by a space).
static java.lang.String stringArrayToString(java.lang.String[] strArr, java.lang.String sepStr)
          Converts an array of strings to a single string containing all the strings in the array.
static boolean stringToBoolean(java.lang.String s)
          Converts the given string to a boolean value.
static boolean stringToBoolean(java.lang.String s, boolean defaultValue)
          Converts the given string to a boolean value.
static java.lang.Integer stringToColorRGB(java.lang.String str)
          Converts the given string to the integer RGB representation of the corresponding color.
static java.lang.Integer stringToColorRGB(java.lang.String str, boolean tryRGBFlag)
          Converts the given color name string to the integer RGB representation of the corresponding color.
static java.lang.String stringToFileName(java.lang.String str)
          Converts the given string to a string that is safe to use as a file name.
static java.lang.String stripBrackets(java.lang.String str)
          Returns a new string created by stripping the bracket characters from around the given string.
static java.lang.String stripChar(java.lang.String str, char ch)
          Removes all occurrences of the given character from the given string.
static java.lang.String stripTrailingNewline(java.lang.String dataStr)
          Removes a newline from the end of a "data" string.
static java.lang.String stripTrailingString(java.lang.String dataStr, java.lang.String stripStr)
          Removes a given "strip" string from the end of a "data" string.
static java.lang.String timeMillisToRFC_822String(long millis)
          Converts the given integer time value to a RFC-822 date/time string.
static java.lang.String timeMillisToString()
          Converts the current time value to a date/time string using the 24-hour clock format and the local time zone.
static java.lang.String timeMillisToString(long millis)
          Converts the given integer time value to a date/time string using the 24-hour clock format and the local time zone.
static java.lang.String timeMillisToString(long millis, boolean gmtFlag)
          Converts the given integer time value to a date/time string using the 24-hour clock format.
static java.lang.String timeMillisToString(long millis, boolean gmtFlag, boolean amPmFlag)
          Converts the given integer time value to a date/time string.
static void toGlobalLogFileWarn(java.lang.String msgStr)
          Sends the given message to the "global" log file object.
static java.lang.String toHexString(int i, int numDigits)
          Creates a string representation of the integer argument as an unsigned integer in base-16.
static java.util.List toList(java.lang.Object[] a)
          Get a fixed-size list backed by the specified array.
static java.lang.String toString(java.lang.Object obj)
          Get the string representation of the Object argument using the default separator string.
static java.lang.String toString(java.lang.Object obj, java.lang.String nullStr)
          Get the string representation of the Object argument without a separator string.
static java.lang.String toString(java.lang.Object obj, java.lang.String nullStr, java.lang.String sepStr)
          Get the string representation of the Object argument using the specified separator string.
static java.lang.String toString(java.lang.Object obj, java.lang.String nullStr, java.lang.String sepStr, java.util.Collection all)
          Get the string representation of the Object argument using the specified separator string.
static java.lang.String trimEndStr(java.lang.String str)
          Trims whitespace at the end of the given string.
static java.lang.String trimMultiLineString(java.lang.String inString)
          Trims leading and trailing whitespace from each line inside of the given string (while retaining the line separations).
static java.lang.String trimMultiLineString(java.lang.String inString, int centerFieldLen)
          Trims leading and trailing whitespace from each line inside of the given string (while retaining the line separations).
static java.lang.String trimMultiLineString(java.lang.String inString, java.lang.String newLineStr)
          Trims leading and trailing whitespace from each line inside of the given string (while retaining the line separations).
static java.lang.String trimMultiLineString(java.lang.String inString, java.lang.String newLineStr, int centerFieldLen)
          Trims leading and trailing whitespace from each line inside of the given string (while retaining the line separations).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GMT_TIME_ZONE_OBJ

public static final java.util.TimeZone GMT_TIME_ZONE_OBJ
TimeZone object setup for "GMT".


colorPropertyStringLength

public static final int colorPropertyStringLength
See Also:
Constant Field Values

timeZoneValidator

public static final CfgPropValidator timeZoneValidator

newline

public static final java.lang.String newline
A static string containing the proper system-dependent value for the "newline" character sequence. This string may be embedded into other strings that are then displayed or written to files. Its value is set by a static initializer.


FAKE_IP_ADDRS

public static final java.lang.String[] FAKE_IP_ADDRS
List of IP addresses for 'getLocalHostName()' to try to ignore.


DEF_SPECIAL_CHARS_STR

public static final java.lang.String DEF_SPECIAL_CHARS_STR
String of special characters for 'insertQuoteChars()' method.

See Also:
Constant Field Values
Method Detail

checkJavaVersion

public static boolean checkJavaVersion(java.lang.String javaVersionString,
                                       java.lang.String minJavaVersionString)
Checks the Java version.

Parameters:
javaVersionString - the current Java version string.
minJavaVersionString - the minimum Java version string.
Returns:
true if the current Java version is not less than the minimum, false otherwise.

getJavaVersion

public static java.lang.String getJavaVersion()
Gets the Java version.

Returns:
the Java version or "(Unknown)" if unavailable.

getSystemTimeSec

public static long getSystemTimeSec()
Returns the current time in seconds since midnight, January 1, 1970 UTC.

Returns:
The current time in seconds since midnight, January 1, 1970 UTC.

intTimeToLong

public static long intTimeToLong(int intTime)
Converts a 32-bit integer value to a 64-bit long as if the value is unsigned. This is useful for converting epoch time values back to 'long' after they have been cast to 'int' (extending the useful range into 2/2106).

Parameters:
intTime - a time value in seconds.
Returns:
The 'long' integer version of the time value.

dateToRFC_822String

public static final java.lang.String dateToRFC_822String(java.util.Date date)
Converts the given Date into a RFC-822 date/time string.

Parameters:
date - the time value to be formatted into a time string.
Returns:
the RFC-822 date/time string.

timeMillisToRFC_822String

public static final java.lang.String timeMillisToRFC_822String(long millis)
Converts the given integer time value to a RFC-822 date/time string.

Parameters:
millis - a time in milliseconds since midnight, January 1, 1970 UTC.
Returns:
the RFC-822 date/time string.

timeMillisToString

public static java.lang.String timeMillisToString(long millis,
                                                  boolean gmtFlag,
                                                  boolean amPmFlag)
Converts the given integer time value to a date/time string.

Parameters:
millis - a time in milliseconds since midnight, January 1, 1970 UTC.
gmtFlag - true for GMT time zone, false for local time zone.
amPmFlag - true for AM/PM clock, false for 24-hour clock.
Returns:
A string representation of the given time, using some variation of following format: "Mmm dd yyyy hh:mm:ss ZZZ".

timeMillisToString

public static java.lang.String timeMillisToString(long millis,
                                                  boolean gmtFlag)
Converts the given integer time value to a date/time string using the 24-hour clock format.

Parameters:
millis - a time in milliseconds since midnight, January 1, 1970 UTC.
gmtFlag - true for GMT time zone, false for local time zone.
Returns:
A string representation of the given time, using some variation of following format: "Mmm dd yyyy hh:mm:ss ZZZ".

timeMillisToString

public static java.lang.String timeMillisToString(long millis)
Converts the given integer time value to a date/time string using the 24-hour clock format and the local time zone.

Parameters:
millis - a time in milliseconds since midnight, January 1, 1970 UTC.
Returns:
A string representation of the given time, using some variation of following format: "Mmm dd yyyy hh:mm:ss ZZZ".

timeMillisToString

public static java.lang.String timeMillisToString()
Converts the current time value to a date/time string using the 24-hour clock format and the local time zone.

Returns:
A string representation of the given time, using some variation of following format: "Mmm dd yyyy hh:mm:ss ZZZ".

durationMillisToString

public static java.lang.String durationMillisToString(long durationMs,
                                                      boolean showDaysFlag,
                                                      boolean showSecsFlag,
                                                      boolean verboseFlag)
Returns a duration-time string for the given time value.

Parameters:
durationMs - the number of milliseconds.
showDaysFlag - if true and the number of hours is not less than 24 then the number of days is displayed; if false then the total number of hours is always displayed.
showSecsFlag - if true then the number of seconds is included.
verboseFlag - if true then show verbose text.
Returns:
A duration-time string in form: "# days H:MM:SS" (with the days and seconds display controlled by the flag parameters).

durationMillisToString

public static java.lang.String durationMillisToString(long durationMs,
                                                      boolean showDaysFlag,
                                                      boolean showSecsFlag)
Returns a duration-time string for the given time value.

Parameters:
durationMs - the number of milliseconds.
showDaysFlag - if true and the number of hours is not less than 24 then the number of days is displayed; if false then the total number of hours is always displayed.
showSecsFlag - if true then the number of seconds is included.
Returns:
A duration-time string in form: "# days H:MM:SS" (with the days and seconds display controlled by the flag parameters).

durationMillisToString

public static java.lang.String durationMillisToString(long durationMs,
                                                      boolean showDaysFlag)
Returns a duration-time string for the given time value. The number of seconds is included in the display.

Parameters:
durationMs - the number of milliseconds.
showDaysFlag - if true and the number of hours is not less than 24 then the number of days is displayed; if false then the total number of hours is always displayed.
Returns:
A duration-time string in form: "# days H:MM:SS" (with the days and seconds display controlled by the flag parameters).

durationMillisToString

public static java.lang.String durationMillisToString(long durationMs)
Returns a duration-time string for the given time value. The number of seconds is included in the display. If the number of hours is not less than 24 then the number of days is displayed.

Parameters:
durationMs - the number of milliseconds.
Returns:
A duration-time string in form: "# days H:MM:SS" (with the days and seconds display controlled by the flag parameters).

parseStringToDate

public static java.util.Date parseStringToDate(java.lang.String dateStr,
                                               boolean gmtFlag,
                                               boolean amPmFlag)
Parses the given time value string.

Parameters:
dateStr - a date/time string in the form "MMM dd yyyy hh:mm:ss [a] z".
gmtFlag - true for GMT time zone, false for local time zone.
amPmFlag - true for AM/PM clock, false for 24-hour clock.
Returns:
A Date, or null if the input could not be parsed.

parseStringToDate

public static java.util.Date parseStringToDate(java.lang.String s,
                                               boolean gmtFlag)
Parses the given time value string using the 24-hour clock format.

Parameters:
s - the time value string.
gmtFlag - true for GMT time zone, false for local time zone.
Returns:
A Date, or null if the input could not be parsed.

parseStringToDate

public static java.util.Date parseStringToDate(java.lang.String s)
Parses the given time value string using the 24-hour clock format and the local time zone.

Parameters:
s - the time value string.
Returns:
A Date, or null if the input could not be parsed.

setDateFormatPattern

public static boolean setDateFormatPattern(java.text.DateFormat formatObj,
                                           java.lang.String patternStr)
Sets the pattern string for the given 'DateFormat' object. If the given 'DateFormat' object is not of type 'SimpleDateFormat' then it is left unchanged. See the Java help reference for 'SimpleDateFormat' for details on the characters used in the pattern string.

Parameters:
formatObj - the 'DateFormat' to be changed.
patternStr - the pattern string to apply.
Returns:
true if the pattern was applied successfully; false if an error occurred.

addDataChangedListener

public static void addDataChangedListener(DataChangedListener listenerObj)
Registers the given 'DataChangedListener' object to be notified when the data such as the default locale is changed.

Parameters:
listenerObj - the 'DataChangedListener' object.

removeDataChangedListener

public static void removeDataChangedListener(DataChangedListener listenerObj)
Unregisters the given 'DataChangedListener' object from the list of listeners for data.

Parameters:
listenerObj - the 'DataChangedListener' object.

fireDataChanged

public static void fireDataChanged(java.lang.Object sourceObj)
Called to indicate that this object has changed. Each registered listener's 'dataChanged()' method is called.

Parameters:
sourceObj - source object for the change.

getDefaultLocale

public static java.util.Locale getDefaultLocale()
Gets the default locale.

Returns:
the default locale.
See Also:
addDataChangedListener, removeDataChangedListener

getSystemLocale

public static java.util.Locale getSystemLocale()
Gets the system locale.

Returns:
the system locale.

getDecimalSeparator

public static char getDecimalSeparator()
Gets the decimal separator character.

Returns:
the decimal separator character.

setDateFormatSymbols

public static void setDateFormatSymbols(java.text.DateFormat formatObj,
                                        java.text.DateFormatSymbols newSymbols)
Sets the date format symbols for the date format object.

Parameters:
formatObj - the date format.
newSymbols - the date format symbols.

setDecimalFormatSymbols

public static void setDecimalFormatSymbols(java.text.NumberFormat formatObj,
                                           java.text.DecimalFormatSymbols newSymbols)
Sets the decimal format symbols for the number format object.

Parameters:
formatObj - the number format.
newSymbols - the decimal format symbols.

setDefaultLocale

public static void setDefaultLocale(java.util.Locale localeObj)
Sets the default locale.

Parameters:
localeObj - the default locale.
See Also:
addDataChangedListener, removeDataChangedListener

createDateFormatObj

public static java.text.DateFormat createDateFormatObj(java.lang.String patternStr,
                                                       java.util.TimeZone timeZoneObj)
Creates a 'DateFormat' object and applies the given pattern string to it. The recommended method of using "DateFormat.getDateTimeInstance()" is followed. See the Java help reference for 'SimpleDateFormat' for details on the characters used in the pattern string.

Parameters:
patternStr - the pattern string to apply.
timeZoneObj - timezone object to apply, or null or none.
Returns:
A new 'SimpleDateFormat' object with the given pattern string applied to it.

createDateFormatObj

public static java.text.DateFormat createDateFormatObj(java.lang.String patternStr,
                                                       java.util.TimeZone timeZoneObj,
                                                       java.util.Locale localeObj)
Creates a 'DateFormat' object and applies the given pattern string to it. The recommended method of using "DateFormat.getDateTimeInstance()" is followed. See the Java help reference for 'SimpleDateFormat' for details on the characters used in the pattern string.

Parameters:
patternStr - the pattern string to apply.
timeZoneObj - timezone object to apply, or null or none.
localeObj - the locale object.
Returns:
A new 'SimpleDateFormat' object with the given pattern string applied to it.

createDateFormatObj

public static java.text.DateFormat createDateFormatObj(java.lang.String patternStr)
Creates a 'DateFormat' object and applies the given pattern string to it. The recommended method of using "DateFormat.getDateTimeInstance()" is followed. See the Java help reference for 'SimpleDateFormat' for details on the characters used in the pattern string.

Parameters:
patternStr - the pattern string to apply.
Returns:
A new 'SimpleDateFormat' object with the given pattern string applied to it.

createDateFormatObj

public static java.text.DateFormat createDateFormatObj(java.lang.String patternStr,
                                                       java.util.Locale localeObj)
Creates a 'DateFormat' object and applies the given pattern string to it. The recommended method of using "DateFormat.getDateTimeInstance()" is followed. See the Java help reference for 'SimpleDateFormat' for details on the characters used in the pattern string.

Parameters:
patternStr - the pattern string to apply.
localeObj - the locale object.
Returns:
A new 'SimpleDateFormat' object with the given pattern string applied to it.

createFloatNumberFormat

public static java.text.NumberFormat createFloatNumberFormat()
Creates a float number formatter.

Returns:
A float number formatter.

createFloatNumberFormat

public static java.text.NumberFormat createFloatNumberFormat(java.util.Locale localeObj)
Creates a float number formatter.

Parameters:
localeObj - the locale object.
Returns:
A float number formatter.

createFloatNumberFormat

public static java.text.NumberFormat createFloatNumberFormat(int numDigits)
Creates a float number formatter.

Parameters:
numDigits - the minimum and maximum number of fraction digits to be shown.
Returns:
A float number formatter.

createFloatNumberFormat

public static java.text.NumberFormat createFloatNumberFormat(int numDigits,
                                                             java.util.Locale localeObj)
Creates a float number formatter.

Parameters:
numDigits - the minimum and maximum number of fraction digits to be shown.
localeObj - the locale object.
Returns:
A float number formatter.

createFloatNumberFormat

public static java.text.NumberFormat createFloatNumberFormat(int minDigits,
                                                             int maxDigits)
Creates a float number formatter.

Parameters:
minDigits - the minimum number of fraction digits to be shown.
maxDigits - the maximum number of fraction digits to be shown.
Returns:
A float number formatter.

createFloatNumberFormat

public static java.text.NumberFormat createFloatNumberFormat(int minDigits,
                                                             int maxDigits,
                                                             java.util.Locale localeObj)
Creates a float number formatter.

Parameters:
minDigits - the minimum number of fraction digits to be shown.
maxDigits - the maximum number of fraction digits to be shown.
localeObj - the locale object.
Returns:
A float number formatter.

createFloatNumberFormat

public static java.text.NumberFormat createFloatNumberFormat(java.lang.String patternStr)
Creates a float number formatter.

Parameters:
patternStr - the pattern string to apply.
Returns:
A float number formatter.

createFloatNumberFormat

public static java.text.NumberFormat createFloatNumberFormat(java.lang.String patternStr,
                                                             java.util.Locale localeObj)
Creates a float number formatter.

Parameters:
patternStr - the pattern string to apply.
localeObj - the locale object.
Returns:
A float number formatter.

createNamedTimerObj

public static java.util.Timer createNamedTimerObj(java.lang.String nameStr,
                                                  boolean daemonFlag)
Creates a new "java.util.Timer" object whose associated thread has the specified name, and may be specified to run as a daemon. This provides access to the Java 1.5 'Timer' constructor with (String,boolean) parameters while still retaining Java 1.4 compatibility. If the Java 1.5 'Timer' constructor is not available then an "unnamed-thread" 'Timer' object will be returned.

Parameters:
nameStr - name for associated thread.
daemonFlag - true if associated thread should run as a daemon.
Returns:
A new "java.util.Timer" object.

getTimeZoneIDs

public static java.lang.String[] getTimeZoneIDs()
Gets all the available time zone IDs supported.

Returns:
an array of time zone IDs.

parseTimeZoneID

public static java.util.TimeZone parseTimeZoneID(java.lang.String id)
Parses the time zone ID property.

Parameters:
id - time zone ID.
Returns:
time zone for the ID.

sleep

public static boolean sleep(long millisecs)
Delays for the given number of milliseconds.

Parameters:
millisecs - the number of milliseconds to delay.
Returns:
true if the delay was completed, false if the delay was interrupted via an 'InterruptedException'.

shortClassString

public static java.lang.String shortClassString(java.lang.Class classObj)
Converts the given Class object to "short" String name (with "java.lang." removed).

Parameters:
classObj - a Class object.
Returns:
A "short" string representation of the given class or an empty string if the given class could not be converted.

stripBrackets

public static java.lang.String stripBrackets(java.lang.String str)
Returns a new string created by stripping the bracket characters from around the given string. For example, "[word]" would return "word". If the brackets are not found then the original string is returned.

Parameters:
str - the string to use.
Returns:
A new converted string, or the original string if brackets were not found.

stripChar

public static java.lang.String stripChar(java.lang.String str,
                                         char ch)
Removes all occurrences of the given character from the given string.

Parameters:
str - the given string.
ch - the character to be removed.
Returns:
A new string containing the contents of the given string minus all occurrences of the given character; or the original string if no occurrences were found.

stripTrailingString

public static java.lang.String stripTrailingString(java.lang.String dataStr,
                                                   java.lang.String stripStr)
Removes a given "strip" string from the end of a "data" string.

Parameters:
dataStr - the data string to use.
stripStr - the "strip" string to be removed.
Returns:
The "data" string with the trailing "strip" string removed, or the original "data" string (if the trailing "strip" string was not found).

stripTrailingNewline

public static java.lang.String stripTrailingNewline(java.lang.String dataStr)
Removes a newline from the end of a "data" string.

Parameters:
dataStr - the data string to use.
Returns:
The "data" string with the trailing newline removed, or the original "data" string (if the trailing newline was not found).

parseNumber

public static java.lang.Number parseNumber(java.lang.String str)
Converts the given string to a 'Number' object.

Parameters:
str - the string to convert.
Returns:
One of the Number-extended class objects 'Integer', 'Double' or 'BooleanCp'; or null if the string could not be converted.

parseNumber

public static java.lang.Number parseNumber(java.lang.String str,
                                           java.lang.Class valueClass)
Converts the given string to a 'Number' object.

Parameters:
str - the string to convert.
valueClass - the specific number class for the value.
Returns:
One of the Number-extended class objects 'Integer', 'Double' or 'BooleanCp'; or null if the string could not be converted.

getUserConsoleString

public static java.lang.String getUserConsoleString()
Inputs a line of data from the user console (System.in). This method blocks until a line a data is entered.

Returns:
The entered string, or null if an I/O error occurred.

getColorDisplayNameIndex

public static int getColorDisplayNameIndex(int value)
Gets the display name index for the specifed color value.

Parameters:
value - the RGB value of the color.
Returns:
the index of the color or -1 if not found.
See Also:
getColorDisplayNames()

getColorDisplayNameValue

public static int getColorDisplayNameValue(int index)
Gets the value for the specified display name index.

Parameters:
index - the display name index.
Returns:
the RGB value of the color.
See Also:
getColorDisplayNames()

getColorDisplayName

public static java.lang.String getColorDisplayName(int value)
Gets the display name for the specifed color value.

Parameters:
value - the RGB value of the color.
Returns:
color name string or hex string if the color value was not found.
See Also:
getColorDisplayNames()

getColorDisplayNames

public static java.lang.String[] getColorDisplayNames()
Gets a list of string color display names.

Returns:
an array of display names.

stringToColorRGB

public static java.lang.Integer stringToColorRGB(java.lang.String str)
Converts the given string to the integer RGB representation of the corresponding color. (As matching the static fields in 'java.awt.Color'.) A case-insensitive comparison is used.

Parameters:
str - the string to be converted.
Returns:
An Integer object containing the integer RGB representation of the Color object corresponding to the given string, or null if the string could not be converted.

stringToColorRGB

public static java.lang.Integer stringToColorRGB(java.lang.String str,
                                                 boolean tryRGBFlag)
Converts the given color name string to the integer RGB representation of the corresponding color. (As matching the static fields in 'java.awt.Color'.) A case-insensitive comparison is used. If 'tryRGBFlag' is true and no color name match is found then the method will attempt to interpret the string as a numeric RGB value or values. As a single value, if it is a decimal value it is interpreted as an opaque sRGB color, otherwise it is interpreted as a sRGB color with an alpha component.

Parameters:
str - the string to be converted.
tryRGBFlag - if true then and no color name match is found then the method will attempt to interpret the string as a numeric RGB value or values.
Returns:
An Integer object containing the integer RGB representation of the Color object corresponding to the given string, or null if the string could not be converted.

booleanToString

public static java.lang.String booleanToString(boolean b)
Converts the given boolean value to a string.

Parameters:
b - the boolean value.
Returns:
the string representing the boolean value.

booleanValueOf

public static java.lang.Boolean booleanValueOf(boolean b)
Converts the given boolean value to a Boolean.

Parameters:
b - the boolean value.
Returns:
the Boolean.

booleanValueOf

public static java.lang.Boolean booleanValueOf(java.lang.String s)
Converts the given string to a Boolean.

Parameters:
s - the string representing the boolean value.
Returns:
the Boolean.

stringToBoolean

public static boolean stringToBoolean(java.lang.String s)
Converts the given string to a boolean value.

Parameters:
s - the string representing the boolean value.
Returns:
the boolean value.

stringToBoolean

public static boolean stringToBoolean(java.lang.String s,
                                      boolean defaultValue)
Converts the given string to a boolean value.

Parameters:
s - the string representing the boolean value.
defaultValue - the default value if the string is null.
Returns:
the boolean value.

colorRGBToString

public static java.lang.String colorRGBToString(int colorRGBVal)
Converts the given integer color RGB value to a string name corresponding to the color. (As matching the static fields in 'java.awt.Color'.)

Parameters:
colorRGBVal - the integer color RGB value to use.
Returns:
A string color name or null if the color RGB value could not be converted.

colorRGBToString

public static java.lang.String colorRGBToString(int colorRGBVal,
                                                boolean useHexFlag)
Converts the given integer color RGB value to a string name corresponding to the color. (As matching the static fields in 'java.awt.Color'.)

Parameters:
colorRGBVal - RGB value of color.
useHexFlag - true if hex string should be used if no match.
Returns:
A string color name if the color RGB value could be converted. Otherwise a hex string is returned if the useHexFlag is true or null if it is not.

toHexString

public static java.lang.String toHexString(int i,
                                           int numDigits)
Creates a string representation of the integer argument as an unsigned integer in base-16.

Parameters:
i - an integer.
numDigits - the number of hex digits to pad if necessary.
Returns:
the string representation of the unsigned integer value represented by the argument in hexadecimal (base 16).

colorToPropertyString

public static java.lang.String colorToPropertyString(java.awt.Color colorObj)
Converts the given integer color value to a property string name corresponding to the color.

Parameters:
colorObj - the color.
Returns:
A property string representing the color.

floatNumberToPropertyString

public static java.lang.String floatNumberToPropertyString(java.lang.Object value)
Converts the given float number value to a property string.

Parameters:
value - the number value.
Returns:
A property string representing the number.

floatNumberToString

public static java.lang.String floatNumberToString(double value)
Converts the given float number value to a string where the value displayed will be at least one fractional digit and will always be non-zero as long as the value is greater than zero.

Parameters:
value - the number value.
Returns:
A string representing the number.

floatNumberToString

public static java.lang.String floatNumberToString(double value,
                                                   int digits)
Converts the given float number value to a string.

Parameters:
value - the number value.
digits - the maximum number of fraction digits to be shown.
Returns:
A string representing the number.

floatNumberToString

public static java.lang.String floatNumberToString(double value,
                                                   int digits,
                                                   int columns,
                                                   java.lang.Comparable maxValueObj)
Converts the given float number value to a string.

Parameters:
value - the number value.
digits - the maximum number of fraction digits to be shown.
columns - the number of the columns for the string or 0 for no limit.
maxValueObj - the maximum value object or null if not needed.
Returns:
A string representing the number.

parseObject

public static java.lang.Object parseObject(java.lang.Class valueClass,
                                           java.lang.String dataStr)
Converts the given data string to an object.

Parameters:
valueClass - the value class.
dataStr - the data string.
Returns:
the object.

parseObject

public static java.lang.Object parseObject(java.lang.Object defaultValueObj,
                                           java.lang.String dataStr)
Converts the given data string to an object.

Parameters:
defaultValueObj - the default value object.
dataStr - the data string.
Returns:
the object.

parseArchivable

public static Archivable parseArchivable(java.lang.Class valueClass,
                                         java.lang.String dataStr)
Converts the given data string to an 'Archivable' object.

Parameters:
valueClass - the 'Archivable' value class.
dataStr - the data string.
Returns:
the 'Archivable' object.

parseArchivable

public static Archivable parseArchivable(Archivable defaultValueObj,
                                         java.lang.String dataStr)
Converts the given data string to an 'Archivable' object.

Parameters:
defaultValueObj - the 'Archivable' default value object.
dataStr - the data string.
Returns:
the 'Archivable' object.

parseColor

public static java.awt.Color parseColor(java.lang.String colorString)
                                 throws java.lang.NumberFormatException
Converts the given property string name to a color value.

Parameters:
colorString - the property string for the color.
Returns:
the color.
Throws:
java.lang.NumberFormatException - if the specified string cannot be interpreted as a color property string.

createOpaqueColor

public static java.awt.Color createOpaqueColor(java.awt.Color colorObj)
Returns a fully opaque version of the given color (with alpha = 255).

Parameters:
colorObj - the Color object to use.
Returns:
A new Color object.

insertQuoteChars

public static java.lang.String insertQuoteChars(java.lang.String dataStr,
                                                java.lang.String specialChars)
Returns a string with a backslash quote character ('\') inserted in front of each occurance of a "special" character in the given source string. If they are included in the string of "special" characters, the ASCII characters tab, newline, and carriage return are written as \t, \n, and \r, respectively.

Parameters:
dataStr - the data source string.
specialChars - a string of "special" characters, each of which should be quoted in the source string.
Returns:
a new string with its "special" characters quoted, or the original string if no matching "special" characters were found.

removeQuoteChars

public static java.lang.String removeQuoteChars(java.lang.String dataStr,
                                                boolean removeDblFlag)
Removes the backslash quote characters ('\') put in by 'insertQuoteChars()'. The sequences \t, \n, and \r are converted to the ASCII characters tab, newline, and carriage return, respectively.

Parameters:
dataStr - the data source string.
removeDblFlag - true to remove any surrounding pair of double-quote characters ("") from string; false to leave them alone.
Returns:
a new string with the quote characters removed, or the original string if no quote characters were found.

removeQuoteChars

public static java.lang.String removeQuoteChars(java.lang.String dataStr)
Removes the backslash quote characters ('\') put in by 'insertQuoteChars()'. The sequences \t, \n, and \r are converted to the ASCII characters tab, newline, and carriage return, respectively.

Parameters:
dataStr - the data source string.
Returns:
a new string with the quote characters removed, or the original string if no quote characters were found.

findCharPos

public static int findCharPos(java.lang.String str,
                              char ch,
                              int startPos)
Searches the given string for the position of the given character. Any occurrence of the given character that is preceded by a backslash character will be ignored. Areas of the string surrounded by double-quotes ("") are ignored, but any double-quote characters preceded by a backslash (\") are not considered to be opening or closing quote characters.

Parameters:
str - the string to search.
ch - the character to search for.
startPos - the position in the string to start searching from.
Returns:
The position at which the character was found, or -1 if the character was not found.

findCharPos

public static int findCharPos(java.lang.String str,
                              char ch)
Searches the entire given string for the position of the given character. Any occurrence of the given character that is preceded by a backslash character will be ignored. Areas of the string surrounded by double-quotes ("") are ignored, but any double-quote characters preceded by a backslash (\") are not considered to be opening or closing quote characters.

Parameters:
str - the string to search.
ch - the character to search for.
Returns:
The position at which the character was found, or -1 if the character was not found.

findCharPos

public static int findCharPos(java.lang.String str,
                              java.lang.String searchCharsStr,
                              int startPos)
Searches the given string for the first occurrence of any character in the given search string. Any occurrence of a search character that is preceded by a backslash character will be ignored. Areas of the string surrounded by double-quotes ("") are ignored, but any double-quote characters preceded by a backslash (\") are not considered to be opening or closing quote characters.

Parameters:
str - the string to search.
searchCharsStr - the string of search characters.
startPos - the position in the string to start searching from.
Returns:
The first position at which a search character was found, or -1 if none were found.

findCharPos

public static int findCharPos(java.lang.String str,
                              java.lang.String searchCharsStr)
Searches the given string for the first occurrence of any character in the given search string. Any occurrence of a search character that is preceded by a backslash character will be ignored. Areas of the string surrounded by double-quotes ("") are ignored, but any double-quote characters preceded by a backslash (\") are not considered to be opening or closing quote characters.

Parameters:
str - the string to search.
searchCharsStr - the string of search characters.
Returns:
The first position at which a search character was found, or -1 if none were found.

indexOfWhitespace

public static int indexOfWhitespace(java.lang.String str,
                                    int startPos)
Searches the given string for the first occurrence of a whitespace character. If the given start position is less than zero or greater than the stringLength-1 then '-1' is returned.

Parameters:
str - the string to search.
startPos - the position at which to start the search.
Returns:
The first position at which a whitespace character was found, or '-1' if none was found.

indexOfWhitespace

public static int indexOfWhitespace(java.lang.String str)
Searches the given string for the first occurrence of a whitespace character.

Parameters:
str - the string to search.
Returns:
The first position at which a whitespace character was found, or '-1' if none was found.

iteratorToEnum

public static java.util.Enumeration iteratorToEnum(java.util.Iterator it)
Converts the iterator to an enumeration.

Parameters:
it - the iterator.
Returns:
an enumeration.

enumToIterator

public static java.util.Iterator enumToIterator(java.util.Enumeration e)
Converts the enumeration to an iterator.

Parameters:
e - the enumeration.
Returns:
an iterator.

enumToListString

public static java.lang.String enumToListString(java.util.Enumeration e)
Returns a string representation of the data elements referenced by the given enumeration. The returned string will have a comma and space between each element.

Parameters:
e - the enumeration of data objects to use.
Returns:
The list string.

enumToString

public static java.lang.String enumToString(java.util.Enumeration e)
Returns a string representation of the data elements referenced by the given enumeration. The returned string will have leading and trailing brackets ("{}") and a comma and space between each element.

Parameters:
e - the enumeration of data objects to use.
Returns:
The string data.

enumToQuotedStrings

public static java.lang.String enumToQuotedStrings(java.util.Enumeration enumObj,
                                                   java.lang.String sepStr,
                                                   boolean quoteCharsFlag)
Returns a String of substrings gathered from the given enumeration. Each substring is generated via each enumerated object's 'toString()' method, will be surrounded by double-quotes ("") and will be separated by the given separator string.

Parameters:
enumObj - the given enumeration.
sepStr - the string that separates the substrings.
quoteCharsFlag - if true then special characters, such as double-quote and control characters, will be "quoted" in the substrings using the backslash character (\r \n \t \\ \").
Returns:
A string of substrings, or an empty string if no substrings could be generated (will not return null).

enumToQuotedStrings

public static java.lang.String enumToQuotedStrings(java.util.Enumeration enumObj,
                                                   char sepChar,
                                                   boolean quoteCharsFlag)
Returns a String of substrings gathered from the given enumeration. Each substring is generated via each enumerated object's 'toString()' method, will be surrounded by double-quotes ("") and will be separated by the given separator character.

Parameters:
enumObj - the given enumeration.
sepChar - the character that separates the substrings.
quoteCharsFlag - if true then special characters, such as double-quote and control characters, will be "quoted" in the substrings using the backslash character (\r \n \t \\ \").
Returns:
A string of substrings, or an empty string if no substrings could be generated (will not return null).

enumToQuotedStrings

public static java.lang.String enumToQuotedStrings(java.util.Enumeration enumObj)
Returns a String of substrings gathered from the given enumeration. Each substring is generated via each enumerated object's 'toString()' method, will be surrounded by double-quotes ("") and will be separated by a comma. Special characters, such as double-quote and control characters, will be "quoted" in the substrings using the backslash character (\r \n \t \\ \").

Parameters:
enumObj - the given enumeration.
Returns:
A string of substrings, or an empty string if no substrings could be generated (will not return null).

listObjToListStr

public static java.lang.String listObjToListStr(java.util.List listObj,
                                                java.lang.String sepStr)
Returns a String of substrings gathered from the given list. Each substring is generated via each entry's 'toString()' method and will be separated by the given separator string.

Parameters:
listObj - source list of entries.
sepStr - separator string value.
Returns:
A string of substrings, or an empty string if no substrings could be generated (will not return null).

quotedStringsToVector

public static java.util.Vector quotedStringsToVector(java.lang.String str,
                                                     char sepChar,
                                                     boolean strictFlag)
Returns a Vector of substrings from the given string. Each substring is surrounded by double-quotes ("") and separated by the given separator character. Special characters, such as double-quote and control characters, may be "quoted" in the substrings using the backslash character (i.e. \").

Parameters:
str - the source string.
sepChar - the character that separates the substrings.
strictFlag - if true then the string format is strictly interpreted--no extraneous spaces are allowed and every substring must be surrounded by double-quotes.
Returns:
A Vector of strings, or null if the proper string format was not found.

quotedStringsToVector

public static java.util.Vector quotedStringsToVector(java.lang.String str,
                                                     char sepChar)
Returns a Vector of substrings from the given string. Each substring is surrounded by double-quotes ("") and separated by the given separator character. Special characters, such as double-quote and control characters, may be "quoted" in the substrings using the backslash character (i.e. \"). The string format is strictly interpreted--no extraneous spaces are allowed and every substring must be surrounded by double-quotes.

Parameters:
str - the source string.
sepChar - the character that separates the substrings.
Returns:
A Vector of strings, or null if the proper string format was not found.

quotedStringsToVector

public static java.util.Vector quotedStringsToVector(java.lang.String str)
Returns a Vector of substrings from the given string. Each substring is surrounded by double-quotes ("") and separated by commas (,). Special characters, such as double-quote and control characters, may be "quoted" in the substrings using the backslash character (i.e. \"). The string format is strictly interpreted-- no extraneous spaces are allowed and every substring must be surrounded by double-quotes.

Parameters:
str - the source string.
Returns:
A Vector of strings, or null if the proper string format was not found.

quotedStringsToVector

public static java.util.Vector quotedStringsToVector(java.lang.String str,
                                                     java.lang.String sepCharsStr,
                                                     boolean strictFlag)
Returns a Vector of substrings from the given string. Each substring is surrounded by double-quotes ("") and separated by one of the the given separator characters. Special characters, such as double-quote and control characters, may be "quoted" in the substrings using the backslash character (i.e. \").

Parameters:
str - the source string.
sepCharsStr - a string of separator characters that may be used to separate the substrings, or null for " ,;".
strictFlag - if true then the string format is strictly interpreted--no extraneous spaces are allowed and every substring must be surrounded by double-quotes.
Returns:
A Vector of strings, or null if the proper string format was not found.

listStringToVector

public static java.util.Vector listStringToVector(java.lang.String str)
Returns a Vector of substrings from the given list string. The substrings are expected to be separated by a ',' separator character and may be surrounded by quotes (which are removed, and special characters, such as double-quote and control characters, may be "quoted" in the substrings using the backslash character [i.e. \"]).

Parameters:
str - the source string.
Returns:
A Vector of strings, or an empty Vector if no data was found in the given list string.

listStringToVector

public static java.util.Vector listStringToVector(java.lang.String str,
                                                  char sepChar,
                                                  boolean trimFlag)
Returns a Vector of substrings from the given list string. The substrings are expected to be separated by the given separator character and may be surrounded by quotes (which are removed, and special characters, such as double-quote and control characters, may be "quoted" in the substrings using the backslash character [i.e. \"]).

Parameters:
str - the source string.
sepChar - the character that separates the substrings.
trimFlag - if true then all leading and trailing spaces in substrings is trimmed.
Returns:
A Vector of strings, or an empty Vector if no data was found in the given list string.

moveListElement

public static boolean moveListElement(java.util.List listObj,
                                      int index,
                                      java.lang.Object element)
Moves the specified element to the specified position in the specified list if it already present, otherwise it adds it at the position. Each component in the list with an index greater or equal to the specified index is shifted upward to have an index one greater than the value it had previously.

If the index is out of range the element is moved to the end of the list.

Parameters:
listObj - the list object.
index - index at which the specified element is to be inserted.
element - element to be inserted.
Returns:
true if the list changed as a result of the call.
Throws:
java.lang.UnsupportedOperationException - if the add method is not supported by the list.
java.lang.ClassCastException - if the class of the specified element prevents it from being added to the list.
java.lang.IllegalArgumentException - if some aspect of this element prevents it from being added to the list.

getTableContentsString

public static java.lang.String getTableContentsString(java.util.Map tableObj,
                                                      java.lang.String sepStr)
Creates a string of "key" = "value" items from the given table/map.

Parameters:
tableObj - the table/map object to use.
sepStr - separator to put between items.
Returns:
A string of "key" = "value" items from the given table/map.

getTableContentsString

public static java.lang.String getTableContentsString(java.util.Map tableObj)
Creates a string of "key" = "value" items from the given table/map, with ", " separating the items.

Parameters:
tableObj - the table/map object to use.
Returns:
A string of "key" = "value" items from the given table/map.

removeEmptyStrings

public static java.util.Vector removeEmptyStrings(java.util.Vector vec)
Removes items from the given Vector that are empty string or null.

Parameters:
vec - the given Vector.
Returns:
The given Vector.

fixStringLen

public static java.lang.String fixStringLen(java.lang.String inString,
                                            int outLen,
                                            boolean rightJustFlag,
                                            boolean truncateFlag)
Returns the given string "fixed" to the desired length, (possibly) truncating or adding spaces as necessary.

Parameters:
inString - the given string.
outLen - the desired length of the output string.
rightJustFlag - true for right-justified (spaces inserted before the given string data); false for left-justified (spaces added after the given string data).
truncateFlag - if true and the given string is longer than the desired length then it is truncated to generate the returned string; if false then the string data is never truncated.
Returns:
A String object with the given length.

fixStringLen

public static java.lang.String fixStringLen(java.lang.String inString,
                                            int outLen,
                                            boolean rightJustFlag)
Returns the given string "fixed" to the desired length, truncating or adding spaces as necessary.

Parameters:
inString - the given string.
outLen - the desired length of the output string.
rightJustFlag - true for right-justified (spaces inserted before the given string data); false for left-justified (spaces added after the given string data).
Returns:
A String object with the given length.

fixStringLen

public static java.lang.String fixStringLen(java.lang.String inString,
                                            int outLen)
Returns the given string "fixed" to the desired length, truncating or adding spaces as necessary. If spaces are added, the returned string is left-justified (spaces added after the given string data).

Parameters:
inString - the given string.
outLen - the desired length of the output string.
Returns:
A String object with the given length.

getSpacerString

public static java.lang.String getSpacerString(int numSpaces)
Returns a string containing the given number of space characters. This method is thread safe.

Parameters:
numSpaces - the desired number of space characters.
Returns:
A string containing the desired number of space characters.

createCenteredString

public static java.lang.String createCenteredString(java.lang.String inString,
                                                    int fieldLen)
Returns a "centered" version of the given string. Leading spaces are added to "center" the string into the given field length.

Parameters:
inString - the given string.
fieldLen - the field length for centering.
Returns:
A "centered" version of the given string, or the given string itself if it is not shorter than the field length.

softWordWrapString

public static java.lang.String softWordWrapString(java.lang.String srcStr,
                                                  int lineWidth,
                                                  java.lang.String indentStr,
                                                  java.lang.String newLineStr,
                                                  java.lang.String sepCharsStr)
Performs a "soft" word-wrap of the given data. If a line has to be shortened more than 20% of the given line-width value then it is allowed to go beyond the given line-width value.

Parameters:
srcStr - data string to use.
lineWidth - target line-width value.
indentStr - indentation to be put in front of generated lines (after the first one), or null for none.
newLineStr - string to use for generate line-ends.
sepCharsStr - string of characters to be interpreted as word separators, or null to use any character <= the space character.
Returns:
A new string containing the word-wrapped data.

softWordWrapString

public static java.lang.String softWordWrapString(java.lang.String srcStr,
                                                  int lineWidth,
                                                  java.lang.String indentStr,
                                                  java.lang.String newLineStr)
Performs a "soft" word-wrap of the given data. If a line has to be shortened more than 20% of the given line-width value then it is allowed to go beyond the given line-width value.

Parameters:
srcStr - data string to use.
lineWidth - target line-width value.
indentStr - indentation to be put in front of generated lines (after the first one), or null for none.
newLineStr - string to use for generate line-ends.
Returns:
A new string containing the word-wrapped data.

softWordWrapString

public static java.lang.String softWordWrapString(java.lang.String srcStr,
                                                  int lineWidth,
                                                  java.lang.String indentStr)
Performs a "soft" word-wrap of the given data. If a line has to be shortened more than 20% of the given line-width value then it is allowed to go beyond the given line-width value.

Parameters:
srcStr - data string to use.
lineWidth - target line-width value.
indentStr - indentation to be put in front of generated lines (after the first one), or null for none.
Returns:
A new string containing the word-wrapped data.

trimEndStr

public static java.lang.String trimEndStr(java.lang.String str)
Trims whitespace at the end of the given string.

Parameters:
str - string to use.
Returns:
The given string with its trailing whitespace trimmed, or the string itself if no trailing whitespace was found.

trimMultiLineString

public static java.lang.String trimMultiLineString(java.lang.String inString,
                                                   java.lang.String newLineStr,
                                                   int centerFieldLen)
Trims leading and trailing whitespace from each line inside of the given string (while retaining the line separations). This can be useful when processing multi-line text that has been read from an XML element. If 'centerFieldLen' is greater than zero then leading spaces are added to "center" the lines into the given field length.

Parameters:
inString - the given string.
newLineStr - the newline separator to be used between lines in the returned string.
centerFieldLen - the field length for centering, or 0 for no centering.
Returns:
The trimmed multi-line string.

trimMultiLineString

public static java.lang.String trimMultiLineString(java.lang.String inString,
                                                   java.lang.String newLineStr)
Trims leading and trailing whitespace from each line inside of the given string (while retaining the line separations). This can be useful when processing multi-line text that has been read from an XML element.

Parameters:
inString - the given string.
newLineStr - the newline separator to be used between lines in the returned string.
Returns:
The trimmed multi-line string.

trimMultiLineString

public static java.lang.String trimMultiLineString(java.lang.String inString,
                                                   int centerFieldLen)
Trims leading and trailing whitespace from each line inside of the given string (while retaining the line separations). This can be useful when processing multi-line text that has been read from an XML element. If 'centerFieldLen' is greater than zero then leading spaces are added to "center" the lines into the given field length. The lines in the returned string will be separated via the newline ('\n') character.

Parameters:
inString - the given string.
centerFieldLen - the field length for centering, or 0 for no centering.
Returns:
The trimmed multi-line string.

trimMultiLineString

public static java.lang.String trimMultiLineString(java.lang.String inString)
Trims leading and trailing whitespace from each line inside of the given string (while retaining the line separations). This can be useful when processing multi-line text that has been read from an XML element. The lines in the returned string will be separated via the newline ('\n') character.

Parameters:
inString - the given string.
Returns:
The trimmed multi-line string.

capFirstLetter

public static java.lang.String capFirstLetter(java.lang.String str)
Returns a new version of the given string that has its first character capitialized (if possible).

Parameters:
str - the string to use.
Returns:
A new String object if the capitialization changed the given string, otherwise the original string.

getPrettyString

public static java.lang.String getPrettyString(java.lang.String str,
                                               boolean allUpperFlag)
Returns a pretty version of the specified string: Replaces periods with spaces. Capatilizes the first letter of the first word. Removes control characters. Removes white space from beginning and end of string. Ensures only a single space between words. Ensures that there is a space before every capital letter if the previous or next letter is lower case.

Parameters:
str - the string.
allUpperFlag - true to have all words start with upper-case, false to have only first word start with upper-case.
Returns:
pretty string.

getPrettyString

public static java.lang.String getPrettyString(java.lang.String str)
Returns a pretty version of the specified string: Capatilizes the first letter of every word. Removes control characters. Removes white space from beginning and end of string. Ensures only a single space between words. Ensures that there is a space before every capital letter if the previous or next letter is lower case.

Parameters:
str - the string.
Returns:
pretty string.

charToString

public static java.lang.String charToString(char ch)
Returns a string containing the given single character. This method can be useful because "Character.toString()" is only available on Java 1.4 and later.

Parameters:
ch - the character to use.
Returns:
A new String object containing the given single character.

getLocalHostAddrObj

public static java.net.InetAddress getLocalHostAddrObj(boolean preferIP4Flag,
                                                       java.lang.StringBuffer addrInfoBuff)
Returns an Internet-address object for the local host. If multiple IPs are available, then an Internet-address object with a "valid" Internet IP address will be returned in favor of one corresponding to an "invalid" Internet IP address (such as "192.168...").

Parameters:
preferIP4Flag - true to give preference to "valid" IPv4 addresses over "valid" IPv6 addresses.
addrInfoBuff - string buffer to be appended with informational text on the host addresses that were found.
Returns:
A new 'InetAddress' object, or null if one could not be created.

getLocalHostAddrObj

public static java.net.InetAddress getLocalHostAddrObj(boolean preferIP4Flag)
Returns an Internet-address object for the local host. If multiple IPs are available, then an Internet-address object with a "valid" Internet IP address will be returned in favor of one corresponding to an "invalid" Internet IP address (such as "192.168...").

Parameters:
preferIP4Flag - true to give preference to "valid" IPv4 addresses over "valid" IPv6 addresses.
Returns:
A new 'InetAddress' object, or null if one could not be created.

getLocalHostAddrObj

public static java.net.InetAddress getLocalHostAddrObj()
Returns an Internet-address object for the local host. If multiple IPs are available, then an Internet-address object with a "valid" Internet IP address will be returned in favor of one corresponding to an "invalid" Internet IP address (such as "192.168...").

Returns:
A new 'InetAddress' object, or null if one could not be created.

getLocalHostIP

public static java.lang.String getLocalHostIP()
Returns the local host IP. If multiple IPs are available, then an IP corresponding to a "valid" Internet IP address will be returned in favor of one corresponding to an "invalid" Internet IP address (such as "192.168..."). If no host IP can be found then an empty string is returned.

Returns:
A string containing the local host IP, or an empty string.

getLocalHostIP

public static java.lang.String getLocalHostIP(java.net.InetAddress addrObj)
Returns the host IP address for the given address object. If no host IP can be found then an empty string is returned.

Parameters:
addrObj - Internet-address object.
Returns:
A string containing the local host IP, or an empty string.
See Also:
getLocalHostAddrObj

getLocalHostName

public static java.lang.String getLocalHostName()
Returns the local host name.

Returns:
A string containing the local host name, or an empty string if the host name could not be determined.

getLocalHostName

public static java.lang.String getLocalHostName(java.net.InetAddress addrObj)
Returns the local host name.

Parameters:
addrObj - the Internet-address object.
Returns:
A string containing the local host name, or an empty string if the host name could not be determined.
See Also:
getLocalHostAddrObj

setURLReference

public static java.net.URL setURLReference(java.net.URL urlObj,
                                           java.lang.String refStr)
Creates a new URL containing the given reference (anchor) string. If the URL already contains a reference then it is replaced.

Parameters:
urlObj - the URL object to use.
refStr - the reference (anchor) string to use, or null to specify no reference.
Returns:
A new URL object containing the given reference, or the original URL object if it already contained the given reference.

isURLAddress

public static boolean isURLAddress(java.lang.String str)
Returns true if the contents of the given string qualify as a valid URL address; otherwise returns false. If the string begins with 1 to 10 letters (or digits) followed by "://" then it is considered a valid URL address.

Parameters:
str - the string to check.
Returns:
true if the contents of the given string qualify as a valid URL address; otherwise false.

isIPAddress

public static boolean isIPAddress(java.lang.String str)
Returns true if the contents of the given string qualify as a valid IP address (in the from #.#.#.#); otherwise returns false.

Parameters:
str - the string to check.
Returns:
true if the contents of the given string qualify as a valid IP address; otherwise false.

isFakeIPAddress

public static boolean isFakeIPAddress(java.lang.String str)
Returns true if the given string contains a "fake" IP address (one that cannot be used as a "real" Internet address). The address is considered "fake" if it begins with one of the following: "192.168.", "172.16.", "10.","255.", "127.0.0.", "0.0.0.0", "fe8", "fec", "fed", "fee", "fef", "2001:", "2002:" or "0:0:0:0:0:0:".

Parameters:
str - the string to check.
Returns:
true if the given string contains a "fake" IP address; otherwise false.

replaceSubstring

public static java.lang.String replaceSubstring(java.lang.String dataStr,
                                                java.lang.String oldStr,
                                                java.lang.String newStr)
Replace the first occurrence of a given substring with a new substring.

Parameters:
dataStr - the data string to be used.
oldStr - the "old" substring to be replaced.
newStr - the "new" substring to be entered.
Returns:
A new String containing the "new" substring, or the original String if no occurrences of the "old" substring were found.

replaceAllSubstrings

public static java.lang.String replaceAllSubstrings(java.lang.String dataStr,
                                                    java.lang.String oldStr,
                                                    java.lang.String newStr)
Replace all of the occurrences of a given substring with a new substring.

Parameters:
dataStr - the data string to be used.
oldStr - the "old" substring to be replaced.
newStr - the "new" substring to be entered.
Returns:
A new String containing the "new" substring, or the original String if no occurrences of the "old" substring were found.

normalizeString

public static java.lang.String normalizeString(java.lang.String str)
Returns a new string with all surrounding whitespace removed and internal whitespace normalized to a single space. If only whitespace exists, an empty string is returned.

Parameters:
str - the string to be normalized.
Returns:
A new, normalized-version of the string if whitespace was found and removed; the original string if no whitespace was found; or an empty string if no non-whitespace data was found.

removeSpecifiedChars

public static java.lang.String removeSpecifiedChars(java.lang.String str,
                                                    java.lang.String keepCharsStr)
Returns a new string with all characters not matching the given keep-characters string removed.

Parameters:
str - string to be processed.
keepCharsStr - string of "keep" characters to be matched.
Returns:
A new version of the string if characters were removed, or the original string if no characters were removed.

removeNonAlphanumChars

public static java.lang.String removeNonAlphanumChars(java.lang.String str)
Returns a new string with all non-alphnumeric characters removed.

Parameters:
str - string to be processed.
Returns:
A new version of the string if characters were removed, or the original string if no characters were removed.

parseSeparatedSubstrsToList

public static java.util.ArrayList parseSeparatedSubstrsToList(java.lang.String dataStr,
                                                              java.lang.String sepStr)
Parses a string of substrings using the given separator.

Parameters:
dataStr - the data string to parse.
sepStr - the separator string (if null or an empty string then "." is used).
Returns:
A list containing the substrings found, or an empty list if the given string contained no data.

parseSeparatedSubstrsToList

public static java.util.ArrayList parseSeparatedSubstrsToList(java.lang.String dataStr,
                                                              java.lang.String sepStr,
                                                              char quoteChar,
                                                              boolean trimFlag,
                                                              boolean removeQuotesFlag)
Parses a string of substrings using the given separator. A quote character may be specified to allow a single substring to contain separator characters, such as: "one.two three"

Parameters:
dataStr - the data string to parse.
sepStr - the separator string (if null or an empty string then "." is used).
quoteChar - a quote character (i.e., '"') to be used at the beginning and end of a substring, or a null ('\0') character for none.
trimFlag - if true then leading and trailing whitespace will be removed from the parsed substrings.
removeQuotesFlag - if true then quote characters surrounding substrings will be removed.
Returns:
An list containing the substrings found, or an empty list if the given string contained no data.

parseSeparatedSubstrsToList

public static java.util.ArrayList parseSeparatedSubstrsToList(java.lang.String dataStr,
                                                              java.lang.String sepStr,
                                                              char quoteChar,
                                                              boolean trimFlag)
Parses a string of substrings using the given separator. A quote character may be specified to allow a single substring to contain separator characters, such as: "one.two three" The surrounding quote characters will be removed.

Parameters:
dataStr - the data string to parse.
sepStr - the separator string (if null or an empty string then "." is used).
quoteChar - a quote character (i.e., '"') to be used at the beginning and end of a substring, or a null ('\0') character for none.
trimFlag - if true then leading and trailing whitespace will be removed from the parsed substrings.
Returns:
An list containing the substrings found, or an empty list if the given string contained no data.

parseSeparatedSubstrings

public static java.lang.String[] parseSeparatedSubstrings(java.lang.String dataStr,
                                                          java.lang.String sepStr)
Parses a string of substrings using the given separator.

Parameters:
dataStr - the data string to parse.
sepStr - the separator string (if null or an empty string then "." is used).
Returns:
An array containing the substrings found, or an empty array if the given string contained no data.

parseSeparatedSubstrings

public static java.lang.String[] parseSeparatedSubstrings(java.lang.String dataStr,
                                                          java.lang.String sepStr,
                                                          char quoteChar,
                                                          boolean trimFlag,
                                                          boolean removeQuotesFlag)
Parses a string of substrings using the given separator. A quote character may be specified to allow a single substring to contain separator characters, such as: "one.two three" The surrounding quote characters will be removed.

Parameters:
dataStr - the data string to parse.
sepStr - the separator string (if null or an empty string then "." is used).
quoteChar - a quote character (i.e., '"') to be used at the beginning and end of a substring, or a null ('\0') character for none.
trimFlag - if true then leading and trailing whitespace will be removed from the parsed substrings.
removeQuotesFlag - if true then quote characters surrounding substrings will be removed.
Returns:
An array containing the substrings found, or an empty array if the given string contained no data.

parseSeparatedSubstrings

public static java.lang.String[] parseSeparatedSubstrings(java.lang.String dataStr,
                                                          java.lang.String sepStr,
                                                          char quoteChar,
                                                          boolean trimFlag)
Parses a string of substrings using the given separator. A quote character may be specified to allow a single substring to contain separator characters, such as: "one.two three" The surrounding quote characters will be removed.

Parameters:
dataStr - the data string to parse.
sepStr - the separator string (if null or an empty string then "." is used).
quoteChar - a quote character (i.e., '"') to be used at the beginning and end of a substring, or a null ('\0') character for none.
trimFlag - if true then leading and trailing whitespace will be removed from the parsed substrings.
Returns:
An array containing the substrings found, or an empty array if the given string contained no data.

parseLeadingInt

public static int parseLeadingInt(java.lang.String numStr)
                           throws java.lang.NumberFormatException
Parses the leading digits of string as an integer while ignoring any trailing non-digit characters. Any leading whitespace is trimmed before the string is parsed.

Parameters:
numStr - the string to parse.
Returns:
The parsed integer value.
Throws:
java.lang.NumberFormatException - if no valid numeric data is found.

parseVersionNumbers

public static java.lang.Integer[] parseVersionNumbers(java.lang.String verStr)
Parses a version string into integer values. The version number values are expected to be separated by periods ('.'). Any non-numeric characters trailing a version number are ignored.

Parameters:
verStr - the version string to be parsed.
Returns:
An array of Integer objects, with each entry containing a version number value or null if no number value was found. If no version number values are found then an empty array is returned.

compareVersionStrings

public static int compareVersionStrings(java.lang.String ver1Str,
                                        java.lang.String ver2Str)
Compares two version strings containing version number values separated by periods ('.'). Any non-numeric characters trailing a version number are ignored.

Parameters:
ver1Str - the first version string.
ver2Str - the second version string.
Returns:
The value 1, 0, or -1 as the first version string is greater than, equal to or less than the second.

getStackTraceString

public static java.lang.String getStackTraceString(java.lang.Throwable throwObj)
Fetches stack trace data from a throwable and returns it in a string.

Parameters:
throwObj - the throwable object to use.
Returns:
A string containing the stack trace data.

getMemoryInfoStr

public static java.lang.String getMemoryInfoStr()
Returns a string of memory information.

Returns:
A string of memory information in the form "total=#, free=#, diff=#", with each value in bytes.

getRootThreadGroupObj

public static java.lang.ThreadGroup getRootThreadGroupObj()
Returns the root ThreadGroup object.

Returns:
The root ThreadGroup object, or null if an error occurred.

getTotalThreadCount

public static int getTotalThreadCount()
Returns a count of the total number of threads in the JVM.

Returns:
A count of the total number of threads in the JVM, or 0 if an error occurred.

beep

public static void beep()
Emits an audio beep.


isValidFileNameChar

public static boolean isValidFileNameChar(char ch)
Determines if the character is valid for a filename.

Parameters:
ch - the character to check.
Returns:
true if valid, false otherwise.

stringToFileName

public static java.lang.String stringToFileName(java.lang.String str)
Converts the given string to a string that is safe to use as a file name.

Parameters:
str - the string to be converted.
Returns:
The given string if it is safe to use as a file name; otherwise returns a converted version that is safe.

fileNameToString

public static java.lang.String fileNameToString(java.lang.String fNameStr)
Converts a file-name string that was encoded via 'stringToFileName()' back to its original form.

Parameters:
fNameStr - file-name string to use.
Returns:
The given string if no conversion occured; otherwise returns the converted version.

stringArrayToString

public static java.lang.String stringArrayToString(java.lang.String[] strArr,
                                                   java.lang.String sepStr)
Converts an array of strings to a single string containing all the strings in the array.

Parameters:
strArr - source array of strings.
sepStr - separator string to use between source strings, or null or none.
Returns:
A single string containing all the strings in the given array.

stringArrayToString

public static java.lang.String stringArrayToString(java.lang.String[] strArr)
Converts an array of strings to a single string containing all the strings in the array (each separated by a space).

Parameters:
strArr - source array of strings.
Returns:
A single string containing all the strings in the given array.

toGlobalLogFileWarn

public static void toGlobalLogFileWarn(java.lang.String msgStr)
Sends the given message to the "global" log file object. This method references 'LogFile' via reflection to avoid a compile-time class dependency on that object. The equivalent call is: LogFile.getGlobalLogObj(true).warning(msgStr)

Parameters:
msgStr - message string to send out.

toList

public static java.util.List toList(java.lang.Object[] a)
Get a fixed-size list backed by the specified array. (Changes to the returned list "write through" to the array.)

Parameters:
a - the array by which the list will be backed or null if none.
Returns:
a list view of the specified array or null if none.

toString

public static java.lang.String toString(java.lang.Object obj)
Get the string representation of the Object argument using the default separator string.

Parameters:
obj - an Object.
Returns:
if the argument is null, then a string equal to "null"; otherwise, the value of obj.toString() is returned.
See Also:
toString(Object, String, String, Collection)

toString

public static java.lang.String toString(java.lang.Object obj,
                                        java.lang.String nullStr)
Get the string representation of the Object argument without a separator string.

Parameters:
obj - an Object.
nullStr - the null string
Returns:
if the argument is null, then nullStr; otherwise, the value of obj.toString() is returned.

toString

public static java.lang.String toString(java.lang.Object obj,
                                        java.lang.String nullStr,
                                        java.lang.String sepStr)
Get the string representation of the Object argument using the specified separator string.

Parameters:
obj - an Object.
nullStr - the null string
sepStr - separator string value.
Returns:
if the argument is null, then nullStr; otherwise, the value of obj.toString() is returned.
See Also:
toString(Object, String, String, Collection)

toString

public static java.lang.String toString(java.lang.Object obj,
                                        java.lang.String nullStr,
                                        java.lang.String sepStr,
                                        java.util.Collection all)
Get the string representation of the Object argument using the specified separator string.

Parameters:
obj - an Object.
nullStr - the null string
sepStr - separator string value.
all - a collection of all values for deep contents or null if none.
Returns:
if the argument is null, then nullStr; otherwise, the value of obj.toString() is returned.
See Also:
#DEFAULT_NULL_TEXT, StringConstants.DEFAULT_SEP_STR

endsWith

public static boolean endsWith(java.lang.String str,
                               java.lang.String suffix,
                               boolean ignoreCase)
Check if a string ends with a specified suffix (optionally case insensitive).

Parameters:
str - the string to check or null.
suffix - the suffix to find or null.
ignoreCase - indicates whether the compare should ignore case (case insensitive) or not.
Returns:
true if the string ends with the suffix or both null
See Also:
String.endsWith(String)

endsWithIgnoreCase

public static boolean endsWithIgnoreCase(java.lang.String str,
                                         java.lang.String suffix)
Case insensitive check if a string ends with a specified prefix.

nulls are handled without exceptions. Two null references are considered to be equal. The comparison is case insensitive.

Parameters:
str - the string to check or null.
suffix - the suffix to find or null.
Returns:
true if the string ends with the suffix, case insensitive, or both null
See Also:
String.endsWith(String)

isBlank

public static boolean isBlank(java.lang.String str)
Checks if a string is blank (trimmed to "" or null).

Parameters:
str - the string to check or null.
Returns:
true if the string is blank (trimmed to "" or null).

isEmpty

public static boolean isEmpty(java.lang.String str)
Checks if a string is empty ("" or null).

Parameters:
str - the string to check or null.
Returns:
true if the string is empty ("" or null).

startsWith

public static boolean startsWith(java.lang.String str,
                                 java.lang.String prefix,
                                 boolean ignoreCase)
Check if a string starts with a specified prefix (optionally case insensitive).

Parameters:
str - the string to check or null.
prefix - the prefix to find or null.
ignoreCase - indicates whether the compare should ignore case (case insensitive) or not.
Returns:
true if the string starts with the prefix or both null
See Also:
String.startsWith(String)

startsWithIgnoreCase

public static boolean startsWithIgnoreCase(java.lang.String str,
                                           java.lang.String prefix)
Case insensitive check if a string starts with a specified prefix.

nulls are handled without exceptions. Two null references are considered to be equal. The comparison is case insensitive.

Parameters:
str - the string to check or null.
prefix - the prefix to find or null.
Returns:
true if the string starts with the prefix, case insensitive, or both null
See Also:
String.startsWith(String)