com.waveset.util
Class Util

java.lang.Object
  extended by com.waveset.util.Util

public class Util
extends java.lang.Object

A bag of utilities.


Nested Class Summary
static class Util.StringComparator
          Internal class that implenents the Comparator interface for sorting the rows in the table.
static class Util.TimePeriod
          Used to represent a time period, such as number of days, weeks or months, relative to an arbitrary day.
static class Util.TimeUnit
          Used by the TimePeriod class to indicate the unit of the period counter.
 
Field Summary
static java.lang.String code_id
           
static java.lang.String DATE_FORMAT_AM_PM
           
static java.lang.String DATE_FORMAT_COMPACT
          Year-month-day with twenty-four-hour time: "yyyyMMdd HH:mm:ss"
static java.lang.String DATE_FORMAT_DEFAULT
           
static java.lang.String DATE_FORMAT_MILLIS
          Timestamp in milliseconds (a stringified Java long value).
static java.lang.String DATE_FORMAT_NO_SPACE
           
static java.lang.String DATE_FORMAT_STRING
           
static int INTERVAL_UNIT_HOURS
           
static int INTERVAL_UNIT_MILLISECONDS
           
static int INTERVAL_UNIT_MINUTES
           
static int INTERVAL_UNIT_SECONDS
           
static java.util.List stockDateTimePatterns
           
static java.util.TimeZone TIME_ZONE_CANONICAL
           
 
Constructor Summary
Util()
           
 
Method Summary
static void addElement(java.util.List list, int index, java.lang.Object o)
          Add an element to an array list at the given position, growing the array if necessary to avoid exceptions.
static java.lang.String[] addString(java.lang.String[] list, java.lang.String newString)
          Return a new string array with the string added.
static java.util.List addToken(java.util.List list, java.lang.String token, boolean trim, java.lang.String valWrapper, boolean unpack)
           
static long appendFile(java.lang.String name, java.lang.String contents)
          Append to a file.
static long appendFile(java.lang.String name, java.lang.String contents, long maxLength)
          See appendFile, below.
static java.lang.String[] appendString(java.lang.String[] list, java.lang.String newString)
          Similar to addString but just appends the string to end of the list (no sorting, no check for duplicates, no guard against null values).
static boolean arrayEquals(java.lang.Object[] arr1, java.lang.Object[] arr2)
          Tests whether two arrays are equal.
static java.lang.String arrayToString(boolean[] array)
           
static java.lang.String arrayToString(byte[] array)
           
static java.lang.String arrayToString(double[] array)
           
static java.lang.String arrayToString(int[] array)
           
static java.lang.String arrayToString(long[] array)
           
static java.lang.String arrayToString(java.lang.Object[] array)
           
static double atod(java.lang.String a)
          Convert a String value into a primitive double value.
static double atod(java.lang.String a, double def)
          Convert a String value into a primitive double value.
static float atof(java.lang.String a)
          Convert a String value into a primitive float value.
static float atof(java.lang.String a, float def)
          Convert a String value into a primitive float value.
static int atoi(java.lang.String a)
          Convert a String value into a primitive integer value.
static int atoi(java.lang.String a, int def)
          Convert a String value into a primitive integer value.
static long atol(java.lang.String a)
          Convert a String value into a primitive integer value.
static long atol(java.lang.String a, long def)
          Convert a String value into a primitive long value.
static java.lang.String btoa(boolean b)
          Convert a primitive boolean value to a string.
static java.net.URL buildFTPURL(java.lang.String host, java.lang.String port, java.lang.String path, java.lang.String user, com.waveset.util.EncryptedData password, java.lang.String type)
           
static char[] byteToChar(byte[] inbytes)
          Converts a byte array to a char array.
static char[] byteToChar(byte[] inb, java.lang.String enc)
          Converts a byte array to character array.
static byte[] charToByte(char[] inchars)
          Converts a char array to a byte array.
static byte[] charToByte(char[] carray, java.lang.String enc)
          Converts a char array to a byte array.
static java.lang.String checkDirectory(java.io.File dir, boolean createIfMissing)
           
static long checksum(java.io.File file)
           
static long checksum(java.lang.String fileName)
          Calculates the CRC32 checksum of the specified file.
static java.util.List commaDelimitedStringToList(java.lang.String cds)
           
static java.lang.String compressToString(java.io.Serializable obj)
          Serializes obj, compresses it using gzip, and then base64 encodes it so that it can be cleanly stuck in XML.
static void confirmDirectory(java.io.File dir)
          Make sure the directory exists and is writable.
static void confirmDirectory(java.io.File dir, boolean createIfMissing)
          Make sure the directory exists (or can be created) and is writable.
static boolean contains(java.lang.Object[] objs, java.lang.Object obj)
           
static boolean containsAny(java.util.Collection containing, java.util.Collection query)
          Returns true if containing collection contains any of the items in the query collection.
static java.lang.String convertToJSName(java.lang.String in)
           
static java.util.ArrayList convertValuesToStringList(java.lang.Object value)
           
static java.lang.String convertValueToString(java.lang.Object value)
           
static boolean copyFile(java.io.File src, java.io.File dest)
          Copies a file to a destintation.
static int copyFile(java.io.InputStream fis, java.io.OutputStream fos)
          Copies one file to another.
static boolean copyFile(java.io.InputStream fis, java.io.OutputStream fos, int max)
          Copies one file to another up to a specified max.
static int copyFile(java.io.Reader reader, java.io.Writer writer)
          Copies one file to another.
static int copyFile(java.lang.String src, java.lang.String dest)
          Copies one file to another.
static int copyFileByBlockSize(java.io.InputStream fis, java.io.OutputStream fos, int bufferSize)
          Copies one file to another.
static int copyFileByBlockSize(java.io.Reader reader, java.io.Writer writer, int bufferSize)
          Copies one file to another.
static void createJarFile(java.io.File jarFile, java.io.File rootDir, java.util.List files)
          Archive and compress a data file.
static boolean dateAfter(java.util.Date date1, java.util.Date date2)
          Determine if date1 is after date2.
static boolean dateEquals(java.util.Date date1, java.util.Date date2)
          Determine if date1 is the same as date2.
static java.lang.String dateToString()
           
static java.lang.String dateToString(java.util.Date src)
          Format a Date value as a String, using the usual "American" format with the current time zone.
static java.lang.String dateToString(java.util.Date src, java.util.Locale locale)
          Format the given date using the given locale.
static java.lang.String dateToString(java.util.Date date, java.lang.String simpleDateFormatPattern)
           
static java.lang.String dateToString(java.util.Locale locale)
          Format the current date using the given locale.
static java.lang.String dateToString(long timeMillis)
           
static java.lang.String dateToString(long src_millis, java.util.Locale locale)
          Format the given date using the given locale.
static java.lang.String dateToString(long timeMillis, java.lang.String simpleDateFormatPattern)
           
static java.lang.String dateToString(java.lang.String simpleDateFormatPattern)
           
static java.util.List decodeCommaString(java.lang.String src)
          Parse a comma delimited string into a List of strings.
static java.util.List decodeCommaString(java.lang.String src, boolean filterEmpty)
           
static java.util.List decodeNewlineString(java.lang.String data, boolean filterEmpty)
          Given a newline deliminted string, break it up into a List of Strings.
static java.lang.String demangle(java.lang.String mangledName)
          Restore special characters in a filename.
static java.lang.String dtoa(double d)
          Convert a primitive double value into a String.
static java.lang.String dumpBytes(byte[] bytes)
          Prints the provided bytes in a format using hex bytes on the right of the line and ASCII printable chars on the left
static java.lang.String dumpBytes(byte[] bytes, int len)
          Prints the provided bytes in a format using hex bytes on the right of the line and ASCII printable chars on the left
static java.lang.String dumpBytes(byte[] bytes, int start, int len)
          Prints the provided bytes in a format using hex bytes on the right of the line and ASCII printable chars on the left
static void dumpProperties()
          Prints the current system properties to the system output device.
static void dumpProperties(java.io.PrintWriter out)
          Prints the current system properties to a writer object.
static java.lang.String encodeCommaString(java.lang.Object list)
          Convert a list of strings into a comma delimited list.
static java.lang.String encodeCommaString(java.lang.Object list, boolean filterEmpty)
           
static java.lang.String encodeCommaString(java.lang.Object o, boolean filterEmpty, boolean trailingSpace)
          Convert a list of strings to a comma delimited list.
static java.lang.String encodeNewlineString(java.util.List values, boolean filterEmpty)
          Given a List of Strings, convert them into a single String with elements seperated by newlines.
static boolean equals(java.lang.Object o1, java.lang.Object o2)
          Compares the 2 objects, handling nulls
static boolean equalsIgnoreCase(java.lang.Object o1, java.lang.Object o2)
          Compares the 2 objects, handling nulls.
static boolean equalStrings(java.lang.String s1, java.lang.String s2)
          Compares the 2 strings, handling nulls
static java.lang.String escape(java.lang.String src, char escapeThis, char prefixWith)
          Process a string to escape any occurrence of the specified character by prefixing it with the specified escape character.
static java.lang.String escapeCommas(java.lang.String src)
          Process a string to escape any comma (,) character.
static java.lang.String escapeForwardSlashes(java.lang.String src)
          Process a string to escape any forward slash (/) character.
static java.lang.String escapeNewlines(java.lang.String src)
          Process a string to escape newline characters.
static java.lang.String escapePoundSigns(java.lang.String src)
          Process a string to escape any hash mark (#) character.
static java.lang.String escapeSingleQuotes(java.lang.String src)
          Process a string to escape any apostrophe characters.
static void escapeString(java.lang.StringBuffer b, java.lang.String s)
          Render a quoted string with the usual escaping.
static java.lang.String exec(java.lang.String command)
          Execute a "shell" command, returning whatever it emitted to stdout as a string.
static void expandJarFile(java.io.File jarFile, java.io.File rootDir)
          Extract and uncompress all data files from an archive.
static void expandJarFile(java.io.File jarFile, java.io.File rootDir, java.util.List entryNames)
          Extract and uncompress specified data files from an archive.
static void filterStringList(java.util.List list, java.lang.String regexp)
          Remove all of the Strings in list that do not match the regular expression.
static int[] findClassName(java.lang.StringBuffer sb)
          Find something tkat looks like a classname (e.g., "com.waveset.Exception:" ).
static java.util.List findDuplicates(java.util.List list)
           
static java.lang.String findFile(java.lang.String name)
          Attempt to derive the absolute path of a file.
static java.lang.String findFile(java.lang.String property, java.lang.String name)
          Attempt to derive the absolute path of a file.
static java.lang.String findFile(java.lang.String property, java.lang.String name, boolean searchClasspath)
          Attempt to derive the absolute path of a file.
static java.lang.String findIllegals(java.lang.String name, java.lang.String illegals)
           
static java.lang.String findOutputFile(java.lang.String name)
          Build an absolute path name for a file.
static java.lang.String format(double d, int decimalPlaces)
           
static java.lang.String format(java.lang.String s, int decimalPlaces)
           
static java.lang.String formatBytes(long bytes)
           
static java.lang.String formatElapsedTime(long from, long to)
           
static java.lang.String formatMemoryStatistics()
           
static void formatMemoryStatistics(java.lang.StringBuffer sb)
           
static java.lang.String formatTimeInterval(long millis)
           
static java.lang.String formatTimeInterval(long millis, int maxUnit, int granularity)
           
static java.lang.String ftoa(float f)
          Convert an primitive float value into a String.
static java.lang.String generateGUID()
           
static java.lang.String generateUniqueTaskName(java.lang.String taskName, Subject taskSubject, java.util.Date date)
           
static java.io.File getApplicationDataDirectory()
          Returns an os-specific application data directory for Identity Manager.
static java.lang.String getApplicationHome()
          Returns the value of the WSHOME environment variable.
static java.util.HashMap getAttributeMap(java.lang.String attrString)
          This routine will take a string of comma delimeted name value pairs and place them in a hashmap.
static java.lang.String getBaseName(java.lang.Class c)
           
static java.lang.String getBaseName(java.lang.String className)
           
static boolean getBoolean(java.lang.Object value)
          Coerce an Object to a boolean value.
static boolean getBoolean(java.lang.Object value, boolean dflt)
          Coerce an Object to a boolean value.
static java.lang.String getCanonicalDateString(java.util.Date date)
           
static java.lang.String getCanonicalDateString(java.util.Date date, java.util.TimeZone timeZone)
           
static java.lang.String getCanonicalDateString(long timestamp)
           
static java.lang.String getCanonicalDateStringOnly(java.util.Date date)
           
static java.lang.String getCanonicalTimeStringOnly(java.util.Date date)
           
static java.lang.Class getClass(boolean b)
           
static java.lang.Class getClass(int i)
           
static java.lang.Class getClass(long l)
           
static java.lang.Class getClass(java.lang.Object o)
           
static java.lang.String getClassNameFromFilePath(java.lang.String path)
          Take a path name of a file and return the corresponding class name (e.g.
static java.lang.String getClassNameFromZipPath(java.lang.String path)
          Take a path name of a file from a zip (jar) file and return the corresponding class name (e.g.
static java.lang.String getClasspathDirectory(int idx)
          Return the nth item on the CLASSPATH.
static java.util.List getClasspathList()
          Return a list of the items that are in the classpath.
static java.lang.String getCodeId(java.lang.Class c)
          Get the code id from the class.
static java.lang.String getCodeId(java.lang.String c)
          Get the code id from the class specified by the string.
static java.util.Date getDecrementedDate(java.lang.String numLogin)
           
static java.lang.String getDefaultEncoding()
           
static java.lang.String getenv(java.lang.String name)
          Return the value of an environment variable.
static java.lang.String getFileName(java.lang.String filePath)
           
static java.io.File getFontsDir()
          Returns the path to the WEB-INF/fonts directory.
static java.io.InputStream getInputStreamFromJar(java.lang.String jarfilename, java.lang.String entryName)
          Return an input stream for an entry in a jar file.
static int getInt(java.lang.Object v)
          Coerce an Object into an int primitive.
static java.util.jar.JarFile getLighthouseJar()
          Searches the classpath for idm.jar.
static java.lang.String getLocalizedString(java.util.Locale locale, java.lang.Object value)
           
static long getLong(java.lang.Object v)
          Coerce an Object value into a long primitive.
static java.lang.String getMachineUser()
          Get the name of the user that is logged in to the host machine.
static long getMaxMemory()
           
static long getMaxMemory(boolean force)
           
static java.util.Date getRelativeDate(int field, int amount)
          Generates a data string expressed as a number of units from now such as "5 minutes from now"
static java.util.Date getRelativeDate(int ord, int day, int mo)
          Generates a date string expressed in a future time such as "the second Monday in October".
static java.util.Date getRelativeDate(Util.TimePeriod period)
          Calculates a Date representing the current time plus the the amount of time represented by the TimePeriod.
static java.net.URL getResource(java.lang.String name)
           
static java.io.File getResourceFile(java.net.URL resoUrl)
           
static java.io.File getResourceFile(java.net.URL resoUrl, boolean mustExist)
           
static java.io.File getResourceFileIfFile(java.net.URL resoUrl)
           
static java.lang.String getResourcePath(java.lang.String name)
          Attempts to determine the absolute pathname of a resource file.
static java.lang.String getResourcePath(java.net.URL res)
           
static java.io.File getSavedObjectsDir()
          Returns the path to the savedObjects directory.
static java.lang.String getServerId()
          Return the "server id".
static java.lang.String getStringFromJar(java.lang.String jarfilename, java.lang.String entryName)
          Return the contents of an entry in a jar file as a string.
static long getUsedMemory()
           
static long getUsedMemory(boolean force)
           
static java.lang.String getVersionFromCodeId(java.lang.String codeid)
          Get the version number from the CVS code id.
static java.net.URL getWavesetConfigURL()
          Get a URL that points to our config directory, should be a file URL that points to lighthouse/config.
static java.lang.String getWavesetHome()
           
static java.lang.String getWavesetHomePathIfFile()
          Convenience method.
static java.net.URL getWavesetHomeURL()
           
static java.net.URL getWavesetHomeURL(boolean ignoreAnyCached)
           
static java.net.URL getWavesetResource(java.lang.String name)
           
static java.io.File getWavesetResourceFile(java.lang.String name)
          Convenience method: equivalent to calling getWavesetResource(); and getResourceFile();.
static java.lang.String getWavesetResourcePath(java.lang.String name)
          Convenience method: equivalent to calling getWavesetResource(); and getResourcePath();.
static byte[] gzipCompress(byte[] inbytes)
           
static byte[] gzipDecompress(byte[] inBytes)
          Decompress an array of bytes, if possible.
static byte[] gzipDecompress(byte[] inbytes, int size)
           
static java.lang.Integer hashCode(java.lang.Object o)
           
static java.util.HashMap hashtableToMap(java.util.Hashtable hash)
          Convert a Hashtable into a HashMap.
static java.lang.String ignoreCase(java.lang.String s)
           
static int indexOf(java.lang.Object[] objs, java.lang.Object obj)
           
static boolean isASCIILetter(char in)
          Walk the string, converting any non-alpha or numeric char to an underscore.
static boolean isASCIILetterOrDigit(char in)
           
static boolean isNumeric(java.lang.String s)
           
static boolean isWindows()
          Are we running in windows?
static java.lang.String itoa(int i)
          Convert an primitive integer value into a String.
static java.lang.String legalizeResourceName(java.lang.String resoName)
           
static int length(byte[] array)
           
static int length(char[] array)
           
static int length(int[] array)
           
static int length(long[] array)
           
static int length(java.lang.Object[] array)
           
static int length(java.lang.String psz)
           
static int length(java.lang.StringBuffer sb)
           
static int lengthInUTF8(java.lang.String psz)
           
static java.util.List listAllFilenames(java.io.File dir, boolean relativeNames)
          List all of the filenames (not including directory names) in the specified directory and its subdirectories.
static java.util.List listClasses()
          List all of the classes in the classpath.
static java.util.List listClassesInDirectory(java.io.File dir)
          List all of the classes found in the specified directory or its subdirectories.
static java.util.List listClassesInZipFile(java.io.File file)
          List all of the classes in the specified zip (jar) file.
static java.util.List listClassNamesMatching(java.lang.String baseName)
           
static java.lang.String listToCommaDelimitedString(java.util.List list)
           
static java.lang.String listToString(java.util.List list, java.lang.String delim)
           
static java.lang.String listToString(java.util.List list, java.lang.String delim, int maxLen)
           
static java.lang.String listToString(java.util.List list, java.lang.String delim, int maxLen, java.lang.String valWrapper)
           
static java.lang.String lpad(java.lang.String str, int length)
          Left-pad a string to the specified length.
static java.lang.String lpad(java.lang.String str, int length, char padChar)
          Left-pad a string to the specified length with the specified character.
static java.lang.String ltoa(long l)
          Convert a primitive long value into a String.
static void main(java.lang.String[] args)
           
static java.util.List makeList(java.lang.Object[] array)
          Make a List out of an array.
static java.lang.String mangle(java.lang.String name)
          Replace special characters in a name or id so that it will be a valid filename.
static java.lang.String mapName(java.util.Locale locale, java.lang.String prefix, java.lang.String name)
          Given a name, try to map it using the catalog.
static java.lang.String mapToString(java.util.Map map)
           
static java.lang.String mapToString(java.util.Map map, java.lang.String separator)
           
static boolean matchSimpleWildcard(java.lang.String in, java.lang.String matchString)
          Very simple string matching, allows matchString to end in a * and match another string com.waveset.* matches com.waveset.util.Util.matchSimpleWildcard
static java.lang.String midString(java.lang.StringBuffer in, char delim, int start, int count)
          Given a string like aaa,bbb,ccc,ddd and a delim of ",", return a string containing the items between start and (start + count).
static java.lang.String normalizeString(java.lang.String str)
          Normalization of the string will be done using an implementation of RFC2253 which specifies the standard for the string representation of distinguished names handling issue such as capitalization, component ordering, special characters, internationalized characters, trimming leading and trailing spaces, etc.
static java.lang.String pad(java.lang.String s, int len, char pad, boolean leftPad)
           
static boolean pathIsAbsolute(java.lang.String path)
           
static boolean pathIsRelative(java.lang.String path)
           
static void print(java.lang.Object o)
           
static void println()
          Ubiquitous macro
static void println(java.lang.Object o)
           
static void printStackTrace()
          Debugging aid that dumps the current stack trace to the console.
static void putJarEntries(java.lang.String jarFileName, java.util.List entryNames, boolean jarMustExist, boolean overwriteEntry, boolean updateExistingJar)
          Archive and compress a data file.
static void putJarEntry(java.lang.String jarFileName, java.lang.String jarEntryName, boolean jarMustExist, boolean overwriteEntry)
          Archive and compress a data file.
static java.lang.String readFile(java.io.File file)
          Read the contents of a file and return it as a String.
static java.lang.String readFile(java.lang.String name)
          Read the contents of a file and return it as a String.
static byte[] readFileBytes(java.io.File file)
          Read the contents of a file and return it as a byte array.
static byte[] readFileBytes(java.lang.String name)
          Read the content of a file and return it as a byte array.
static java.lang.String readFileUtf8(java.io.File filename)
           
static java.lang.String readFileUtf8(java.io.InputStream in)
           
static java.lang.String readFileUtf8(java.lang.String filename)
           
static java.lang.String readInputStream(java.io.InputStream in)
          Read the contents of an input stream and return it as a String.
static byte[] readInputStreamBytes(java.io.InputStream is, boolean close)
           
static java.lang.String readResource(java.net.URL resoUrl)
           
static byte[] readURLBytes(java.net.URL url)
          Read the content of a URL.
static byte[] readURLBytesIfExists(java.net.URL url)
          Read the contents of a URL if there is something there.
static java.lang.String readWavesetResource(java.lang.String name)
          Convenience method: equivalent to calling getWavesetResource(); and readResource();.
static void removeDuplicates(java.util.List list)
          Remove the duplicates from a list, returning the duplicate-free list.
static void removeNulls(java.util.List list)
          Remove null elements from a list.
static boolean renameFileForBackup(java.io.File file)
          Renames the file using the following format: .backup.yyyyMMdd_HHmmss.
static boolean renameFileForBackup(java.lang.String path)
          Renames the file using the following format: .backup.yyyyMMdd_HHmmss.
static java.lang.String replaceChar(java.lang.String s, java.lang.String replaceMe, java.lang.String replaceWith)
          Replace all occurances of replaceMe with replaceWith
static java.lang.String replaceString(java.lang.String in, java.lang.String fromString, java.lang.String toString)
           
static boolean resourceExists(java.net.URL resoUrl)
           
static double roundTo(double d, int decimalPlaces)
           
static int roundToInt(double d)
           
static java.lang.String rpad(java.lang.String str, int length)
          Right-pad a string buffer to the specified length.
static java.lang.String rpad(java.lang.String str, int length, char padChar)
          Right-pad a string buffer to the specified length with the specified character.
static java.lang.String setWavesetHome(java.lang.String newValue)
          Set the application docroot.
static int size(java.util.Collection collection)
           
static int size(java.util.Map map)
           
static java.util.List sortList(java.util.List list)
          Sort a list
static java.lang.StringBuffer sprintf(java.lang.String format, java.lang.String[] args)
          A marginally functional attempt to provide "sprintf" in Java.
static java.lang.String stackToHtml(java.lang.Throwable th)
          Converts the stack trace of an exception to an HTML string
static java.lang.String stackToHtmlComment(java.lang.Throwable th)
          Converts the stack trace of an exception to an HTML string Bug #10499 If 'ui.web.disableStackTraceComments' property in waveset.properties is 'true' this returns an empty string.
static java.lang.String stackToString(java.lang.Throwable th)
          Converts the stack trace of an exception to a String
static java.lang.String[] stringToArray(java.lang.String s)
          Inverse of arrayToString (except that we cannot convert back to Object).
static java.util.Date stringToDate(java.lang.String src)
          Convert the string representation for a date into a Date object.
static java.util.Date stringToDate(java.lang.String src, java.lang.String format)
           
static java.util.Date stringToDate(java.lang.String src, java.lang.String format, java.lang.String timeZone)
           
static java.util.Date stringToDate(java.lang.String src, java.lang.String format, java.lang.String timeZone, java.util.Locale locale)
           
static java.lang.String stringToHtmlComment(java.lang.String s)
          Converts the stack trace of an exception to an HTML string
static java.util.List stringToList(java.lang.String s, java.lang.String delim)
           
static java.util.List stringToList(java.lang.String s, java.lang.String delim, boolean trim)
           
static java.util.List stringToList(java.lang.String s, java.lang.String delim, boolean trim, java.lang.String valWrapper)
           
static java.util.List stringToList(java.lang.String s, java.lang.String delim, boolean trim, java.lang.String valWrapper, java.lang.String escChar, boolean unpack)
           
static java.lang.String strip(java.lang.Throwable th)
           
static java.lang.String stripClassName(java.lang.String in)
          Strip the classname off of the front of an error if it really looks like a classpath - and it looks like there is a real error out there.
static int strlen(java.lang.String inString)
          Returns the length of the specified string.
static java.lang.String strstr(java.lang.String inString, java.lang.String delimiter)
          Returns the last token in a string of tokens separated by the specified delimiter.
static java.lang.String timestampConvert(java.lang.String dText, java.lang.String tText, java.util.List formats, java.lang.String iTimezone, java.lang.String oMask, java.lang.String oTimezone)
           
static java.lang.String timestampConvert(java.lang.String dText, java.lang.String tText, java.lang.String iTimezone, java.lang.String oMask, java.lang.String oTimezone)
           
static java.lang.String topStackFrames(int num)
           
static java.lang.String toString(boolean b)
           
static java.lang.String toString(char c)
           
static java.lang.String toString(int i)
           
static java.lang.String toString(long l)
           
static java.lang.String toString(java.lang.Object o)
           
static byte[] toUpperByteArray(byte[] barray)
          Coverts all bytes to upper case.
static byte[] toUpperByteArray(byte[] barray, java.lang.String enc)
          Coverts all bytes to upper case.
static char[] toUpperCharArray(char[] carray)
          Converts all lower case characters to upper case.
static java.lang.String trimWhitespace(java.lang.String src)
          Trims trailing whitespace from a string.
static java.lang.String truncateAt(java.lang.String in, java.lang.String delim, int count)
          Given a string like aaa,bbb,ccc,ddd and a delim of ",", return a string containing the first count items.
static java.lang.String truncateEncodedString(java.lang.String psz, java.lang.String encoding, int maxbytes)
          Truncate string in encoding space, returning longest string that will fit in a byte buffer of the given size after it has been encoded.
static java.io.Serializable uncompressFromString(java.lang.String str)
          Called to retrieve the object passed into compressToString
static java.lang.String URLDecode(java.lang.String s)
          Process a string to decode all characters using the com.waveset.util.URLUTF8Decoder.decode method
static java.lang.String URLEncode(java.lang.String s)
          Process a string to encode all characters using the com.waveset.util.URLUTF8Encoder.encode method
static boolean wavesetResourceExists(java.lang.String name)
          Convenience method: equivalent to calling getWavesetResource(); and resourceExists();.
static void writeFile(java.io.File file, java.lang.String contents)
          Store the contents of a String in a file.
static void writeFile(java.lang.String name, byte[] contents)
          Store the contents of a String in a file.
static void writeFile(java.lang.String name, java.lang.String contents)
          Store the contents of a String in a file.
static void writeFileUtf8(java.lang.String name, java.lang.String contents)
           
static void writeResource(java.net.URL resoUrl, java.lang.String content)
          Replace the content of the specified URL with a String if that URL is a file.
static void writeWavesetResource(java.lang.String name, java.lang.String content)
          Convenience method: equivalent to calling getWavesetResource(); and writeResource();.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

code_id

public static final java.lang.String code_id
See Also:
Constant Field Values

DATE_FORMAT_AM_PM

public static final java.lang.String DATE_FORMAT_AM_PM
See Also:
Constant Field Values

DATE_FORMAT_COMPACT

public static final java.lang.String DATE_FORMAT_COMPACT
Year-month-day with twenty-four-hour time: "yyyyMMdd HH:mm:ss"

See Also:
Constant Field Values

DATE_FORMAT_DEFAULT

public static final java.lang.String DATE_FORMAT_DEFAULT
See Also:
Constant Field Values

DATE_FORMAT_MILLIS

public static final java.lang.String DATE_FORMAT_MILLIS
Timestamp in milliseconds (a stringified Java long value).

See Also:
Constant Field Values

DATE_FORMAT_NO_SPACE

public static final java.lang.String DATE_FORMAT_NO_SPACE
See Also:
Constant Field Values

DATE_FORMAT_STRING

public static final java.lang.String DATE_FORMAT_STRING
See Also:
Date.toString(), Constant Field Values

INTERVAL_UNIT_HOURS

public static final int INTERVAL_UNIT_HOURS
See Also:
Constant Field Values

INTERVAL_UNIT_MILLISECONDS

public static final int INTERVAL_UNIT_MILLISECONDS
See Also:
Constant Field Values

INTERVAL_UNIT_MINUTES

public static final int INTERVAL_UNIT_MINUTES
See Also:
Constant Field Values

INTERVAL_UNIT_SECONDS

public static final int INTERVAL_UNIT_SECONDS
See Also:
Constant Field Values

stockDateTimePatterns

public static final java.util.List stockDateTimePatterns

TIME_ZONE_CANONICAL

public static java.util.TimeZone TIME_ZONE_CANONICAL
Constructor Detail

Util

public Util()
Method Detail

addElement

public static void addElement(java.util.List list,
                              int index,
                              java.lang.Object o)
Add an element to an array list at the given position, growing the array if necessary to avoid exceptions.

This can be used to build "sparse" arrays, or to allow for the population of array elements in random order, something that can potentially happen when using XML to build lists.

Parameters:
list - List to which to append
index - Position to insert the element
o - Object representing the element to insert

addString

public static java.lang.String[] addString(java.lang.String[] list,
                                           java.lang.String newString)
Return a new string array with the string added. Do the right thing for null list and/or null newString


addToken

public static java.util.List addToken(java.util.List list,
                                      java.lang.String token,
                                      boolean trim,
                                      java.lang.String valWrapper,
                                      boolean unpack)

appendFile

public static long appendFile(java.lang.String name,
                              java.lang.String contents)
                       throws com.waveset.util.IOException
Append to a file.

Parameters:
name - - file name to log to. Created if des not exist
contents - - string to write out
Returns:
total length of the file (for trimming, if needed). 0 if no data written
Throws:
com.waveset.util.IOException - on error

appendFile

public static long appendFile(java.lang.String name,
                              java.lang.String contents,
                              long maxLength)
                       throws com.waveset.util.WavesetException,
                              com.waveset.util.IOException
See appendFile, below. This just truncates the file at a requested length if it grows too large.

Parameters:
name - identifies destination file
contents - String to write to file
maxLength - maximum length of file, at which point the file is truncated
Returns:
length of file after writing contents
Throws:
com.waveset.util.WavesetException - on error
com.waveset.util.IOException - - not currently thrown

appendString

public static java.lang.String[] appendString(java.lang.String[] list,
                                              java.lang.String newString)
Similar to addString but just appends the string to end of the list (no sorting, no check for duplicates, no guard against null values).


arrayEquals

public static boolean arrayEquals(java.lang.Object[] arr1,
                                  java.lang.Object[] arr2)
Tests whether two arrays are equal.

Parameters:
arr1 - first array of Objects
arr2 - second array of Objects
Returns:
true if equal, false otherwise

arrayToString

public static java.lang.String arrayToString(boolean[] array)

arrayToString

public static java.lang.String arrayToString(byte[] array)

arrayToString

public static java.lang.String arrayToString(double[] array)

arrayToString

public static java.lang.String arrayToString(int[] array)

arrayToString

public static java.lang.String arrayToString(long[] array)

arrayToString

public static java.lang.String arrayToString(java.lang.Object[] array)

atod

public static double atod(java.lang.String a)
Convert a String value into a primitive double value. Tolerate null strings, and invalid integer strings and return 0.

Parameters:
a - string representation of a double value
Returns:
double

atod

public static double atod(java.lang.String a,
                          double def)
Convert a String value into a primitive double value. If the string is invalid, returns the specified default.

Parameters:
a - string representation of a double value
def - default value, in the event of a parsing error
Returns:
double

atof

public static float atof(java.lang.String a)
Convert a String value into a primitive float value. Tolerate null strings, and invalid integer strings and return 0.

Parameters:
a - String representation of a floating point number
Returns:
floating point number

atof

public static float atof(java.lang.String a,
                         float def)
Convert a String value into a primitive float value. If the string is invalid, the value of the "def" argument is returned.

Parameters:
a - String representation of a floating point number
def - default value, in case there is a parsing error
Returns:
floating point number

atoi

public static int atoi(java.lang.String a)
Convert a String value into a primitive integer value. Tolerate null strings, and invalid integer strings and return 0.

Parameters:
a - String representation of an integer
Returns:
integer value

atoi

public static int atoi(java.lang.String a,
                       int def)
Convert a String value into a primitive integer value. If the string is invalid, the value of the "def" argument is returned.

Parameters:
a - String representation of an integer
def - default value
Returns:
integer value

atol

public static long atol(java.lang.String a)
Convert a String value into a primitive integer value. Tolerate null strings, and invalid integer strings and return 0.

Parameters:
a - string representation of a long integer
Returns:
long representation of a

atol

public static long atol(java.lang.String a,
                        long def)
Convert a String value into a primitive long value. If the string is invalid, returns the specified default.

Parameters:
a - string representation of a long
def - default value to use if there's a problem parsing the string
Returns:
long representation of the string value, or def if there was a problem

btoa

public static java.lang.String btoa(boolean b)
Convert a primitive boolean value to a string.

Parameters:
b - boolean
Returns:
String representation of b

buildFTPURL

public static java.net.URL buildFTPURL(java.lang.String host,
                                       java.lang.String port,
                                       java.lang.String path,
                                       java.lang.String user,
                                       com.waveset.util.EncryptedData password,
                                       java.lang.String type)
                                throws com.waveset.util.WavesetException,
                                       java.net.MalformedURLException
Parameters:
host - - The name of the host to connect to. Cannot be empty or null.
port - - The optional port to connect to.
path - - The optional path to the object to retrieve. '/' characters are not encoded.
user - - The optional name of a user to login as.
password - - The encrypted password to use when logging in as a specific user.
type - - The optional single character indicating the type of data to get: "a" - ascii, * "i" - binary, or "d" - directory. Note: The code underneath java.net.URL that supports ftp doesn't seem to support the ";type=t" URL syntax, so you will need to pass in "null" for the type.
Returns:
a URL that looks like this: ftp://user:password@host:port/path;type=t. Any special characters in the individual URL components (e.g. user) will be encoded appropriately.
Throws:
com.waveset.util.WavesetException - on error
java.net.MalformedURLException - on error

Using java.net.URL doesn't work very well when downloading a text file that is in EBCDIC. It doesn't seem to support the ";type=t" syntax. The default when downloading from a mainframe seems to be binary which does not include any newline characters.


byteToChar

public static char[] byteToChar(byte[] inbytes)
Converts a byte array to a char array.

Note: This method is not safe for internationalization since it will use the default encoding of the machine it is running on.

Parameters:
inbytes - Byte array of input if this is null the return will be null.
Returns:
Returns a character array encoded in the default encoding of the machine its running on.

byteToChar

public static char[] byteToChar(byte[] inb,
                                java.lang.String enc)
Converts a byte array to character array.

Parameters:
inb - Byte array of input if this is null the return will null.
enc - Encoding to use while decoding the bytes.
Returns:
Returns a character array.

charToByte

public static byte[] charToByte(char[] inchars)
Converts a char array to a byte array.

Note: This method is not safe for internationalization since it will use the default encoding of the machine it is running on.

Parameters:
inchars - Character array of input if this is null the return will be null.
Returns:
Returns a byte array decoded in the default encoding of the machine its running on.

charToByte

public static byte[] charToByte(char[] carray,
                                java.lang.String enc)
Converts a char array to a byte array.

Parameters:
carray - Character array of input if this is null the return will be null.
enc - character encoding
Returns:
Returns a byte array decoded in the default encoding of the machine its running on.

checkDirectory

public static java.lang.String checkDirectory(java.io.File dir,
                                              boolean createIfMissing)
Returns:
null if the directory exists (or can be created) and is writable. If not, return a message describing the problem.

checksum

public static long checksum(java.io.File file)
                     throws java.io.IOException,
                            java.io.FileNotFoundException
Throws:
java.io.IOException
java.io.FileNotFoundException

checksum

public static long checksum(java.lang.String fileName)
                     throws java.io.IOException,
                            java.io.FileNotFoundException
Calculates the CRC32 checksum of the specified file.

Parameters:
fileName - - the path to the file on which to calculate the checksum
Returns:
checksum for the file
Throws:
java.io.IOException - on error
java.io.FileNotFoundException - - not currently thrown

commaDelimitedStringToList

public static java.util.List commaDelimitedStringToList(java.lang.String cds)
Parameters:
cds - - a string of tokens separated by commas.

Will not return any token that contains only white space.

Returns:
a List of comma-delimited string tokens.

compressToString

public static java.lang.String compressToString(java.io.Serializable obj)
Serializes obj, compresses it using gzip, and then base64 encodes it so that it can be cleanly stuck in XML. This should only be used if the object will compress well and profiling has shown that it's necessary. Call uncompressFromString to get the object back.


confirmDirectory

public static void confirmDirectory(java.io.File dir)
                             throws com.waveset.util.ConfigurationError
Make sure the directory exists and is writable.

Throws:
com.waveset.util.ConfigurationError

confirmDirectory

public static void confirmDirectory(java.io.File dir,
                                    boolean createIfMissing)
                             throws com.waveset.util.ConfigurationError
Make sure the directory exists (or can be created) and is writable.

Throws:
com.waveset.util.ConfigurationError

contains

public static boolean contains(java.lang.Object[] objs,
                               java.lang.Object obj)

containsAny

public static boolean containsAny(java.util.Collection containing,
                                  java.util.Collection query)
Returns true if containing collection contains any of the items in the query collection. Note: List's can not specify a Comparator so the contains done herein may not be finding the value if you're expecting if the two objects need special handling (i.e. CaseIgnoreString). rwagner


convertToJSName

public static java.lang.String convertToJSName(java.lang.String in)

convertValuesToStringList

public static java.util.ArrayList convertValuesToStringList(java.lang.Object value)
                                                     throws com.waveset.util.WavesetException
Throws:
com.waveset.util.WavesetException

convertValueToString

public static java.lang.String convertValueToString(java.lang.Object value)
                                             throws com.waveset.util.WavesetException
Throws:
com.waveset.util.WavesetException

copyFile

public static boolean copyFile(java.io.File src,
                               java.io.File dest)
                        throws java.io.IOException
Copies a file to a destintation.

Parameters:
src - The source must be a file
dest - This can be a directory or a file.
Returns:
True if succeded otherwise false.
Throws:
java.io.IOException - on error

copyFile

public static int copyFile(java.io.InputStream fis,
                           java.io.OutputStream fos)
                    throws java.io.IOException
Copies one file to another.

Iterate over a fixed block size.

Parameters:
fis - input stream
fos - output stream
Returns:
total bytes copied.
Throws:
java.io.IOException - on error.

copyFile

public static boolean copyFile(java.io.InputStream fis,
                               java.io.OutputStream fos,
                               int max)
                        throws java.io.IOException
Copies one file to another up to a specified max.

Parameters:
fis - input stream
fos - output stream
max - maximum number of bytes to copy
Returns:
true if the entire input stream was copied before hitting max.
Throws:
java.io.IOException - on error.

copyFile

public static int copyFile(java.io.Reader reader,
                           java.io.Writer writer)
                    throws java.io.IOException
Copies one file to another.

Iterate over a fixed block size.

Parameters:
reader - source
writer - destination
Returns:
total bytes copied.
Throws:
java.io.IOException - on error.

copyFile

public static int copyFile(java.lang.String src,
                           java.lang.String dest)
                    throws com.waveset.util.WavesetException,
                           com.waveset.util.IOException
Copies one file to another.

I'm sort of suprised the JDK doesn't have something to do this. If this were used with large files, we'd want to do iterate over a fixed block size.

Parameters:
src - source file identifier
dest - destination file identifier
Returns:
total bytes copied.
Throws:
com.waveset.util.WavesetException - on error
com.waveset.util.IOException - - not currently thrown

copyFileByBlockSize

public static int copyFileByBlockSize(java.io.InputStream fis,
                                      java.io.OutputStream fos,
                                      int bufferSize)
                               throws java.io.IOException
Copies one file to another.

Iterate over a fixed block size specified by bufferSize.

Parameters:
fis - input stream
fos - output stream
bufferSize - to use
Returns:
total bytes copied.
Throws:
java.io.IOException - on error.

copyFileByBlockSize

public static int copyFileByBlockSize(java.io.Reader reader,
                                      java.io.Writer writer,
                                      int bufferSize)
                               throws java.io.IOException
Copies one file to another.

Iterate over a fixed block size specified by bufferSize

Parameters:
reader - source
writer - destination
bufferSize - desired buffer size for blocks when copying
Returns:
total bytes copied.
Throws:
java.io.IOException - on error.

createJarFile

public static void createJarFile(java.io.File jarFile,
                                 java.io.File rootDir,
                                 java.util.List files)
                          throws com.waveset.util.InvalidArgument,
                                 com.waveset.util.WavesetException
Archive and compress a data file.

Parameters:
jarFile - - target output archive file.
rootDir - - source directory containing the data files.
files - - a list of files to be placed in the jar file.
Throws:
com.waveset.util.InvalidArgument - thrown if one of the listed files is not beneath rootDir.
com.waveset.util.WavesetException

dateAfter

public static boolean dateAfter(java.util.Date date1,
                                java.util.Date date2)
Determine if date1 is after date2. When comparing two dates, this method compares the seconds, minutes, hours, day, month, and year.


dateEquals

public static boolean dateEquals(java.util.Date date1,
                                 java.util.Date date2)
Determine if date1 is the same as date2. This method is required as it only compares the month, day, and year components of a date (found that using the Date after & equals methods relies on a strait compare of the long UTC value of time which for some reason for the same date/time is not always the same)


dateToString

public static java.lang.String dateToString()
Returns:
a string formatting the current date according to the default pattern.

dateToString

public static java.lang.String dateToString(java.util.Date src)
Format a Date value as a String, using the usual "American" format with the current time zone. NOTE: The "American" format doesn't sort worth a damn.


dateToString

public static java.lang.String dateToString(java.util.Date src,
                                            java.util.Locale locale)
Format the given date using the given locale.


dateToString

public static java.lang.String dateToString(java.util.Date date,
                                            java.lang.String simpleDateFormatPattern)
Returns:
a string representing a specified date in the specified format.

dateToString

public static java.lang.String dateToString(java.util.Locale locale)
Format the current date using the given locale.


dateToString

public static java.lang.String dateToString(long timeMillis)
Returns:
a string formatting a specified timestamp according to the default pattern.

dateToString

public static java.lang.String dateToString(long src_millis,
                                            java.util.Locale locale)
Format the given date using the given locale.


dateToString

public static java.lang.String dateToString(long timeMillis,
                                            java.lang.String simpleDateFormatPattern)
Returns:
a string formatting a specified time (in milliseconds) in the specified format (default is yyyyMMdd hh:mm:ss".

dateToString

public static java.lang.String dateToString(java.lang.String simpleDateFormatPattern)
Returns:
a string formatting the current date according to the specified pattern.

decodeCommaString

public static java.util.List decodeCommaString(java.lang.String src)
Parse a comma delimited string into a List of strings.

Parameters:
src - comma separated list of values
Returns:
list of values

decodeCommaString

public static java.util.List decodeCommaString(java.lang.String src,
                                               boolean filterEmpty)

decodeNewlineString

public static java.util.List decodeNewlineString(java.lang.String data,
                                                 boolean filterEmpty)
Given a newline deliminted string, break it up into a List of Strings.

Parameters:
data - newline delimited string
filterEmpty - whether to ignore empty values
Returns:
list of values from the original string, possibly filtered

demangle

public static java.lang.String demangle(java.lang.String mangledName)
Restore special characters in a filename.

Returns:
original item name or id (no longer mangled)
See Also:
mangle(String)

dtoa

public static java.lang.String dtoa(double d)
Convert a primitive double value into a String. This doesn't really save much space, but its the obvious inverse to atod.

Parameters:
d - double
Returns:
string representation of d

dumpBytes

public static java.lang.String dumpBytes(byte[] bytes)
Prints the provided bytes in a format using hex bytes on the right of the line and ASCII printable chars on the left

Parameters:
bytes - the bytes to print
Returns:
a string with the formatted output

dumpBytes

public static java.lang.String dumpBytes(byte[] bytes,
                                         int len)
Prints the provided bytes in a format using hex bytes on the right of the line and ASCII printable chars on the left

Parameters:
bytes - the bytes to print
len - the number of bytes in the array to print
Returns:
a string with the formatted output

dumpBytes

public static java.lang.String dumpBytes(byte[] bytes,
                                         int start,
                                         int len)
Prints the provided bytes in a format using hex bytes on the right of the line and ASCII printable chars on the left

Parameters:
bytes - the bytes to print
start - the index in the array to start printing
len - the number of bytes in the array to print
Returns:
a string with the formatted output

dumpProperties

public static void dumpProperties()
Prints the current system properties to the system output device.


dumpProperties

public static void dumpProperties(java.io.PrintWriter out)
Prints the current system properties to a writer object.


encodeCommaString

public static java.lang.String encodeCommaString(java.lang.Object list)
Convert a list of strings into a comma delimited list.

Parameters:
list - List of elements to convert to a string
Returns:
comma delimited string of list's elements

encodeCommaString

public static java.lang.String encodeCommaString(java.lang.Object list,
                                                 boolean filterEmpty)

encodeCommaString

public static java.lang.String encodeCommaString(java.lang.Object o,
                                                 boolean filterEmpty,
                                                 boolean trailingSpace)
Convert a list of strings to a comma delimited list. If the filterEmpty flag is on we will remove any null elements in the list. If the "trailingSpace" flag is on we will add a space after the comma. Originally we always added a trailing space, but this broke some of the adapters that wanted to get CSV's without spaces. Rather than completely remove the space its now an option in case there is other code that likes the look of the space.

Parameters:
o - list of strings
filterEmpty - remove null elements when true
trailingSpace - provide trailing space when true
Returns:
comma delimited string of values in o

encodeNewlineString

public static java.lang.String encodeNewlineString(java.util.List values,
                                                   boolean filterEmpty)
Given a List of Strings, convert them into a single String with elements seperated by newlines.

Parameters:
values - List of values to encode
filterEmpty - whether to remove null values
Returns:
newline delimited string of values

equals

public static boolean equals(java.lang.Object o1,
                             java.lang.Object o2)
Compares the 2 objects, handling nulls

Parameters:
o1 - object
o2 - object
Returns:
true if o1 equals o2; otherwise false.

equalsIgnoreCase

public static boolean equalsIgnoreCase(java.lang.Object o1,
                                       java.lang.Object o2)
Compares the 2 objects, handling nulls. String comparsion is case-insensitive, but only when both objects are instances of String.

Parameters:
o1 - 1st object to be compared.
o2 - 2nd object to be compared.
Returns:
true if o1 equals o2; otherwise false.

equalStrings

public static boolean equalStrings(java.lang.String s1,
                                   java.lang.String s2)
Compares the 2 strings, handling nulls

Parameters:
s1 - string
s2 - string
Returns:
true if s1 equals s2; otherwise false.

escape

public static java.lang.String escape(java.lang.String src,
                                      char escapeThis,
                                      char prefixWith)
Process a string to escape any occurrence of the specified character by prefixing it with the specified escape character.

Parameters:
src - string to escape
escapeThis - - the target character to escape
prefixWith - - character to insert before each target
Returns:
escaped string

escapeCommas

public static java.lang.String escapeCommas(java.lang.String src)
Process a string to escape any comma (,) character.

Parameters:
src - string to escape
Returns:
string with commas escaped

escapeForwardSlashes

public static java.lang.String escapeForwardSlashes(java.lang.String src)
Process a string to escape any forward slash (/) character.

Parameters:
src - string to escape
Returns:
string with forward slashes escaped.

escapeNewlines

public static java.lang.String escapeNewlines(java.lang.String src)
Process a string to escape newline characters.

Ordinarily done if you want to store a string as a value in a property file, where the newline marks the end of the value.

Parameters:
src - string to escape
Returns:
string with newlines escaped

escapePoundSigns

public static java.lang.String escapePoundSigns(java.lang.String src)
Process a string to escape any hash mark (#) character.

Parameters:
src - string to escape
Returns:
string with pound signs escaped

escapeSingleQuotes

public static java.lang.String escapeSingleQuotes(java.lang.String src)
Process a string to escape any apostrophe characters.

Ordinarily done if you want to store a string as a value in a relational database, where single-quotes delimit each value.

Parameters:
src - string to escape
Returns:
string with single quotes escaped

escapeString

public static void escapeString(java.lang.StringBuffer b,
                                java.lang.String s)
Render a quoted string with the usual escaping. Need to do more.

Parameters:
b - stringbuffer to which to append escaped version of s
s - string to escape

exec

public static java.lang.String exec(java.lang.String command)
                             throws com.waveset.util.WavesetException
Execute a "shell" command, returning whatever it emitted to stdout as a string. Written to support Util.getenv, but may have other uses.

Parameters:
command - Shell command to execute.
Returns:
output of the command
Throws:
com.waveset.util.WavesetException - on IOError, wrapping the underlying exception.

expandJarFile

public static void expandJarFile(java.io.File jarFile,
                                 java.io.File rootDir)
                          throws com.waveset.util.InvalidArgument,
                                 com.waveset.util.WavesetException
Extract and uncompress all data files from an archive.

Parameters:
jarFile - - the source archive file.
rootDir - - the target directory beneath which to place the files.
Throws:
com.waveset.util.InvalidArgument
com.waveset.util.WavesetException

expandJarFile

public static void expandJarFile(java.io.File jarFile,
                                 java.io.File rootDir,
                                 java.util.List entryNames)
                          throws com.waveset.util.InvalidArgument,
                                 com.waveset.util.WavesetException
Extract and uncompress specified data files from an archive.

Parameters:
jarFile - - the source archive file.
rootDir - - the target directory beneath which to place the files.
entryNames - - a list of entry names to extract from the jar file. If this list is null, this method will extract all entries.
Throws:
com.waveset.util.InvalidArgument
com.waveset.util.WavesetException

filterStringList

public static void filterStringList(java.util.List list,
                                    java.lang.String regexp)
                             throws java.lang.Exception
Remove all of the Strings in list that do not match the regular expression.

Parameters:
list - list of strings to filter
regexp - regular expression
Throws:
java.lang.Exception - on error

findClassName

public static int[] findClassName(java.lang.StringBuffer sb)
Find something tkat looks like a classname (e.g., "com.waveset.Exception:" ).

It must start with java chars, include at least one period, and end in ": ".

Parameters:
sb - stringbuffer to parse
Returns:
starting and ending index for desired substring if found, null otherwise

findDuplicates

public static java.util.List findDuplicates(java.util.List list)
Parameters:
list - List in which to find duplicated.
Returns:
a list of duplicate entries in a list

findFile

public static java.lang.String findFile(java.lang.String name)
Attempt to derive the absolute path of a file. The "name" argument may be an absolute path or path fragment. If it is an absolute path, it is simply returned. If it is a path fragment, we will use the system property "user.dir" as the root directory and add the path fragment. If a file cannot be found by combining the path fragment with user.dir, the path fragment is passed to getResourcePath which will attempt to find it through the CLASSPATH. If getResourcePath fails, we just return the name argument.


findFile

public static java.lang.String findFile(java.lang.String property,
                                        java.lang.String name)
Attempt to derive the absolute path of a file. The "name" argument may be an absolute path or path fragment. If it is an absolute path, it is simply returned. If it is a path fragment, we will use the system property named in the "property" argument as the root directory, and add the path fragment. If a file cannot be found by combining the path fragment with the system property, the path fragment is passed to getResourcePath which will attempt to find it through the CLASSPATH. If getResourcePath fails, we just return the name argument.


findFile

public static java.lang.String findFile(java.lang.String property,
                                        java.lang.String name,
                                        boolean searchClasspath)
Attempt to derive the absolute path of a file. The "name" argument may be an absolute path or path fragment.

Parameters:
property - - a system property specifying a location to search.
name - - a path or path fragment.
searchClasspath - - if true, we next search the classpath.
Returns:
the absolute path of any file that is found; otherwise
  • if 'name' is an absolute path the fragment passed in as 'name'
  • if 'searchClassPath' is true, the fragment passed in as 'name'
  • if 'searchClassPath' is false, the path relative to 'property'.

If it is an absolute path, it is simply returned.

If it is a path fragment, we will use the system property named in the "property" argument as the root directory, and add the path fragment.

If the argument 'searchClasspath' is true, and a file cannot be found by combining the path fragment with the system property, then the path fragment is passed to getResourcePath, which will attempt to find it through the CLASSPATH. If getResourcePath fails, we just return the name argument.


findIllegals

public static java.lang.String findIllegals(java.lang.String name,
                                            java.lang.String illegals)

findOutputFile

public static java.lang.String findOutputFile(java.lang.String name)
Build an absolute path name for a file. Typically used when you want to write an output file to the "current working directory". If the name is already an absolute path we use it, otherwise we use the system property "user.dir" as the root directory and add the name.


format

public static java.lang.String format(double d,
                                      int decimalPlaces)

format

public static java.lang.String format(java.lang.String s,
                                      int decimalPlaces)
Parameters:
s - string
decimalPlaces - number of decimal places desired
Returns:
a string representing a numerical value padded to the specified number of decimal places.

formatBytes

public static java.lang.String formatBytes(long bytes)

formatElapsedTime

public static java.lang.String formatElapsedTime(long from,
                                                 long to)
Returns:
a beautified string to display elapsed time.

formatMemoryStatistics

public static java.lang.String formatMemoryStatistics()

formatMemoryStatistics

public static void formatMemoryStatistics(java.lang.StringBuffer sb)

formatTimeInterval

public static java.lang.String formatTimeInterval(long millis)
Returns:
a beautified string to display a time interval down to millisecond granularity.

formatTimeInterval

public static java.lang.String formatTimeInterval(long millis,
                                                  int maxUnit,
                                                  int granularity)
Returns:
a beautified string to display a time interval,

ftoa

public static java.lang.String ftoa(float f)
Convert an primitive float value into a String. This doesn't really save much space, but its the obvious inverse to atof.

Parameters:
f - float
Returns:
string representation of f

generateGUID

public static java.lang.String generateGUID()

generateUniqueTaskName

public static java.lang.String generateUniqueTaskName(java.lang.String taskName,
                                                      Subject taskSubject,
                                                      java.util.Date date)

getApplicationDataDirectory

public static java.io.File getApplicationDataDirectory()
Returns an os-specific application data directory for Identity Manager. That is ~/.idmgr on unix systems and Documents And Settings//.idmgr on windows systems.

Returns:
file corresponding to the application data directory

getApplicationHome

public static java.lang.String getApplicationHome()
                                           throws com.waveset.util.WavesetException
Returns the value of the WSHOME environment variable. System.getenv has been deprecated and doesn't appear to work anyway with JDK 1.2. We can fake it by assuming that WSHOME/java is on the CLASSPATH, and we use a ClassLoader to find a known file within that directory. This is however rather unreliable. Modified to do the "right" thing and look for a property that was passed on the java command line. The property we expect is"waveset.home".

Throws:
com.waveset.util.WavesetException

getAttributeMap

public static java.util.HashMap getAttributeMap(java.lang.String attrString)
This routine will take a string of comma delimeted name value pairs and place them in a hashmap.

Parameters:
attrString - string containing comma delimited name,value pairs
Returns:
map of name/value pairs

getBaseName

public static java.lang.String getBaseName(java.lang.Class c)

getBaseName

public static java.lang.String getBaseName(java.lang.String className)

getBoolean

public static boolean getBoolean(java.lang.Object value)
Coerce an Object to a boolean value.

Boolean truth is defined by having a string property value whose first character is one of the following: t, T, y, Y, 1 Any other value, including null, is considered false.

Parameters:
value - value to convert to boolean
Returns:
boolean value - defaults to false

getBoolean

public static boolean getBoolean(java.lang.Object value,
                                 boolean dflt)
Coerce an Object to a boolean value. If the specified object is null, the supplied default value is used.

Boolean truth is defined as having a string value whose first character is one of the following: t, T, y, Y, 1. Any other value is considered false.

Parameters:
value - value to convert to boolean
dflt - default value if conversion isn't possible
Returns:
boolean value

getCanonicalDateString

public static java.lang.String getCanonicalDateString(java.util.Date date)
Returns:
An IS0-8601 formatted date string

getCanonicalDateString

public static java.lang.String getCanonicalDateString(java.util.Date date,
                                                      java.util.TimeZone timeZone)
Returns:
An IS0-8601 formatted date string

getCanonicalDateString

public static java.lang.String getCanonicalDateString(long timestamp)
Returns:
An IS0-8601 formatted date string

getCanonicalDateStringOnly

public static java.lang.String getCanonicalDateStringOnly(java.util.Date date)
Returns:
formatted string representing DATE in ISO-8601 format: yyyy-MM-dd.

getCanonicalTimeStringOnly

public static java.lang.String getCanonicalTimeStringOnly(java.util.Date date)
Returns:
formatted string representing the TIME in ISO-8601 format: HH:mm:ss.SSSZ.

getClass

public static java.lang.Class getClass(boolean b)

getClass

public static java.lang.Class getClass(int i)

getClass

public static java.lang.Class getClass(long l)

getClass

public static java.lang.Class getClass(java.lang.Object o)

getClassNameFromFilePath

public static java.lang.String getClassNameFromFilePath(java.lang.String path)
Take a path name of a file and return the corresponding class name (e.g. "com.waveset.util.Util") if the file name ends with ".class". Otherwise, return null.


getClassNameFromZipPath

public static java.lang.String getClassNameFromZipPath(java.lang.String path)
Take a path name of a file from a zip (jar) file and return the corresponding class name (e.g. "com.waveset.util.Util") if the file name ends with ".class". Otherwise, return null.


getClasspathDirectory

public static java.lang.String getClasspathDirectory(int idx)
Return the nth item on the CLASSPATH. In addition to isolating the path, it will convert \ to / and trim the trailing slash if any.


getClasspathList

public static java.util.List getClasspathList()
Return a list of the items that are in the classpath.


getCodeId

public static java.lang.String getCodeId(java.lang.Class c)
                                  throws java.lang.Exception
Get the code id from the class.

Parameters:
c - Specified class.
Returns:
the codeId for the specified class if it exists; otherwise returns null.
Throws:
java.lang.Exception

getCodeId

public static java.lang.String getCodeId(java.lang.String c)
                                  throws java.lang.Exception
Get the code id from the class specified by the string.

Parameters:
c - - Fully qualified classname.
Returns:
the codeId for the specified class if it exists; otherwise returns null.
Throws:
java.lang.Exception

getDecrementedDate

public static java.util.Date getDecrementedDate(java.lang.String numLogin)

getDefaultEncoding

public static java.lang.String getDefaultEncoding()

getenv

public static java.lang.String getenv(java.lang.String name)
Return the value of an environment variable.

Now that Sun has thoughtfully decided to deprecate System.getenv, we have to kludge around the loss in other ways. This will work only on Unix and NT, but that's all we care about anyway. (Actually only NT at the moment).

This is NOT effecient, it will lauch a process for each request, so you should use this only for occasional lookups the values of which are then cached.

We could make this faster by reading the entire environment, and maintaining it in a Properties table, but then we'd have the problem of the values going stale.

Parameters:
name - Environment variable to retrieve
Returns:
Value of the environment variable.

getFileName

public static java.lang.String getFileName(java.lang.String filePath)
Parameters:
filePath - string representation of file path
Returns:
just the "basename" from the specified file path.

getFontsDir

public static java.io.File getFontsDir()
                                throws com.waveset.util.InvalidArgument,
                                       com.waveset.util.InternalError,
                                       com.waveset.util.ConfigurationError
Returns the path to the WEB-INF/fonts directory.

Throws:
com.waveset.util.InvalidArgument
com.waveset.util.InternalError
com.waveset.util.ConfigurationError

getInputStreamFromJar

public static java.io.InputStream getInputStreamFromJar(java.lang.String jarfilename,
                                                        java.lang.String entryName)
                                                 throws java.lang.Exception
Return an input stream for an entry in a jar file.

Throws:
java.lang.Exception

getInt

public static int getInt(java.lang.Object v)
Coerce an Object into an int primitive.

Parameters:
v - number or string representation of a number
Returns:
int value, possibly truncated, of v

getLighthouseJar

public static java.util.jar.JarFile getLighthouseJar()
Searches the classpath for idm.jar.


getLocalizedString

public static java.lang.String getLocalizedString(java.util.Locale locale,
                                                  java.lang.Object value)

getLong

public static long getLong(java.lang.Object v)
Coerce an Object value into a long primitive.

Parameters:
v - object to convert to a long
Returns:
long value

getMachineUser

public static java.lang.String getMachineUser()
Get the name of the user that is logged in to the host machine.


getMaxMemory

public static long getMaxMemory()

getMaxMemory

public static long getMaxMemory(boolean force)

getRelativeDate

public static java.util.Date getRelativeDate(int field,
                                             int amount)
Generates a data string expressed as a number of units from now such as "5 minutes from now"

Parameters:
field - Integer corresponding to the field of the date to increment. Legal values correspond with constants used by the Calendar class, namely: 0 (era) 1 (year) 2 (month) 3 (week of year) 4 (week of month) 5 (day of month) 6 (day of year) 7 (day of week) 8 (day of week in month) 9 (am/pm) 10 (hour) 11 (hour of day) 12 (minute) 13 (second) 14 (millisecond) 15 (zone offset) 16 (daylight savings time offset)
amount - Number representing the value to increment the current date by the units specified in field
Returns:
a time/date string in the future

getRelativeDate

public static java.util.Date getRelativeDate(int ord,
                                             int day,
                                             int mo)
Generates a date string expressed in a future time such as "the second Monday in October". If the current time is BEFORE the date requested by the input parameters, the date will be for the current year. If the current time is AFTER the date requested, the year will be incremented by one such that the date occurs in the future. The date returned will be rounded up to the day boundary.

Parameters:
ord - Integer representing the ordinal of the day of the week for the generated date and must be a number between 1 and 5 inclusive. If there are only four days in the month and the value of this parameter is 5, the result of this method call is undefined.
day - Integer representing a day of the week. Legal values correspond with constants used by the Calendar class, namely:
          1 (Sunday)
          2 (Monday)
          3 Tuesday)
          4 (Wednesday)
          5 (Thursday)
          6 (Friday)
          7 (Saturday)
        
mo - Integer representing a month. Legal values correspond with constants used by the Calendar class, namely:
          0 (January)
          1 (February)
          2 (March)
          3 (April)
          4 (May)
          5 (June)
          6 (July)
          7 (August)
          8 (September)
          9 (October)
          10 (November)
          11 (December)
        
Returns:
a time/date string

getRelativeDate

public static java.util.Date getRelativeDate(Util.TimePeriod period)
Calculates a Date representing the current time plus the the amount of time represented by the TimePeriod. If the unit of the specified TimePeriod is not MINUTES, the relative date returned will be rounded up to a day boundary so passwords won't expire until the second before midnight of the day the password is scheduled to expire.


getResource

public static java.net.URL getResource(java.lang.String name)
                                throws com.waveset.util.InvalidArgument
Returns:
the URL for the specified resource.

The call is delegated to the class loader for this class.

To get a URL for a Lighthouse application resource, call getWavesetResource(String).

Throws:
com.waveset.util.InvalidArgument

getResourceFile

public static java.io.File getResourceFile(java.net.URL resoUrl)
                                    throws com.waveset.util.InvalidArgument,
                                           com.waveset.util.ConfigurationError
Returns:
handle to specified resource as a File.
Throws:
com.waveset.util.InvalidArgument - if the specified URL is null.
com.waveset.util.ConfigurationError - if the specified URL is not a file.

Call method getResourceFileIfFile(URL) if the URL need not specify a file.


getResourceFile

public static java.io.File getResourceFile(java.net.URL resoUrl,
                                           boolean mustExist)
                                    throws com.waveset.util.InvalidArgument,
                                           com.waveset.util.ConfigurationError
Parameters:
mustExist - if true, the specified file must exist.
Returns:
handle to specified resource as a File.
Throws:
com.waveset.util.InvalidArgument - if the specified URL is null.
com.waveset.util.ConfigurationError - if the specified URL is not a file or if mustExist is true and the file does not exist.

Call method getResourceFileIfFile(URL) if the URL need not specify a file.


getResourceFileIfFile

public static java.io.File getResourceFileIfFile(java.net.URL resoUrl)
                                          throws com.waveset.util.InvalidArgument
Returns:
handle to specified resource as a File. Return null if the specified URL is not a file.

Call method getResourceFile(URL) if the specified URL must be a file.

Throws:
com.waveset.util.InvalidArgument - if the specified URL is null.

getResourcePath

public static java.lang.String getResourcePath(java.lang.String name)
Attempts to determine the absolute pathname of a resource file.

Parameters:
name - path to a resource file that can be found in the CLASSPATH.

getResourcePath

public static java.lang.String getResourcePath(java.net.URL res)
Parameters:
res - the URL of a resource file.
Returns:
the absolute pathname of a resource file.

getSavedObjectsDir

public static java.io.File getSavedObjectsDir()
                                       throws com.waveset.util.InvalidArgument,
                                              com.waveset.util.InternalError,
                                              com.waveset.util.ConfigurationError
Returns the path to the savedObjects directory.

Throws:
com.waveset.util.InvalidArgument
com.waveset.util.InternalError
com.waveset.util.ConfigurationError

getServerId

public static java.lang.String getServerId()
Return the "server id". This is expected to be a unique name that can be used to distinguish one JVM running Lighthouse from another. It is used primarily for obtaining repository locks. By default it will be the same as the value returned by getServerId, but DO NOT ASSUME THIS IS A HOST NAME. It may be specified with the waveset.serverId property. Doing so is necessary if you have more than one instance of Lighthouse running in a cluster on the same multi-processor machine. Since the hostname in this scenario will be the same for all instances, it cannot be used for repository locking. In this situation, you must arrange for each application server instance to set the waveset.serverId to a unique value.

Returns:
server id if set, otherwise the host name

getStringFromJar

public static java.lang.String getStringFromJar(java.lang.String jarfilename,
                                                java.lang.String entryName)
                                         throws java.lang.Exception
Return the contents of an entry in a jar file as a string.

Throws:
java.lang.Exception

getUsedMemory

public static long getUsedMemory()

getUsedMemory

public static long getUsedMemory(boolean force)

getVersionFromCodeId

public static java.lang.String getVersionFromCodeId(java.lang.String codeid)
Get the version number from the CVS code id.

Parameters:
codeid - Code id to parse.
Returns:
the version in string form otherwise null.

getWavesetConfigURL

public static java.net.URL getWavesetConfigURL()
Get a URL that points to our config directory, should be a file URL that points to lighthouse/config.


getWavesetHome

public static java.lang.String getWavesetHome()
Returns:
the application docroot string.

NOTE: This string could be a file path or a URL.

See Also:
getWavesetHomePathIfFile(), getWavesetHomeURL()

getWavesetHomePathIfFile

public static java.lang.String getWavesetHomePathIfFile()
Convenience method. In the simple case where waveset.home is a directory that is available to the local file system, this method returns the path to that directory.

Returns:
the path to waveset.home if waveset.home is a file; otherwise null.

Originally, the value of waveset.home was always a String containing a file path to a local (or locally mounted) directory. Later, support for application-server-clustered environments required that we generalize waveset.home to a URL (and that we no longer assume access to the local file system).


getWavesetHomeURL

public static java.net.URL getWavesetHomeURL()
Returns:
the application docroot URL.

NOTE: This could be a file or a JAR (WARfile) URL.

See Also:
getWavesetHomePathIfFile()

getWavesetHomeURL

public static java.net.URL getWavesetHomeURL(boolean ignoreAnyCached)
Parameters:
ignoreAnyCached - re-read SystemProperty

Try (in the following order):

  1. System property waveset.home
  2. environment variable "WS_HOME".
  3. parsing the URL to this class (as a resource).
Returns:
a URL for waveset.home (the application docroot).

getWavesetResource

public static java.net.URL getWavesetResource(java.lang.String name)
                                       throws com.waveset.util.InvalidArgument,
                                              com.waveset.util.InternalError
Parameters:
name - relative to the application docroot (as specified by System Property waveset.home).

Returns:
a URL for the named resource
Throws:
com.waveset.util.InvalidArgument - if name is null.
com.waveset.util.InternalError - if waveset.home URL cannot be determined.

getWavesetResourceFile

public static java.io.File getWavesetResourceFile(java.lang.String name)
                                           throws com.waveset.util.InvalidArgument,
                                                  com.waveset.util.InternalError,
                                                  com.waveset.util.ConfigurationError
Convenience method: equivalent to calling getWavesetResource(); and getResourceFile();.

Throws:
com.waveset.util.InvalidArgument
com.waveset.util.InternalError
com.waveset.util.ConfigurationError

getWavesetResourcePath

public static java.lang.String getWavesetResourcePath(java.lang.String name)
                                               throws com.waveset.util.InvalidArgument,
                                                      com.waveset.util.InternalError
Convenience method: equivalent to calling getWavesetResource(); and getResourcePath();.

Throws:
com.waveset.util.InvalidArgument
com.waveset.util.InternalError

gzipCompress

public static byte[] gzipCompress(byte[] inbytes)
                           throws com.waveset.util.WavesetException
Throws:
com.waveset.util.WavesetException

gzipDecompress

public static byte[] gzipDecompress(byte[] inBytes)
                             throws com.waveset.util.WavesetException
Decompress an array of bytes, if possible.

Parameters:
inBytes -
Returns:
decompressed bytes
Throws:
com.waveset.util.WavesetException - on IOException. The underlying IOException is wrapped by the WavesetException.

gzipDecompress

public static byte[] gzipDecompress(byte[] inbytes,
                                    int size)
                             throws com.waveset.util.WavesetException
Throws:
com.waveset.util.WavesetException

hashCode

public static java.lang.Integer hashCode(java.lang.Object o)

hashtableToMap

public static java.util.HashMap hashtableToMap(java.util.Hashtable hash)
Convert a Hashtable into a HashMap. There are probably easier ways to do this with some of the newer collection methods.


ignoreCase

public static java.lang.String ignoreCase(java.lang.String s)
Parameters:
s - - input string This method hides whether we convert to upper case or to lower case for case-insensitive comparison (since we've waffled a bit on this issue).
Returns:
a value to use for case-insensitive comparison.

indexOf

public static int indexOf(java.lang.Object[] objs,
                          java.lang.Object obj)

isASCIILetter

public static boolean isASCIILetter(char in)
Walk the string, converting any non-alpha or numeric char to an underscore. They must start with a letter or _, then all chars must be a letter, number, or _

Parameters:
in - character to test
Returns:
true if ch is an ASCII letter

isASCIILetterOrDigit

public static boolean isASCIILetterOrDigit(char in)

isNumeric

public static boolean isNumeric(java.lang.String s)
Parameters:
s - string
Returns:
true if the specified string contains only digits or decimal points, and possibly a leading minus sign. Cheaper than catching an exception from a parse method.

isWindows

public static boolean isWindows()
Are we running in windows?

Returns:
true if os.name contains "Windows"

itoa

public static java.lang.String itoa(int i)
Convert an primitive integer value into a String. This doesn't really save much space, but its the obvious inverse to atoi.

Parameters:
i - integer
Returns:
String representation of i

legalizeResourceName

public static java.lang.String legalizeResourceName(java.lang.String resoName)

length

public static int length(byte[] array)

length

public static int length(char[] array)

length

public static int length(int[] array)

length

public static int length(long[] array)

length

public static int length(java.lang.Object[] array)

length

public static int length(java.lang.String psz)

length

public static int length(java.lang.StringBuffer sb)

lengthInUTF8

public static int lengthInUTF8(java.lang.String psz)
                        throws com.waveset.util.InternalError
Throws:
com.waveset.util.InternalError

listAllFilenames

public static java.util.List listAllFilenames(java.io.File dir,
                                              boolean relativeNames)
                                       throws java.lang.Exception
List all of the filenames (not including directory names) in the specified directory and its subdirectories. Either return names relative to the directory or as canonical path names.

Throws:
java.lang.Exception

listClasses

public static java.util.List listClasses()
                                  throws java.lang.Exception
List all of the classes in the classpath.

Throws:
java.lang.Exception

listClassesInDirectory

public static java.util.List listClassesInDirectory(java.io.File dir)
                                             throws java.lang.Exception
List all of the classes found in the specified directory or its subdirectories. The directory should be one that might be added to a classpath.

Throws:
java.lang.Exception

listClassesInZipFile

public static java.util.List listClassesInZipFile(java.io.File file)
                                           throws java.lang.Exception
List all of the classes in the specified zip (jar) file.

Throws:
java.lang.Exception

listClassNamesMatching

public static java.util.List listClassNamesMatching(java.lang.String baseName)
                                             throws com.waveset.util.InvalidArgument
Returns:
a list containing the fully-qualified names of classes in the Lighthouse archive (jar file) that contain the specified partial name.
Throws:
com.waveset.util.InvalidArgument

listToCommaDelimitedString

public static java.lang.String listToCommaDelimitedString(java.util.List list)
Parameters:
list - - a string of tokens separated by commas.

Will not return any token that contains only white space.

Returns:
a string containing comma-delimited string tokens.

listToString

public static java.lang.String listToString(java.util.List list,
                                            java.lang.String delim)
Parameters:
list - - the input list
delim - - the delimiter string
Returns:
a string containing delimited tokens.

listToString

public static java.lang.String listToString(java.util.List list,
                                            java.lang.String delim,
                                            int maxLen)
Parameters:
list - - the input list
delim - - the delimiter string
maxLen - - the maximum length of the resulting string.
Returns:
a string containing delimited tokens.

listToString

public static java.lang.String listToString(java.util.List list,
                                            java.lang.String delim,
                                            int maxLen,
                                            java.lang.String valWrapper)
Parameters:
list - - the input list
delim - - the delimiter string
maxLen - - the maximum length of the resulting string.
valWrapper - - precede and follow each value with this string (e.g., a single-quote must precede and follow each literal value in an SQL "IN" expression.)
Returns:
a string containing delimited tokens.

lpad

public static java.lang.String lpad(java.lang.String str,
                                    int length)
Left-pad a string to the specified length. Pad a numeric string with zeros, any other with the space character.

Parameters:
str - string
length - length for padded string
Returns:
left padded string
See Also:
isNumeric(String)

lpad

public static java.lang.String lpad(java.lang.String str,
                                    int length,
                                    char padChar)
Left-pad a string to the specified length with the specified character.

Parameters:
str - string
length - length for pad
padChar - character to use for padding
Returns:
padded string

ltoa

public static java.lang.String ltoa(long l)
Convert a primitive long value into a String. This doesn't really save much space, but its the obvious inverse to atol.

Parameters:
l - long value to convert
Returns:
string representation of l

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception

makeList

public static java.util.List makeList(java.lang.Object[] array)
Make a List out of an array.

Parameters:
array - Array of elements to insert in a new list.
Returns:
List of elements in array

mangle

public static java.lang.String mangle(java.lang.String name)
                               throws com.waveset.util.InternalError
Replace special characters in a name or id so that it will be a valid filename.

Returns:
name or id (mangled into a) valid filename.
Throws:
com.waveset.util.InternalError

mapName

public static java.lang.String mapName(java.util.Locale locale,
                                       java.lang.String prefix,
                                       java.lang.String name)
Given a name, try to map it using the catalog.

Parameters:
locale - Locale for the current session.
prefix - Catalog prefix.
name - Name to search for in the message catalog.
Returns:
localized message if in the catalog, otherwise name.

mapToString

public static java.lang.String mapToString(java.util.Map map)

mapToString

public static java.lang.String mapToString(java.util.Map map,
                                           java.lang.String separator)

matchSimpleWildcard

public static boolean matchSimpleWildcard(java.lang.String in,
                                          java.lang.String matchString)
Very simple string matching, allows matchString to end in a * and match another string com.waveset.* matches com.waveset.util.Util.matchSimpleWildcard

Parameters:
in - string
matchString - string to match (allowed to end in *)
Returns:
true if in matches matchString, false otherwise

midString

public static java.lang.String midString(java.lang.StringBuffer in,
                                         char delim,
                                         int start,
                                         int count)
Given a string like aaa,bbb,ccc,ddd and a delim of ",", return a string containing the items between start and (start + count). midString("aaa,bbb,ccc,ddd", ",", 2,2) returns "ccc,ddd" midString("aaa,bbb,ccc,ddd", ",", 2,4) returns "ccc,ddd" midString("aaa,bbb,ccc,ddd", ",", 1,1) returns "aaa"

Parameters:
in - StringBuffer containing delimited list of tokens
delim - character delimiter
start - which token to start with
count - how many tokens to return, if available
Returns:
string containing delimited list of tokens

normalizeString

public static java.lang.String normalizeString(java.lang.String str)
Normalization of the string will be done using an implementation of RFC2253 which specifies the standard for the string representation of distinguished names handling issue such as capitalization, component ordering, special characters, internationalized characters, trimming leading and trailing spaces, etc.

This is being called to normalize all strings when doing AttributeCondition compares since we don't really care how the two strings (provided string and operand string) look as long as they compare if the same.

If string passed in is null, it is not normalized and null is returned.


pad

public static java.lang.String pad(java.lang.String s,
                                   int len,
                                   char pad,
                                   boolean leftPad)
Parameters:
s - - the input string to pad.
len - - pad to this length.
pad - - pad with this character.
leftPad - - if true, prepend pad characters; otherwise, append.
Returns:
the input string, padded to a specified length.

pathIsAbsolute

public static boolean pathIsAbsolute(java.lang.String path)
Returns:
true if the specified path appears to be an absolute path; otherwise false.

Don't bother to call this if you already have (or plan to construct) a File with the specified path. This method is a poor man's File.isAbsolute(), this method's advantage is that it avoids object construction.


pathIsRelative

public static boolean pathIsRelative(java.lang.String path)
Returns:
true if the specified path appears to be a relative path; otherwise false.

Don't bother to call this if you already have (or plan to construct) a File with the specified path. This method is a poor man's inverse of File.isAbsolute(), this method's advantage is that it avoids object construction.


print

public static void print(java.lang.Object o)

println

public static void println()
Ubiquitous macro


println

public static void println(java.lang.Object o)

printStackTrace

public static void printStackTrace()
Debugging aid that dumps the current stack trace to the console.


putJarEntries

public static void putJarEntries(java.lang.String jarFileName,
                                 java.util.List entryNames,
                                 boolean jarMustExist,
                                 boolean overwriteEntry,
                                 boolean updateExistingJar)
                          throws com.waveset.util.InvalidArgument,
                                 com.waveset.util.WavesetException
Archive and compress a data file.

Parameters:
jarFileName - - the path to the Java ARchive file.
entryNames - - a list of files to be placed in the jar file.
jarMustExist - - if true, the file named by jarFileName must exist.
overwriteEntry - - if true, the specified jarEntry may replace an existing entry with the same name.
Throws:
com.waveset.util.InvalidArgument - - thrown if jarMustExist is true and jar file is not found, or if overwriteEntry is false and an entry with the name specified by jarEntryName already exists.
com.waveset.util.WavesetException

putJarEntry

public static void putJarEntry(java.lang.String jarFileName,
                               java.lang.String jarEntryName,
                               boolean jarMustExist,
                               boolean overwriteEntry)
                        throws com.waveset.util.InvalidArgument,
                               com.waveset.util.WavesetException
Archive and compress a data file.

Parameters:
jarFileName - - the path to the Java ARchive file.
jarEntryName - - the path to a file to be placed in the jar file.
jarMustExist - - if true, the file named by jarFileName must exist.
overwriteEntry - - if true, the specified jarEntry may replace an existing entry with the same name.
Throws:
com.waveset.util.InvalidArgument - - thrown if jarMustExist is true and jar file is not found, or if overwriteEntry is false and an entry with the name specified by jarEntryName already exists.
com.waveset.util.WavesetException

readFile

public static java.lang.String readFile(java.io.File file)
                                 throws com.waveset.util.IOException
Read the contents of a file and return it as a String.

Parameters:
file - File to read
Returns:
String containing file contents
Throws:
com.waveset.util.IOException - on error

readFile

public static java.lang.String readFile(java.lang.String name)
                                 throws com.waveset.util.IOException
Read the contents of a file and return it as a String.

Parameters:
name - file name
Returns:
string containing file contents
Throws:
com.waveset.util.IOException - on error

readFileBytes

public static byte[] readFileBytes(java.io.File file)
                            throws com.waveset.util.IOException
Read the contents of a file and return it as a byte array.

Parameters:
file - File to read
Returns:
byte array containing file contents.
Throws:
com.waveset.util.IOException - on error

readFileBytes

public static byte[] readFileBytes(java.lang.String name)
                            throws com.waveset.util.IOException
Read the content of a file and return it as a byte array.

Parameters:
name - file name
Returns:
byte array containing bytes in the file.
Throws:
com.waveset.util.IOException - on error

readFileUtf8

public static java.lang.String readFileUtf8(java.io.File filename)
                                     throws com.waveset.util.IOException
Throws:
com.waveset.util.IOException

readFileUtf8

public static java.lang.String readFileUtf8(java.io.InputStream in)
                                     throws com.waveset.util.IOException
Throws:
com.waveset.util.IOException

readFileUtf8

public static java.lang.String readFileUtf8(java.lang.String filename)
                                     throws com.waveset.util.IOException
Throws:
com.waveset.util.IOException

readInputStream

public static java.lang.String readInputStream(java.io.InputStream in)
                                        throws com.waveset.util.IOException
Read the contents of an input stream and return it as a String.

Parameters:
in - Input Stream to read
Returns:
String containing input stream contents
Throws:
com.waveset.util.IOException - on error

readInputStreamBytes

public static byte[] readInputStreamBytes(java.io.InputStream is,
                                          boolean close)
                                   throws com.waveset.util.IOException
Parameters:
is - input stream
close - - if true, close when finished reading.
Returns:
input stream content.
Throws:
com.waveset.util.IOException - on error

readResource

public static java.lang.String readResource(java.net.URL resoUrl)
                                     throws com.waveset.util.InvalidArgument,
                                            com.waveset.util.IOException,
                                            com.waveset.util.InternalError
Returns:
the content of the specified URL as a String.
Throws:
com.waveset.util.InvalidArgument
com.waveset.util.IOException
com.waveset.util.InternalError

readURLBytes

public static byte[] readURLBytes(java.net.URL url)
                           throws com.waveset.util.IOException
Read the content of a URL.

Parameters:
url - URL from which to read content
Returns:
the content as an array of bytes.
Throws:
com.waveset.util.IOException - on error

readURLBytesIfExists

public static byte[] readURLBytesIfExists(java.net.URL url)
Read the contents of a URL if there is something there. Do not throw exceptions if the URL does not resolve to a file. This is used for things like the help catalogs where we want to read a file if one exists, but don't want to throw a WavesetException (and provoke an exception breakpoint) if it doesn't.

Parameters:
url - URL from which to read
Returns:
byte array containing contents of URL, if anything is present

readWavesetResource

public static java.lang.String readWavesetResource(java.lang.String name)
                                            throws com.waveset.util.InvalidArgument,
                                                   com.waveset.util.InternalError,
                                                   com.waveset.util.IOException
Convenience method: equivalent to calling getWavesetResource(); and readResource();.

Throws:
com.waveset.util.InvalidArgument
com.waveset.util.InternalError
com.waveset.util.IOException

removeDuplicates

public static void removeDuplicates(java.util.List list)
Remove the duplicates from a list, returning the duplicate-free list.

Parameters:
list - List from which to remove all duplicate entries

removeNulls

public static void removeNulls(java.util.List list)
Remove null elements from a list.

Parameters:
list - List from which to remove all null elements.

renameFileForBackup

public static boolean renameFileForBackup(java.io.File file)
Renames the file using the following format: .backup.yyyyMMdd_HHmmss. Returns whether or not the file was renamed.

Parameters:
file - to be backed up/rename
Returns:
whether the file was renamed

renameFileForBackup

public static boolean renameFileForBackup(java.lang.String path)
Renames the file using the following format: .backup.yyyyMMdd_HHmmss. Returns whether or not the file was renamed.

Parameters:
path - of file to back up/rename
Returns:
whether the file was renamed

replaceChar

public static java.lang.String replaceChar(java.lang.String s,
                                           java.lang.String replaceMe,
                                           java.lang.String replaceWith)
Replace all occurances of replaceMe with replaceWith

Parameters:
s - string to which to apply substitions
replaceMe - string to replace
replaceWith - replacement string
Returns:
string with replacements

replaceString

public static java.lang.String replaceString(java.lang.String in,
                                             java.lang.String fromString,
                                             java.lang.String toString)
Returns:
a new string resulting from replacing all occurrences of fromString in the input string in with toString.

resourceExists

public static boolean resourceExists(java.net.URL resoUrl)
Returns:
true if we can connect to the specified resource; otherwise false.

roundTo

public static double roundTo(double d,
                             int decimalPlaces)

roundToInt

public static int roundToInt(double d)

rpad

public static java.lang.String rpad(java.lang.String str,
                                    int length)
Right-pad a string buffer to the specified length. Pad a numeric string with zeros, any other with the space character.

Parameters:
str - string
length - length for pad
Returns:
padded string
See Also:
isNumeric(String)

rpad

public static java.lang.String rpad(java.lang.String str,
                                    int length,
                                    char padChar)
Right-pad a string buffer to the specified length with the specified character.

Parameters:
str - string
length - padded string length
padChar - character to pad string
Returns:
padded string

setWavesetHome

public static java.lang.String setWavesetHome(java.lang.String newValue)
Set the application docroot.

Returns:
any previous value.

size

public static int size(java.util.Collection collection)

size

public static int size(java.util.Map map)

sortList

public static java.util.List sortList(java.util.List list)
Sort a list

Parameters:
list - of values to be sorted
Returns:
sorted list

sprintf

public static java.lang.StringBuffer sprintf(java.lang.String format,
                                             java.lang.String[] args)
A marginally functional attempt to provide "sprintf" in Java. The format string is a blank delimited list of integer tokens that represent the field sizes. The args array contains the strings that will plug into the fields. Todo: take an Object[] array instead of a String[] array add format tokens for left/right justification allow literal text in the format string


stackToHtml

public static java.lang.String stackToHtml(java.lang.Throwable th)
Converts the stack trace of an exception to an HTML string


stackToHtmlComment

public static java.lang.String stackToHtmlComment(java.lang.Throwable th)
Converts the stack trace of an exception to an HTML string Bug #10499 If 'ui.web.disableStackTraceComments' property in waveset.properties is 'true' this returns an empty string. By default the property is false, in which case the stack trace is returned as an HTML comment string.


stackToString

public static java.lang.String stackToString(java.lang.Throwable th)
Converts the stack trace of an exception to a String


stringToArray

public static java.lang.String[] stringToArray(java.lang.String s)
Inverse of arrayToString (except that we cannot convert back to Object).

Parameters:
s - string representing an array of strings
Returns:
array of strings

stringToDate

public static java.util.Date stringToDate(java.lang.String src)
                                   throws java.text.ParseException
Convert the string representation for a date into a Date object. The string may be of the following forms: M/d/y H:m:s z M/d/y H:m:s M/d/y yyyyMMdd HH:mm:ss (default) yyyyMMdd HH:mm:ss.SSS (old canonical) yyyyMMddTHH:mm:ss.SSS (old canonical absolute) yyyy-MM-ddTHH:mm:ss.SSSZ (canonical, no offset) yyyy-MM-ddTHH:mm:ss.SSS+/-HHMM (canonical, offset) nnnnnnnnnnnnnnnnn (milliseconds)

Throws:
java.text.ParseException
See Also:
DATE_FORMAT_COMPACT, DATE_FORMAT_DEFAULT, DATE_FORMAT_MILLIS

stringToDate

public static java.util.Date stringToDate(java.lang.String src,
                                          java.lang.String format)
                                   throws java.text.ParseException
Throws:
java.text.ParseException

stringToDate

public static java.util.Date stringToDate(java.lang.String src,
                                          java.lang.String format,
                                          java.lang.String timeZone)
                                   throws java.text.ParseException
Throws:
java.text.ParseException

stringToDate

public static java.util.Date stringToDate(java.lang.String src,
                                          java.lang.String format,
                                          java.lang.String timeZone,
                                          java.util.Locale locale)
                                   throws java.text.ParseException
Throws:
java.text.ParseException

stringToHtmlComment

public static java.lang.String stringToHtmlComment(java.lang.String s)
Converts the stack trace of an exception to an HTML string


stringToList

public static java.util.List stringToList(java.lang.String s,
                                          java.lang.String delim)
Parameters:
s - - the input string
delim - - the delimiter string (NOTE: NOT as in StringTokenizer(s, delim). Instead, the entire string is taken as the separator.)
Returns:
a list of string tokens. Trims whitespace from the beginning and end of each token. Ignores any token that contains only white space.

stringToList

public static java.util.List stringToList(java.lang.String s,
                                          java.lang.String delim,
                                          boolean trim)
Parameters:
s - - the input string
delim - - the delimiter string (NOTE: NOT as in StringTokenizer(s, delim). Instead, the entire string is taken as the separator.)
trim - - if true, remove any whitespace from the beginning and the end of each token. Ignore any token that contains only white space.
Returns:
a list of string tokens.

stringToList

public static java.util.List stringToList(java.lang.String s,
                                          java.lang.String delim,
                                          boolean trim,
                                          java.lang.String valWrapper)
Parameters:
s - - the input string
delim - - the delimiter string (NOTE: NOT as in StringTokenizer(s, delim). Instead, the entire string is taken as the separator.)
trim - - if true, remove any whitespace from the beginning and the end of each token. Ignore any token that contains only white space.
valWrapper - - expected to precede and follow each token (e.g., a single-quote must precede and follow each literal value in an SQL "IN" expression).
Returns:
a list of string tokens.

stringToList

public static java.util.List stringToList(java.lang.String s,
                                          java.lang.String delim,
                                          boolean trim,
                                          java.lang.String valWrapper,
                                          java.lang.String escChar,
                                          boolean unpack)
Parameters:
s - - the input string
delim - - the delimiter string (NOTE: NOT as in StringTokenizer(s, delim). Instead, the entire string is taken as the separator.)
trim - - if true, remove any whitespace from the beginning and the end of each token. Ignore any token that contains only white space.
valWrapper - - expected to precede and follow each token (e.g., a single-quote must precede and follow each literal value in an SQL "IN" expression).
escChar - - This string should be a single escape character to check for before splitting based on the delimiter.
unpack - - remove escape characters before adding strings to the list
Returns:
a list of string tokens.

strip

public static java.lang.String strip(java.lang.Throwable th)

stripClassName

public static java.lang.String stripClassName(java.lang.String in)
Strip the classname off of the front of an error if it really looks like a classpath - and it looks like there is a real error out there. While we are at it, translate some of the really common java errors to strings: java.lang.OutOfMemoryError, java.lang.NullPointerException;

Parameters:
in - error string
Returns:
error string with classname removed

strlen

public static int strlen(java.lang.String inString)
Returns the length of the specified string. Returns zero if the specified string is null.

Parameters:
inString - string
Returns:
length of the string, 0 if null

strstr

public static java.lang.String strstr(java.lang.String inString,
                                      java.lang.String delimiter)
Returns the last token in a string of tokens separated by the specified delimiter.

Parameters:
inString - string to search
delimiter - delimiter for tokens
Returns:
last token in the string

timestampConvert

public static java.lang.String timestampConvert(java.lang.String dText,
                                                java.lang.String tText,
                                                java.util.List formats,
                                                java.lang.String iTimezone,
                                                java.lang.String oMask,
                                                java.lang.String oTimezone)
Parameters:
dText - The date to attempt to parse
tText - The time to attempt to parse
formats - A list of Strings that will become the SimpleDateFormat objects used to parse dText/tText
iTimezone - What time zone the given time stamp is in
oMask - A SimpleDateFormat friendly format mask used to emit the time stamp in
oTimezone - The time zone the outputted time should be in
Returns:
The given time, or now (if the given time could not be parsed), formated as directed by oMask in the time zone specified in oTimezone

timestampConvert

public static java.lang.String timestampConvert(java.lang.String dText,
                                                java.lang.String tText,
                                                java.lang.String iTimezone,
                                                java.lang.String oMask,
                                                java.lang.String oTimezone)
Parameters:
dText - The date to use (must be in MM/dd/yyyy form)
tText - The time to use (must be in HH:mm, Hmm, or HHmm form)
iTimezone - What time zone the given time stamp is in
oMask - A SimpleDateFormat friendly format mask used to emit the time stamp in
oTimezone - The time zone the outputted time should be in
Returns:
The given time, or now (if the given time could not be parsed), formated as directed by oMask in the time zone specified in oTimezone

topStackFrames

public static java.lang.String topStackFrames(int num)
Returns:
a String of the the top num stack frames

toString

public static java.lang.String toString(boolean b)

toString

public static java.lang.String toString(char c)

toString

public static java.lang.String toString(int i)

toString

public static java.lang.String toString(long l)

toString

public static java.lang.String toString(java.lang.Object o)

toUpperByteArray

public static byte[] toUpperByteArray(byte[] barray)
Coverts all bytes to upper case.

Note: This method is not safe for internationalization since it will use the default encoding of the machine it is running on.

Parameters:
barray - Byte array of input if this is null the return will be null.
Returns:
Returns a byte array of upper case.

toUpperByteArray

public static byte[] toUpperByteArray(byte[] barray,
                                      java.lang.String enc)
Coverts all bytes to upper case.

Parameters:
barray - Byte array of input if this is null the return will be null.
enc - character encoding
Returns:
Returns a byte array of upper case.

toUpperCharArray

public static char[] toUpperCharArray(char[] carray)
Converts all lower case characters to upper case.

Parameters:
carray - Byte array of input if this is null the return will null.
Returns:
Returns an array of characters in upper case.

trimWhitespace

public static java.lang.String trimWhitespace(java.lang.String src)
Trims trailing whitespace from a string. String.trim() can be used if you want to trim from both sides of the string.

Parameters:
src - string to trim
Returns:
src trimmed of trailing whitespace

truncateAt

public static java.lang.String truncateAt(java.lang.String in,
                                          java.lang.String delim,
                                          int count)
Given a string like aaa,bbb,ccc,ddd and a delim of ",", return a string containing the first count items. truncateAt("aaa,bbb,ccc,ddd", ",", 2) returns "aaa,bbb"

Parameters:
in - string
delim - delimiter
count - number of items to return
Returns:
substring of first count tokens, delimited by the same delim.

truncateEncodedString

public static java.lang.String truncateEncodedString(java.lang.String psz,
                                                     java.lang.String encoding,
                                                     int maxbytes)
                                              throws com.waveset.util.InvalidArgument
Truncate string in encoding space, returning longest string that will fit in a byte buffer of the given size after it has been encoded.

Parameters:
psz - String to be truncated.
encoding - to be used to convert to equivalent byte array.
maxbytes - allowed in byte array before truncation.
Returns:
the substring of psz, such that if the returned substring is encoded with the given encoding, it will result in a byte array <= maxbytes.
Throws:
com.waveset.util.InvalidArgument - - thrown if psz is null OR encoding is null OR maxbytes is negative OR encoding is not valid

uncompressFromString

public static java.io.Serializable uncompressFromString(java.lang.String str)
Called to retrieve the object passed into compressToString


URLDecode

public static java.lang.String URLDecode(java.lang.String s)
Process a string to decode all characters using the com.waveset.util.URLUTF8Decoder.decode method

null strings will be returned null

Parameters:
s - string to decode
Returns:
decoded string

URLEncode

public static java.lang.String URLEncode(java.lang.String s)
Process a string to encode all characters using the com.waveset.util.URLUTF8Encoder.encode method

null strings will be returned null

Parameters:
s - string to encode
Returns:
encoded string

wavesetResourceExists

public static boolean wavesetResourceExists(java.lang.String name)
                                     throws com.waveset.util.InvalidArgument,
                                            com.waveset.util.InternalError
Convenience method: equivalent to calling getWavesetResource(); and resourceExists();.

Throws:
com.waveset.util.InvalidArgument - if specified name is null.
com.waveset.util.InternalError - if waveset.home URL cannot be determined.

writeFile

public static void writeFile(java.io.File file,
                             java.lang.String contents)
                      throws com.waveset.util.InvalidArgument,
                             com.waveset.util.IOException
Store the contents of a String in a file.

Parameters:
file - destination file for contents
contents - string containing content to write
Throws:
com.waveset.util.InvalidArgument - on error
com.waveset.util.IOException - on error

writeFile

public static void writeFile(java.lang.String name,
                             byte[] contents)
                      throws com.waveset.util.IOException
Store the contents of a String in a file.

Parameters:
name - identifies file to write contents
contents - byte array containing content to write
Throws:
com.waveset.util.IOException - on error

writeFile

public static void writeFile(java.lang.String name,
                             java.lang.String contents)
                      throws com.waveset.util.IOException
Store the contents of a String in a file.

Parameters:
name - identifies file to write contents
contents - string to write to file
Throws:
com.waveset.util.IOException - on error

writeFileUtf8

public static void writeFileUtf8(java.lang.String name,
                                 java.lang.String contents)
                          throws com.waveset.util.IOException
Throws:
com.waveset.util.IOException

writeResource

public static void writeResource(java.net.URL resoUrl,
                                 java.lang.String content)
                          throws com.waveset.util.InvalidArgument,
                                 com.waveset.util.ConfigurationError,
                                 com.waveset.util.IOException
Replace the content of the specified URL with a String if that URL is a file.

If Lighthouse is deployed as (expanded) Servlet files, then most resources can be written. However, if Lighthouse is deployed as some form of archive (e.g., a WAR or an EAR), then resources should not ordinarily be written.

Throws:
com.waveset.util.InvalidArgument - if either argument is null.
com.waveset.util.ConfigurationError - if the resource is not writable.
com.waveset.util.IOException - if an error occurs writing the resource.

writeWavesetResource

public static void writeWavesetResource(java.lang.String name,
                                        java.lang.String content)
                                 throws com.waveset.util.InvalidArgument,
                                        com.waveset.util.InternalError,
                                        com.waveset.util.ConfigurationError,
                                        com.waveset.util.IOException
Convenience method: equivalent to calling getWavesetResource(); and writeResource();.

Throws:
com.waveset.util.InvalidArgument
com.waveset.util.InternalError
com.waveset.util.ConfigurationError
com.waveset.util.IOException