|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.waveset.util.Util
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_CANONICAL
Deprecated. Will become a private constant since this doesn't handle parsing a general IS0-8601 format. (Only handles our subset). Instead always use the public methods stringToDate and getCanonicalDateString. (At some point we may want to handle parsing a general IS0-8601 format). |
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 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.ArrayList 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)
|
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(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.Boolean |
autoBox(boolean b)
|
static java.lang.Integer |
autoBox(int i)
|
static java.lang.Long |
autoBox(long l)
|
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,
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 void |
debug(java.lang.Object o)
Deprecated. Use Debug or Trace instead. |
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 |
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)
return a list of duplicate entries in a 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.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.text.DateFormat |
getCanonicalDateFormat()
Deprecated. Will become a private method since this doesn't handle parsing a general IS0-8601 format. (Only handles our subset). Instead always use the public methods stringToDate and getCanonicalDateString. (At some point we may want to handle parsing a general IS0-8601 format). |
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. |
protected static java.lang.String |
getClassNameFromPath(java.lang.String path,
java.lang.String separator)
Take a path name of a file that uses the specified separator 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.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 |
getLocalHostName()
Return the local host name. |
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.lang.String |
getOldCanonicalDateString(java.util.Date date,
boolean absoluteTimezone)
Deprecated. Use getCanonicalDateString |
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 java.lang.String |
getUniqueId()
Generate a globally unique identifier. |
static long |
getUsedMemory()
|
static long |
getUsedMemory(boolean force)
|
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. |
protected static java.util.List |
listAllFilenames(java.io.File dir,
boolean relativeNames,
java.lang.String basepath)
|
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 String. |
static byte[] |
readFileBytes(java.lang.String name)
Read the content of a file and return it as a String. |
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: |
static boolean |
renameFileForBackup(java.lang.String path)
Renames the file using the following format: |
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 java.lang.String |
rfc2396URLPieceEncode(java.lang.String s)
Deprecated. Use RFC2396URLPieceEncode class. |
static java.lang.String |
rfc2396URLPieceEncode(java.lang.String s,
java.lang.String dontEncode)
Deprecated. Use RFC2396URLPieceEncode class. |
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.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.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 |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String code_id
public static final java.lang.String DATE_FORMAT_COMPACT
"yyyyMMdd HH:mm:ss"
public static final java.lang.String DATE_FORMAT_DEFAULT
public static final java.lang.String DATE_FORMAT_AM_PM
public static final java.lang.String DATE_FORMAT_NO_SPACE
public static final java.lang.String DATE_FORMAT_CANONICAL
public static java.util.TimeZone TIME_ZONE_CANONICAL
public static final java.lang.String DATE_FORMAT_MILLIS
long
value).
public static final int INTERVAL_UNIT_HOURS
public static final int INTERVAL_UNIT_MINUTES
public static final int INTERVAL_UNIT_SECONDS
public static final int INTERVAL_UNIT_MILLISECONDS
public static final java.util.List stockDateTimePatterns
Constructor Detail |
public Util()
Method Detail |
public static java.lang.String getDefaultEncoding()
public static int lengthInUTF8(java.lang.String psz) throws InternalError
InternalError
public static java.lang.String getUniqueId()
public static int length(java.lang.String psz)
public static int length(java.lang.StringBuffer sb)
public static int length(byte[] array)
public static int length(char[] array)
public static int length(int[] array)
public static int length(long[] array)
public static int length(java.lang.Object[] array)
public static int size(java.util.Map map)
public static int size(java.util.Collection collection)
public static java.lang.Long autoBox(long l)
public static java.lang.Integer autoBox(int i)
public static java.lang.Boolean autoBox(boolean b)
public static java.lang.Class getClass(java.lang.Object o)
public static java.lang.Class getClass(int i)
public static java.lang.Class getClass(long l)
public static java.lang.Class getClass(boolean b)
public static java.lang.Integer hashCode(java.lang.Object o)
public static java.lang.String formatBytes(long bytes)
public static void formatMemoryStatistics(java.lang.StringBuffer sb)
public static java.lang.String formatMemoryStatistics()
public static long getUsedMemory()
public static long getUsedMemory(boolean force)
public static long getMaxMemory()
public static long getMaxMemory(boolean force)
public static java.lang.String getServerId()
public static java.lang.String getLocalHostName()
public static java.lang.String exec(java.lang.String command) throws WavesetException
WavesetException
public static java.lang.String getenv(java.lang.String name)
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.
public static void addElement(java.util.ArrayList list, int index, java.lang.Object o)
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.
public static java.util.List findDuplicates(java.util.List list)
public static void removeDuplicates(java.util.List list)
public static void removeNulls(java.util.List list)
public static java.util.List makeList(java.lang.Object[] array)
public static char[] byteToChar(byte[] inb, java.lang.String enc)
inb
- Byte array of input if this is null the return will null.enc
- Encoding to use while decoding the bytes.
public static char[] byteToChar(byte[] inbytes)
Note: This method is not safe for internationalization since it will use the default encoding of the machine it is running on.
inbytes
- Byte array of input if this is null the return will be null.
public static byte[] charToByte(char[] inchars)
Note: This method is not safe for internationalization since it will use the default encoding of the machine it is running on.
inchars
- Character array of input if this is null the return will be null.
public static byte[] charToByte(char[] carray, java.lang.String enc)
carray
- Character array of input if this is null the return will be null.
public static char[] toUpperCharArray(char[] carray)
carray
- Byte array of input if this is null the return will null.
public static byte[] toUpperByteArray(byte[] barray)
Note: This method is not safe for internationalization since it will use the default encoding of the machine it is running on.
barray
- Byte array of input if this is null the return will be null.
public static byte[] toUpperByteArray(byte[] barray, java.lang.String enc)
barray
- Byte array of input if this is null the return will be null.
public static java.lang.String truncateEncodedString(java.lang.String psz, java.lang.String encoding, int maxbytes) throws InvalidArgument
psz
- String to be truncated.encoding
- to be used to convert to equivalent byte array.maxbytes
- allowed in byte array before truncation.
InvalidArgument
- - thrown if
psz is null OR
encoding is null OR
maxbytes is negative OR
encoding is not validpublic static java.util.List decodeCommaString(java.lang.String src)
public static java.util.List decodeCommaString(java.lang.String src, boolean filterEmpty)
public static java.lang.String encodeCommaString(java.lang.Object list)
public static java.lang.String encodeCommaString(java.lang.Object list, boolean filterEmpty)
public static java.lang.String encodeCommaString(java.lang.Object o, boolean filterEmpty, boolean trailingSpace)
public static java.util.List decodeNewlineString(java.lang.String data, boolean filterEmpty)
public static java.lang.String encodeNewlineString(java.util.List values, boolean filterEmpty)
public static java.lang.String itoa(int i)
public static java.lang.String btoa(boolean b)
public static int getInt(java.lang.Object v)
Object
into an int
primitive.
public static int atoi(java.lang.String a)
public static int atoi(java.lang.String a, int def)
public static java.lang.String ltoa(long l)
public static long atol(java.lang.String a)
public static long atol(java.lang.String a, long def)
public static java.lang.String ftoa(float f)
public static float atof(java.lang.String a)
public static float atof(java.lang.String a, float def)
public static java.lang.String dtoa(double d)
public static double atod(java.lang.String a)
public static double atod(java.lang.String a, double def)
public static java.lang.String trimWhitespace(java.lang.String src)
public static java.lang.String lpad(java.lang.String str, int length)
isNumeric(String)
public static java.lang.String rpad(java.lang.String str, int length)
isNumeric(String)
public static java.lang.String lpad(java.lang.String str, int length, char padChar)
public static java.lang.String rpad(java.lang.String str, int length, char padChar)
public static java.lang.String pad(java.lang.String s, int len, char pad, boolean leftPad)
s
- - the input string to pad.len
- - pad to this length.pad
- - pad with this character.leftPad
- - if true, prepend pad characters; otherwise, append.
public static boolean isNumeric(java.lang.String s)
public static java.lang.String strstr(java.lang.String inString, java.lang.String delimiter)
public static boolean equalStrings(java.lang.String s1, java.lang.String s2)
s1
- s2
-
true
if s1 equals s2; otherwise false
.public static boolean equals(java.lang.Object o1, java.lang.Object o2)
o1
- o2
-
true
if o1 equals o2; otherwise false
.public static int strlen(java.lang.String inString)
public static java.lang.String format(double d, int decimalPlaces)
public static java.lang.String format(java.lang.String s, int decimalPlaces)
public static double roundTo(double d, int decimalPlaces)
public static int roundToInt(double d)
public static java.lang.String truncateAt(java.lang.String in, java.lang.String delim, int count)
public static java.lang.String midString(java.lang.StringBuffer in, char delim, int start, int count)
public static void escapeString(java.lang.StringBuffer b, java.lang.String s)
public static java.lang.String escapeNewlines(java.lang.String src)
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.
public static java.lang.String escapeSingleQuotes(java.lang.String src)
Ordinarily done if you want to store a string as a value in a relational database, where single-quotes delimit each value.
public static java.lang.String escapePoundSigns(java.lang.String src)
#
) character.
public static java.lang.String escapeForwardSlashes(java.lang.String src)
/
) character.
public static java.lang.String escapeCommas(java.lang.String src)
,
) character.
public static java.lang.String escape(java.lang.String src, char escapeThis, char prefixWith)
escapeThis
- - the target character to escapeprefixWith
- - character to insert before each targetpublic static java.net.URL buildFTPURL(java.lang.String host, java.lang.String port, java.lang.String path, java.lang.String user, EncryptedData password, java.lang.String type) throws WavesetException, java.net.MalformedURLException
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.
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.
WavesetException
java.net.MalformedURLException
public static java.lang.String rfc2396URLPieceEncode(java.lang.String s)
public static java.lang.String rfc2396URLPieceEncode(java.lang.String s, java.lang.String dontEncode)
public static java.lang.String URLEncode(java.lang.String s)
null strings will be returned null
public static java.lang.String URLDecode(java.lang.String s)
null strings will be returned null
public static java.lang.String ignoreCase(java.lang.String s)
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).
public static java.lang.String arrayToString(byte[] array)
public static java.lang.String arrayToString(boolean[] array)
public static java.lang.String arrayToString(long[] array)
public static java.lang.String arrayToString(java.lang.Object[] array)
public static java.lang.String[] stringToArray(java.lang.String s)
public static java.lang.String mapToString(java.util.Map map)
public static java.lang.String mapToString(java.util.Map map, java.lang.String separator)
public static int[] findClassName(java.lang.StringBuffer sb)
It must start with java chars, include at least one period, and end in ": ".
public static boolean matchSimpleWildcard(java.lang.String in, java.lang.String matchString)
public static java.lang.String strip(java.lang.Throwable th)
public static java.lang.String getBaseName(java.lang.Class c)
public static java.lang.String getBaseName(java.lang.String className)
public static java.lang.String getFileName(java.lang.String filePath)
public static java.lang.String stripClassName(java.lang.String in)
public static java.lang.String toString(java.lang.Object o)
public static java.lang.String toString(int i)
public static java.lang.String toString(long l)
public static java.lang.String toString(boolean b)
public static java.lang.String toString(char c)
public static java.lang.String convertValueToString(java.lang.Object value) throws WavesetException
WavesetException
public static void filterStringList(java.util.List list, java.lang.String regexp) throws java.lang.Exception
java.lang.Exception
public static java.util.ArrayList convertValuesToStringList(java.lang.Object value) throws WavesetException
WavesetException
public static boolean isASCIILetter(char in)
public static boolean isASCIILetterOrDigit(char in)
public static java.lang.String convertToJSName(java.lang.String in)
public static java.lang.String replaceChar(java.lang.String s, java.lang.String replaceMe, java.lang.String replaceWith)
public static boolean getBoolean(java.lang.Object 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.
public static boolean getBoolean(java.lang.Object value, boolean dflt)
public static long getLong(java.lang.Object v)
Object
value into a long
primitive.
public static byte[] readFileBytes(java.io.File file) throws IOException
IOException
public static byte[] readURLBytes(java.net.URL url) throws IOException
IOException
public static byte[] readURLBytesIfExists(java.net.URL url)
public static byte[] readInputStreamBytes(java.io.InputStream is, boolean close) throws IOException
close
- - if true, close when finished reading.
IOException
public static byte[] readFileBytes(java.lang.String name) throws IOException
IOException
public static java.lang.String readFile(java.lang.String name) throws IOException
IOException
public static java.lang.String readFile(java.io.File file) throws IOException
IOException
public static java.lang.String readInputStream(java.io.InputStream in) throws IOException
IOException
public static void writeFileUtf8(java.lang.String name, java.lang.String contents) throws IOException
IOException
public static java.lang.String readFileUtf8(java.io.File filename) throws IOException
IOException
public static java.lang.String readFileUtf8(java.lang.String filename) throws IOException
IOException
public static java.lang.String readFileUtf8(java.io.InputStream in) throws IOException
IOException
public static void writeFile(java.io.File file, java.lang.String contents) throws InvalidArgument, IOException
InvalidArgument
IOException
public static void writeFile(java.lang.String name, java.lang.String contents) throws IOException
IOException
public static void writeFile(java.lang.String name, byte[] contents) throws IOException
IOException
public static long appendFile(java.lang.String name, java.lang.String contents, long maxLength) throws WavesetException, IOException
WavesetException
IOException
public static long appendFile(java.lang.String name, java.lang.String contents) throws IOException
name
- - file name to log to. Created if des not existcontents
- - string to write out
IOException
public static int copyFile(java.lang.String src, java.lang.String dest) throws WavesetException, IOException
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.
WavesetException
IOException
public static int copyFileByBlockSize(java.io.InputStream fis, java.io.OutputStream fos, int bufferSize) throws java.io.IOException
Iterate over a fixed block size specified by bufferSize
java.io.IOException
public static int copyFile(java.io.InputStream fis, java.io.OutputStream fos) throws java.io.IOException
Iterate over a fixed block size.
java.io.IOException
public static boolean copyFile(java.io.InputStream fis, java.io.OutputStream fos, int max) throws java.io.IOException
java.io.IOException
public static int copyFile(java.io.Reader reader, java.io.Writer writer) throws java.io.IOException
Iterate over a fixed block size.
java.io.IOException
public static int copyFileByBlockSize(java.io.Reader reader, java.io.Writer writer, int bufferSize) throws java.io.IOException
Iterate over a fixed block size specified by bufferSize
java.io.IOException
public static boolean renameFileForBackup(java.io.File file)
public static boolean renameFileForBackup(java.lang.String path)
public static long checksum(java.lang.String fileName) throws java.io.IOException, java.io.FileNotFoundException
fileName
- - the path to the file on which to calculate
the checksum
java.io.IOException
java.io.FileNotFoundException
public static long checksum(java.io.File file) throws java.io.IOException, java.io.FileNotFoundException
java.io.IOException
java.io.FileNotFoundException
public static void putJarEntry(java.lang.String jarFileName, java.lang.String jarEntryName, boolean jarMustExist, boolean overwriteEntry) throws InvalidArgument, WavesetException
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.
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.
WavesetException
public static void putJarEntries(java.lang.String jarFileName, java.util.List entryNames, boolean jarMustExist, boolean overwriteEntry, boolean updateExistingJar) throws InvalidArgument, WavesetException
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.
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.
WavesetException
public static void createJarFile(java.io.File jarFile, java.io.File rootDir, java.util.List files) throws InvalidArgument, WavesetException
jarFile
- - target output archive file.rootDir
- - source directory containing the data files.files
- - a list of files to be placed in the jar file.
InvalidArgument
- thrown if one of the listed files is not beneath rootDir.
WavesetException
public static void expandJarFile(java.io.File jarFile, java.io.File rootDir) throws InvalidArgument, WavesetException
jarFile
- - the source archive file.rootDir
- - the target directory beneath which to place the files.
InvalidArgument
WavesetException
public static void expandJarFile(java.io.File jarFile, java.io.File rootDir, java.util.List entryNames) throws InvalidArgument, WavesetException
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.
InvalidArgument
WavesetException
public static java.util.List listClasses() throws java.lang.Exception
java.lang.Exception
public static java.util.List listClassesInZipFile(java.io.File file) throws java.lang.Exception
java.lang.Exception
public static java.util.List listClassesInDirectory(java.io.File dir) throws java.lang.Exception
java.lang.Exception
public static java.lang.String getClassNameFromZipPath(java.lang.String path)
public static java.lang.String getClassNameFromFilePath(java.lang.String path)
protected static java.lang.String getClassNameFromPath(java.lang.String path, java.lang.String separator)
public static java.util.List listAllFilenames(java.io.File dir, boolean relativeNames) throws java.lang.Exception
java.lang.Exception
protected static java.util.List listAllFilenames(java.io.File dir, boolean relativeNames, java.lang.String basepath) throws java.lang.Exception
java.lang.Exception
public static java.lang.String getMachineUser()
public static java.lang.String mangle(java.lang.String name) throws InternalError
InternalError
public static java.lang.String demangle(java.lang.String mangledName)
mangle(String)
public static java.lang.String replaceString(java.lang.String in, java.lang.String fromString, java.lang.String toString)
fromString
in the input string in
with toString
.public static java.util.List stringToList(java.lang.String s, java.lang.String delim)
s
- - the input stringdelim
- - the delimiter string
(NOTE: NOT as in StringTokenizer(s, delim)
.
Instead, the entire string is taken as the separator.)
public static java.util.List stringToList(java.lang.String s, java.lang.String delim, boolean trim)
s
- - the input stringdelim
- - 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.
public static java.util.List stringToList(java.lang.String s, java.lang.String delim, boolean trim, java.lang.String valWrapper)
s
- - the input stringdelim
- - 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).
public static java.util.List addToken(java.util.List list, java.lang.String token, boolean trim, java.lang.String valWrapper)
public static java.util.List commaDelimitedStringToList(java.lang.String cds)
cds
- - a string of tokens separated by commas.
Will not return any token that contains only white space.
public static java.lang.String listToCommaDelimitedString(java.util.List list)
list
- - a string of tokens separated by commas.
Will not return any token that contains only white space.
public static java.lang.String listToString(java.util.List list, java.lang.String delim)
list
- - the input listdelim
- - the delimiter string
public static java.lang.String listToString(java.util.List list, java.lang.String delim, int maxLen)
list
- - the input listdelim
- - the delimiter stringmaxLen
- - the maximum length of the resulting string.
public static java.lang.String listToString(java.util.List list, java.lang.String delim, int maxLen, java.lang.String valWrapper)
list
- - the input listdelim
- - the delimiter stringmaxLen
- - 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.)
public static java.lang.String normalizeString(java.lang.String str)
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.
public static java.lang.String dateToString()
public static java.lang.String dateToString(java.lang.String simpleDateFormatPattern)
public static java.lang.String dateToString(long timeMillis)
public static java.lang.String dateToString(long timeMillis, java.lang.String simpleDateFormatPattern)
public static java.lang.String getOldCanonicalDateString(java.util.Date date, boolean absoluteTimezone)
public static java.text.DateFormat getCanonicalDateFormat()
public static java.lang.String getCanonicalDateString(long timestamp)
public static java.lang.String getCanonicalDateString(java.util.Date date)
public static java.lang.String getCanonicalDateString(java.util.Date date, java.util.TimeZone timeZone)
public static java.lang.String getCanonicalDateStringOnly(java.util.Date date)
public static java.lang.String getCanonicalTimeStringOnly(java.util.Date date)
public static java.lang.String dateToString(java.util.Date date, java.lang.String simpleDateFormatPattern)
public static java.lang.String dateToString(java.util.Date src)
public static java.lang.String dateToString(java.util.Locale locale)
public static java.lang.String dateToString(java.util.Date src, java.util.Locale locale)
public static java.lang.String dateToString(long src_millis, java.util.Locale locale)
public static java.util.Date stringToDate(java.lang.String src, java.lang.String format) throws java.text.ParseException
java.text.ParseException
public static java.util.Date stringToDate(java.lang.String src, java.lang.String format, java.lang.String timeZone) throws java.text.ParseException
java.text.ParseException
public static java.util.Date stringToDate(java.lang.String src) throws java.text.ParseException
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)
java.text.ParseException
DATE_FORMAT_COMPACT
,
DATE_FORMAT_DEFAULT
,
DATE_FORMAT_MILLIS
public static java.util.Date getRelativeDate(int field, int amount)
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
public static java.util.Date getRelativeDate(int ord, int day, int mo)
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)
public static java.util.Date getRelativeDate(Util.TimePeriod period)
public static boolean dateEquals(java.util.Date date1, java.util.Date date2)
public static boolean dateAfter(java.util.Date date1, java.util.Date date2)
public static java.lang.String formatElapsedTime(long from, long to)
public static java.lang.String formatTimeInterval(long millis)
public static java.lang.String formatTimeInterval(long millis, int maxUnit, int granularity)
public static java.lang.StringBuffer sprintf(java.lang.String format, java.lang.String[] args)
public static void println()
public static void println(java.lang.Object o)
public static void print(java.lang.Object o)
public static void debug(java.lang.Object o)
Debug
or Trace
instead.
public static java.lang.String getWavesetHome()
NOTE: This string could be a file path or a URL.
getWavesetHomePathIfFile()
,
getWavesetHomeURL()
public static java.net.URL getWavesetHomeURL()
NOTE: This could be a file or a JAR (WARfile) URL.
getWavesetHomePathIfFile()
public static java.lang.String setWavesetHome(java.lang.String newValue)
public static java.net.URL getWavesetHomeURL(boolean ignoreAnyCached)
ignoreAnyCached
- re-read SystemProperty
Try (in the following order):
waveset.home
public static java.lang.String getWavesetHomePathIfFile()
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).
public static java.net.URL getWavesetConfigURL()
public static java.net.URL getResource(java.lang.String name) throws InvalidArgument
The call is delegated to the class loader for this class.
To get a URL for a Lighthouse application resource,
call getWavesetResource(String)
.
InvalidArgument
public static java.net.URL getWavesetResource(java.lang.String name) throws InvalidArgument, InternalError
name
- relative to the application docroot
(as specified by System Property waveset.home
).
InvalidArgument
- if name is null.
InternalError
- if waveset.home URL cannot be determined.public static java.lang.String readResource(java.net.URL resoUrl) throws InvalidArgument, IOException, InternalError
URL
as a String
.
InvalidArgument
IOException
InternalError
public static java.lang.String readWavesetResource(java.lang.String name) throws InvalidArgument, InternalError, IOException
getWavesetResource();
and
readResource();
.
InvalidArgument
InternalError
IOException
public static void writeResource(java.net.URL resoUrl, java.lang.String content) throws InvalidArgument, ConfigurationError, IOException
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.
InvalidArgument
- if either argument is null.
ConfigurationError
- if the resource is not writable.
IOException
- if an error occurs writing the resource.public static void writeWavesetResource(java.lang.String name, java.lang.String content) throws InvalidArgument, InternalError, ConfigurationError, IOException
getWavesetResource();
and
writeResource();
.
InvalidArgument
InternalError
ConfigurationError
IOException
public static java.lang.String getWavesetResourcePath(java.lang.String name) throws InvalidArgument, InternalError
getWavesetResource();
and
getResourcePath();
.
InvalidArgument
InternalError
public static java.lang.String getResourcePath(java.lang.String name)
name
- path to a resource file that can be found in the CLASSPATH.public static java.lang.String getResourcePath(java.net.URL res)
res
- the URL of a resource file.
public static boolean pathIsAbsolute(java.lang.String path)
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.
public static boolean pathIsRelative(java.lang.String path)
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.
public static boolean wavesetResourceExists(java.lang.String name) throws InvalidArgument, InternalError
getWavesetResource();
and
resourceExists();
.
InvalidArgument
- if specified name is null.
InternalError
- if waveset.home URL cannot be determined.public static boolean resourceExists(java.net.URL resoUrl)
true
if we can connect to the specified resource;
otherwise false
.public static java.io.File getWavesetResourceFile(java.lang.String name) throws InvalidArgument, InternalError, ConfigurationError
getWavesetResource();
and
getResourceFile();
.
InvalidArgument
InternalError
ConfigurationError
public static java.io.File getSavedObjectsDir() throws InvalidArgument, InternalError, ConfigurationError
InvalidArgument
InternalError
ConfigurationError
public static java.io.File getFontsDir() throws InvalidArgument, InternalError, ConfigurationError
InvalidArgument
InternalError
ConfigurationError
public static java.io.File getResourceFileIfFile(java.net.URL resoUrl) throws InvalidArgument
File
.
Return null
if the specified URL is not a file.
Call method getResourceFile(URL)
if the specified URL must be a file.
InvalidArgument
- if the specified URL is null.public static java.io.File getResourceFile(java.net.URL resoUrl) throws InvalidArgument, ConfigurationError
File
.
InvalidArgument
- if the specified URL is null.
ConfigurationError
- if the specified URL is not a file.
Call method getResourceFileIfFile(URL)
if the URL need not specify a file.
public static java.io.File getResourceFile(java.net.URL resoUrl, boolean mustExist) throws InvalidArgument, ConfigurationError
mustExist
- if true, the specified file must exist.
File
.
InvalidArgument
- if the specified URL is null.
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.
public static java.lang.String legalizeResourceName(java.lang.String resoName)
public static java.util.List listClassNamesMatching(java.lang.String baseName) throws InvalidArgument
InvalidArgument
public static java.util.jar.JarFile getLighthouseJar()
public static java.lang.String getClasspathDirectory(int idx)
public static java.util.List getClasspathList()
public static java.io.InputStream getInputStreamFromJar(java.lang.String jarfilename, java.lang.String entryName) throws java.lang.Exception
java.lang.Exception
public static java.lang.String getStringFromJar(java.lang.String jarfilename, java.lang.String entryName) throws java.lang.Exception
java.lang.Exception
public static java.lang.String findFile(java.lang.String property, java.lang.String name)
public static java.lang.String findFile(java.lang.String property, java.lang.String name, boolean searchClasspath)
property
- - a system property specifying a location to search.name
- - a path or path fragment.searchClasspath
- - if true, we next search the classpath.
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.
public static java.lang.String findFile(java.lang.String name)
public static java.lang.String findOutputFile(java.lang.String name)
public static java.lang.String getApplicationHome() throws WavesetException
WavesetException
public static void confirmDirectory(java.io.File dir) throws ConfigurationError
ConfigurationError
public static void confirmDirectory(java.io.File dir, boolean createIfMissing) throws ConfigurationError
ConfigurationError
public static java.lang.String checkDirectory(java.io.File dir, boolean createIfMissing)
public static void dumpProperties(java.io.PrintWriter out)
public static void dumpProperties()
public static java.lang.String dumpBytes(byte[] bytes)
bytes
- the bytes to print
public static java.lang.String dumpBytes(byte[] bytes, int len)
bytes
- the bytes to printlen
- the number of bytes in the array to print
public static java.lang.String dumpBytes(byte[] bytes, int start, int len)
bytes
- the bytes to printstart
- the index in the array to start printinglen
- the number of bytes in the array to print
public static java.util.HashMap hashtableToMap(java.util.Hashtable hash)
public static java.lang.String stringToHtmlComment(java.lang.String s)
public static java.lang.String stackToHtmlComment(java.lang.Throwable th)
public static java.lang.String stackToHtml(java.lang.Throwable th)
public static java.lang.String stackToString(java.lang.Throwable th)
public static java.lang.String topStackFrames(int num)
public static void printStackTrace()
public static java.lang.String[] addString(java.lang.String[] list, java.lang.String newString)
public static java.lang.String[] appendString(java.lang.String[] list, java.lang.String newString)
public static boolean containsAny(java.util.Collection containing, java.util.Collection query)
public static int indexOf(java.lang.Object[] objs, java.lang.Object obj)
public static boolean contains(java.lang.Object[] objs, java.lang.Object obj)
public static java.lang.String findIllegals(java.lang.String name, java.lang.String illegals)
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)
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 inoMask
- A SimpleDateFormat friendly format mask used to emit the time stamp inoTimezone
- The time zone the outputted time should be in
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)
dText
- The date to attempt to parsetText
- The time to attempt to parseformats
- A list of Strings that will become the SimpleDateFormat objects used to parse dText/tTextiTimezone
- What time zone the given time stamp is inoMask
- A SimpleDateFormat friendly format mask used to emit the time stamp inoTimezone
- The time zone the outputted time should be in
public static byte[] gzipCompress(byte[] inbytes) throws WavesetException
WavesetException
public static byte[] gzipDecompress(byte[] inbytes, int size) throws WavesetException
WavesetException
public static byte[] gzipDecompress(byte[] inBytes) throws WavesetException
inBytes
-
WavesetException
- on IOException. The underlying IOException
is wrapped by the WavesetException.public static java.lang.String compressToString(java.io.Serializable obj)
public static java.io.Serializable uncompressFromString(java.lang.String str)
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
public static java.util.List sortList(java.util.List list)
public static java.lang.String getLocalizedString(java.util.Locale locale, java.lang.Object value)
public static java.util.HashMap getAttributeMap(java.lang.String attrString)
public static java.util.Date getDecrementedDate(java.lang.String numLogin)
public static java.io.File getApplicationDataDirectory()
public static boolean isWindows()
public static boolean copyFile(java.io.File src, java.io.File dest) throws java.io.IOException
src
- The source must be a filedest
- This can be a directory or a file.
java.io.IOException
public static java.lang.String generateGUID()
public static boolean arrayEquals(java.lang.Object[] arr1, java.lang.Object[] arr2)
public static java.lang.String mapName(java.util.Locale locale, java.lang.String prefix, java.lang.String name)
name
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |