Class Library: Utility Objects

Util. Includes various parsing and other utility routines useful to many of EarthStones' classes.

package earthstones
import java.applet.*;
java.util.*;
class declaration public abstract class Util extends Object
class constants public static final String days[] = {"Sun", "Mon", "Tue", "Wed", "Thu" ,"Fri", "Sat"};
public static final String months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
public static final String hexDigits[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"};
static methods The first two methods parse a string of the form
key=val1, val2, val3...
public static String getKey(String line) Returns key.
public static Vector getValues(String line) Returns a vector with val1... as its elements.
The next two methods pad the string str with one or more instances of string pad for a total length of len.
public static String padStart(String str, String pad, int len)
public static String padEnd(String str, String pad, int len)
The next four methods convert back and forth between integer and hex digit string values.
public static String intToHexDigitString(int i)
public static String intToHexString(int i)
public static int hexDigitStringtoInt(String s)
public static int hexStringToInt(String str)
public static boolean isEven(int num) Returns true if num is an even integer.
The next two methods parse a string val of the form #XXYYZZ where XX, YY, ZZ are hexadecimal values and return the corresponding color.
public static Color getColor(String val, String where This form permits specification of the string where to indicate where the getColor() method was called (e.g., "file Site.web"). This parameter is used in generating an error message printed to the Java console when the specified color cannot be set.
public static Color getColor(String val) Calls getColor(val, "HTML tag");
The next two method trim any leading/trailing occurrences of thisStr from inStr.
public static String trimLeading(String inStr, String thisStr)
public static String trimTrailing(String inStr, String thisStr)
The following two methods return the word in String inStr occurring prior to/following the String before starting from position startingWith, with or without any intervening white space.
public static String previousWord(String inStr, String before, int startingWith)
public static String nextWord(String inStr, String after, int startingWith)
The next three methods return the "words" in an arbitrary string separated by an some separator string.
public static Vector words(String str, String sep, boolean trimLeadingBlanks, boolean trimTrailingBlanks) Sets separator string to the parameter sep. If trimLeadingTrailingBlanks parameters are set, trims leanding/trailing blanks from the strings returned. Note: Html.getTagTail() uses the form
words(tag, ">", false, false) to make sure that meaningful blank characters are not lost.
public static Vector words(String str, String sep) Calls words(str, sep, true, true).
public static Vector words(String str) Calls words(str, " ", true, true).
public static String nextString(String inStr, int startingWith) Returns the next quote-("") delimited string starting with the specified index. If none is found, tries looking for a single-quote ('') delimited string. If none is found return the string up to the first space character. If that fails, return what's left.
public static String replace(String inStr, String thisStr, String withThis) Replaces all occurrences of thisStr in String inStr with the String withThis.
public static boolean isBlank(String str) Returns true of str is null, is equal to "", or contains only one or more blank (" ") characters.
The next three methods evaluate or manipulate path strings.
public static boolean isFullPath(String path) Returns true if string path represents a fully qualified URL:
1) Returns true if isWebPath(path) is true.
2)Otherwise,
2a) Returns true if path begins with "X:" where X is a single character A-Z (i.e., this is a DOS drive specification).
2b) Otherwise, returns false.
public static boolean isWebPath(String path) Returns true if path string begins with one of the following Internet protocol specifications: "http:", "ftp:", "file:", or "mailto:".
public static String stripHttpServer(String href) Strips http://myServer/ from URL string http://myServer/myPath/myFile.htm,
returning myPath/myFile.htm.
The following methods provide various date functions.
public static Date date(String date) Returns a Date object corresponding to the string date of the form mm/dd/yyyy.
public static Date datePlusDays(String date, int more) Returns a Date object corresponding to the string date of the form mm/dd/yyyy + more days.
public static Date datePlusDays(Date date, int more) Returns a Date object corresponding to date + more days.
public static String shortDate(Date dt) Returns a string representing the Date object dt as a string of the form mm/dd/yyyy.
public static String shortDate() Returns a string representing current date as a string of the form mm/dd/yyyy.
public static synchronized String longDate(Date dt) Returns a string representing the Date object dt as a string of the form day mon dd yyyy hh:mm ap (e.g., Thu Mar 26 1998 07:47 PM).
public static String longDate() Returns a string representing the current date as a string of the form day mon dd yyyy hh:mm ap (e.g., Thu Mar 26 1998 07:47 PM).