public class Misc
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static boolean |
debug
debug flag
|
static java.lang.String |
MISSING
missing string
|
static java.lang.String |
NaN
NaN string
|
Constructor and Description |
---|
Misc()
Default constructor; does nothing
|
Modifier and Type | Method and Description |
---|---|
static float[][] |
addArray(float[][] a,
float[][] b,
float[][] c)
Add two arrays together
|
static void |
addClassLoader(java.lang.ClassLoader cl)
Add the given class loader into the list of custom class loaders
|
static java.util.List |
addUnique(java.util.List dest,
java.util.List src,
java.util.Hashtable seen)
Adds all of the elements held by src into the dest list
if they are not held in the seen Hashtable.
|
static boolean |
allStrings(java.util.List listToCheck)
Is the given List a list of String objects.
|
static java.lang.StringBuffer |
append(java.lang.StringBuffer sb,
java.lang.Object s1)
Deprecated.
See StringUtil
|
static java.lang.StringBuffer |
append(java.lang.StringBuffer sb,
java.lang.Object s1,
java.lang.Object s2)
Deprecated.
See StringUtil
|
static java.lang.StringBuffer |
append(java.lang.StringBuffer sb,
java.lang.Object s1,
java.lang.Object s2,
java.lang.Object s3)
Deprecated.
See StringUtil
|
static java.lang.StringBuffer |
append(java.lang.StringBuffer sb,
java.lang.Object s1,
java.lang.Object s2,
java.lang.Object s3,
java.lang.Object s4)
Deprecated.
See StringUtil
|
static java.lang.StringBuffer |
append(java.lang.StringBuffer sb,
java.lang.Object s1,
java.lang.Object s2,
java.lang.Object s3,
java.lang.Object s4,
java.lang.Object s5)
Deprecated.
See StringUtil
|
static java.lang.String |
appendUrlArgs(java.lang.String base,
java.lang.String[] args)
Create a url argument String with the given args.
|
static java.lang.String |
appendUrlArgs(java.lang.String base,
java.lang.String[] args,
boolean addQuestionMark)
Create a url argument String with the given args.
|
static boolean |
arraysEquals(double[][] a,
double[][] b)
check for equality a or b can be null;
|
static boolean |
arraysEquals(double[] a,
double[] b)
check for equality a or b can be null;
|
static boolean |
arraysEquals(float[][] a,
float[][] b)
check for equality a or b can be null;
|
static boolean |
arraysEquals(float[] a,
float[] b)
check for equality a or b can be null;
|
static boolean |
arraysEquals(int[][][] a,
int[][][] b)
check for equality a or b can be null;
|
static boolean |
arraysEquals(int[][] a,
int[][] b)
check for equality a or b can be null;
|
static boolean |
arraysEquals(int[] a,
int[] b)
check for equality a or b can be null;
|
static boolean |
arraysEquals(java.lang.String[] a,
java.lang.String[] b)
check for equality a or b can be null;
|
static double[] |
arrayToDouble(float[] d)
convert float array to double array
|
static java.lang.String |
breakText(java.lang.String text,
java.lang.String insert,
int lineSize)
Deprecated.
See StringUtil
|
static java.lang.String |
cleanFileName(java.lang.String name)
Deprecated.
Use IOUtil
|
static double[][] |
cloneArray(double[][] a)
Clone an array of doubles
|
static float[][] |
cloneArray(float[][] a)
Clone an array of floats
|
static java.util.List |
cloneList(java.util.List sourceList)
Utility to create a new list or handle a null argument gracefully.
|
static double[] |
computeTicks(double high,
double low,
double base,
double interval)
Compute the tick mark values based on the input.
|
static float[] |
computeTicks(float high,
float low,
float base,
float interval)
Compute the tick mark values based on the input.
|
static double |
computeTickSpacing(double min,
double max)
Calculate a good spacing interval for labels, contours based
on the range of the data.
|
static boolean |
contains(java.lang.Object object,
java.lang.Object[] array)
Does the given array contain the given object.
|
static boolean |
containsRegExp(java.lang.String patternString)
Deprecated.
See StringUtil
|
static boolean |
containsString(java.lang.String string,
java.util.List objects,
boolean lowerCase)
Does the the list contain the string
|
static float[][] |
copy(float[][] pts,
int pointCnt)
Copy an array to another
|
static void |
copyFile(java.io.File from,
java.io.File to)
Deprecated.
Use IOUtil
|
static java.util.List |
createIntervalList(int start,
int end,
int step)
Create and return a List that holds Integers starting at start
to end by step.
|
static java.util.Hashtable |
createLabelTable(double max,
double min,
double base,
double increment)
Creates a hashtable that will draw text labels starting at the
starting point specified using the increment field.
|
static double |
decodeLatLon(java.lang.String latlon)
Decodes a string representation of a latitude or longitude and
returns a double version (in degrees).
|
static void |
deleteDirectory(java.io.File root)
Deprecated.
Use IOUtil
|
static java.lang.Object |
deserialize(byte[] bytes)
Deserialize the given byte array into an object
|
static java.lang.String |
doPost(java.lang.String action,
java.lang.String data)
Post the form data
|
static java.lang.String |
doPost(java.lang.String action,
java.lang.String data,
java.lang.String[] attrs)
Post the form data
|
static java.lang.Object[] |
doPostAndGetConnection(java.lang.String action,
java.lang.String data)
Do an http post with the given action, writing the given data
as the post data.
|
static java.lang.Object[] |
doPostAndGetConnection(java.lang.String action,
java.lang.String data,
java.lang.String[] attrs)
Do an http post with the given action, writing the given data
as the post data.
|
static boolean |
equals(java.lang.Object o1,
java.lang.Object o2)
Does an o1.equals (o2) if both objects are non-null.
|
static boolean |
equalsIgnoreCase(java.lang.Object o1,
java.lang.Object o2)
Compares two object-s toString() methods to see if they are
equal, ignoring case.
|
static float[][] |
expand(float[][] pts)
Expand an array of points
|
static void |
fatal(java.lang.String msg)
Utility method to print an error and exit
|
static void |
fatal(java.lang.Throwable exc)
Utility method to print an exception and exit
|
static void |
fillArray(float[][] a,
float value)
fill array with value
|
static int[] |
find(double value,
double[] array)
Find the indices of the array where it is equal to the value
|
static int[] |
find(float value,
float[] array)
Find the indices of the array where it is equal to the value
|
static int[] |
find(int value,
int[] array)
Find the indices of the array where it is equal to the value
|
static java.lang.Class |
findClass(java.lang.String className)
Find the Class for the given class name.
|
static java.lang.reflect.Constructor |
findConstructor(java.lang.Class c,
java.lang.Class[] paramTypes)
Find all constructors of the given class
Of these methods find one whose parameter types
are assignable from the given parameter types.
|
static java.lang.Object |
findMatch(java.lang.String source,
java.util.List patternList,
java.util.List results,
java.lang.Object dflt)
Deprecated.
See StringUtil
|
static java.lang.Object |
findMatch(java.lang.String source,
java.util.List patternList,
java.lang.Object dflt)
Deprecated.
See StringUtil
|
static java.lang.reflect.Method |
findMethod(java.lang.Class c,
java.lang.String methodName,
java.lang.Class[] paramTypes)
Find all methods with the given name.
|
static java.lang.String |
format(double value)
Provide a consistent String formatting of the given double value
|
static java.lang.String |
formatLatitude(double value,
java.lang.String format)
Format a latitude to the given format.
|
static java.lang.String |
formatLatOrLon(double value,
java.lang.String format,
boolean isLatitude,
boolean use360)
Format a latitude or longitude value to the given format.
|
static java.lang.String |
formatLongitude(double value,
java.lang.String format,
boolean use360)
Format a longitude to the given format.
|
static long |
gc()
Run the garbage collector.
|
static float |
getAverage(float[] values)
Average the array.
|
static boolean |
getBoolean(java.lang.String stringValue,
boolean dflt)
Try to decode the given stringValue as an boolean.
|
static java.util.List<java.lang.ClassLoader> |
getClassLoaders()
Get the list of dynamic class loaders
|
static java.lang.String |
getClassMethod(java.lang.String path)
Utility method that returns the ClassName.methodName part of the
(possibly) full package.ClassName.methodName path.
|
static java.lang.String |
getClassName(java.lang.Class c)
Return the end part of the class name
|
static long |
getCurrentTime()
Get the current time
|
static java.text.DecimalFormat |
getDecimalFormat(double v)
Return different pre-defined DecimalFormat objects depending
on the value of the given double
|
static java.util.List |
getDirectories(java.io.File dir,
boolean recurse)
Deprecated.
Use IOUtil
|
static java.util.List |
getDirectories(java.util.List dirs,
boolean recurse)
Deprecated.
Use IOUtil
|
static java.lang.String |
getFileExtension(java.lang.String f)
Deprecated.
Use IOUtil
|
static java.lang.String |
getFileRoot(java.lang.String f)
Deprecated.
Use IOUtil
|
static java.lang.String |
getFileTail(java.lang.String f)
Deprecated.
Use IOUtil
|
static java.util.List |
getIndexList(java.util.List values,
java.util.List allValues)
Return a list of Integer indexes, the indexes that each value
object is in the all values list.
|
static java.io.InputStream |
getInputStream(java.lang.String filename)
Deprecated.
Use IOUtil
|
static java.io.InputStream |
getInputStream(java.lang.String filename,
java.lang.Class origin)
Deprecated.
Use IOUtil
|
static int |
getInt(java.lang.String stringValue,
int dflt)
Try to decode the given stringValue as an integer.
|
static java.lang.Object |
getLast(java.util.List l)
Return the last object in the given list or null if the list is empty.
|
static java.io.File |
getMostRecentFile(java.io.File dir)
Deprecated.
Use IOUtil
|
static java.io.File |
getMostRecentFile(java.io.File dir,
java.io.FileFilter filter)
Deprecated.
Use IOUtil
|
static java.io.File |
getMostRecentFile(java.io.File dir,
javax.swing.filechooser.FileFilter filter)
Deprecated.
Use IOUtil
|
static long |
getPauseEveryTime(int minutesDelta)
figure out how long to wait for
|
static boolean |
getProperty(java.util.Hashtable props,
java.lang.String prop,
boolean dflt)
Look up the prop in the given set of Hashtable.
|
static java.awt.Color |
getProperty(java.util.Hashtable props,
java.lang.String prop,
java.awt.Color dflt)
Look up the prop in the given set of properties.
|
static double |
getProperty(java.util.Hashtable props,
java.lang.String prop,
double dflt)
get a double property from the props table
|
static float |
getProperty(java.util.Hashtable props,
java.lang.String prop,
float dflt)
Look up the prop in the given set of Hashtable.
|
static int |
getProperty(java.util.Hashtable props,
java.lang.String prop,
int dflt)
Look up the prop in the given set of Hashtable.
|
static java.lang.String |
getProperty(java.util.Hashtable p,
java.lang.String prop,
java.lang.String dflt)
Look up the String prop in the given set of properties.
|
static PrototypeManager |
getPrototypeManager()
Get the prototype manager
|
static float[] |
getRange(float[][] a)
Get the range of all values
|
static float[][] |
getRanges(float[][] a)
Get the ranges for each column
|
static java.lang.Runnable |
getRunnable()
Get a Runnable object
|
static java.lang.String |
getSetterMethod(java.lang.String prop)
For the given property name get the set method name, e.g., returns:
|
static java.lang.String |
getStackTrace()
Return the stack trace of this calling thread
|
static java.lang.String |
getStackTrace(java.lang.Throwable exc)
Get the stack trace from the given exception
|
static java.lang.String |
getSystemProperty(java.lang.String key,
java.lang.String dflt)
Read the given system property.
|
static java.lang.String |
getUniqueId()
Gets a (sort of) unique String identifier.
|
static java.net.URL |
getURL(java.lang.String name,
java.lang.Class origin)
Find the url with the given name as a resource relative to the given
class.
|
static java.lang.String |
getValue(java.lang.String key,
java.util.Hashtable props)
Looks up the named value in the props hashtable.
|
static java.util.List |
getValuesFromIndices(java.util.List indices,
java.util.List allValues)
Return a list of objects from the allValues list that are at the
indices contained by the given indices list.
|
static int |
hashcode(java.lang.Object o1)
Return the hashcode for the object.
|
static boolean |
hasSuffix(java.lang.String fileOrUrl,
java.lang.String suffix)
Does the given file or url have the given suffix
|
static boolean |
haveNotSeen(java.lang.Object o,
java.util.Hashtable map)
The inverse of haveSeen
|
static boolean |
haveSeen(java.lang.Object o,
java.util.Hashtable map)
Checks to see if the object o is in the given Hashtable.
|
static int |
indexOf(java.lang.Object object,
java.lang.Object[] array)
What is the index of the given object
|
static float[] |
interpolate(int cnt,
float start,
float end)
Do a linear interpolation with cnt points between start and end
|
static boolean |
isHtml(java.lang.String s)
See if the string is HTML.
|
static boolean |
isHtmlFile(java.lang.String filenameOrUrl)
Deprecated.
Use IOUtil
|
static boolean |
isImageFile(java.lang.String filename)
Deprecated.
Use IOUtil
|
static boolean |
isNaN(double[][] values)
Check if all the values in the array are NaNs
|
static boolean |
isNaN(float[][] values)
Check if all the values in the array are NaNs
|
static boolean |
isTextFile(java.lang.String filename)
Deprecated.
Use IOUtil
|
static java.lang.String |
join(java.lang.String[] args)
Deprecated.
See StringUtil
|
static java.lang.String |
join(java.lang.String delimiter,
java.util.List args)
Deprecated.
See StringUtil
|
static java.lang.String |
join(java.lang.String delimiter,
java.util.List args,
boolean ignoreEmptyStrings)
Deprecated.
See StringUtil
|
static java.lang.String |
join(java.lang.String delimiter,
java.lang.Object[] args)
Deprecated.
See StringUtil
|
static java.lang.String |
join(java.lang.String delimiter,
java.lang.Object[] args,
boolean ignoreEmptyStrings)
Deprecated.
See StringUtil
|
static java.lang.String |
joinDir(java.io.File f1,
java.lang.String filename)
Deprecated.
Use IOUtil
|
static java.lang.String |
joinDir(java.lang.String f1,
java.lang.String f2)
Deprecated.
Use IOUtil
|
static java.lang.String |
listToString(java.util.List l)
Deprecated.
See StringUtil
|
static java.lang.String[] |
listToStringArray(java.util.List objectList)
Deprecated.
See StringUtil
|
static void |
main(java.lang.String[] args)
Test this class
|
static java.lang.String |
makeDir(java.io.File f)
Deprecated.
Use IOUtil
|
static java.lang.String |
makeDir(java.lang.String path)
Deprecated.
Use IOUtil
|
static <E> java.util.List<E> |
makeUnique(java.util.List<E> l)
Make the list unique.
|
static java.lang.String |
makeUrl(java.lang.String protocol,
java.lang.String server,
java.lang.String urlRoot,
java.lang.String[] args)
Create a URL String with the given protocol, server, url and url
arguments.
|
static float[] |
merge(float[] a,
float[] b)
Merge the two arrays into one.
|
static void |
moveFile(java.io.File from,
java.io.File to)
Deprecated.
Use IOUtil
|
static java.util.Hashtable |
newHashtable(java.util.Hashtable ht,
java.lang.Object[] o)
Create a Hashtable.
|
static java.util.Hashtable |
newHashtable(java.lang.Object[] o)
Create a new Hashtable.
|
static java.util.Hashtable |
newHashtable(java.lang.Object[] keys,
java.lang.Object[] values)
Create a Hashtable and add the given keys and their
corresponding values into it.
|
static java.util.Hashtable |
newHashtable(java.lang.Object key1,
java.lang.Object value1)
Create a Hashtable and add the given keys and their corresponding
values into it.
|
static java.util.Hashtable |
newHashtable(java.lang.Object key1,
java.lang.Object value1,
java.lang.Object key2,
java.lang.Object value2)
Create a Hashtable and add the given keys and their corresponding
values into it.
|
static java.util.Hashtable |
newHashtable(java.lang.Object key1,
java.lang.Object value1,
java.lang.Object key2,
java.lang.Object value2,
java.lang.Object key3,
java.lang.Object value3)
Create a Hashtable and add the given keys and their corresponding
values into it.
|
static java.util.List |
newList(java.lang.Object o1)
Create a List and add the argument to it.
|
static java.util.List |
newList(java.lang.Object[] l)
Copy the objects with the given objectArray into a new List.
|
static java.util.List |
newList(java.lang.Object o1,
java.lang.Object o2)
Create a List and add the arguments to it.
|
static java.util.List |
newList(java.lang.Object o1,
java.lang.Object o2,
java.lang.Object o3)
Create a List and add the arguments to it.
|
static java.util.List |
newList(java.lang.Object o1,
java.lang.Object o2,
java.lang.Object o3,
java.lang.Object o4)
Create a List and add the arguments to it.
|
static java.util.List |
newList(java.lang.Object o1,
java.lang.Object o2,
java.lang.Object o3,
java.lang.Object o4,
java.lang.Object o5)
Create a List and add the arguments to it.
|
static java.util.List |
newList(java.lang.Object o1,
java.lang.Object o2,
java.lang.Object o3,
java.lang.Object o4,
java.lang.Object o5,
java.lang.Object o6)
Create a List and add the arguments to it.
|
static java.util.List |
newList(java.lang.Object o1,
java.lang.Object o2,
java.lang.Object o3,
java.lang.Object o4,
java.lang.Object o5,
java.lang.Object o6,
java.lang.Object o7)
Create a List and add the arguments to it.
|
static double |
normalizeLongitude(double lonValue)
Normalize a longitude value to the range between -180 and 180.
|
static java.lang.String |
padLeft(java.lang.String s,
int desiredLength)
Deprecated.
See StringUtil
|
static java.lang.String |
padLeft(java.lang.String s,
int desiredLength,
java.lang.String padString)
Deprecated.
See StringUtil
|
static java.lang.String |
padRight(java.lang.String s,
int desiredLength)
Deprecated.
See StringUtil
|
static java.lang.String |
padRight(java.lang.String s,
int desiredLength,
java.lang.String padString)
Deprecated.
See StringUtil
|
static java.lang.String |
padZero(int value,
int numDigits)
Deprecated.
See StringUtil
|
static java.util.List |
parseCsv(java.lang.String s,
boolean skipFirst)
Deprecated.
See StringUtil
|
static double |
parseDouble(java.lang.String s)
Parse the double value specified by the string s.
|
static double[] |
parseDoubles(java.lang.String sourceString)
The given sourceString is a comma separated list of values, this method
parses this String, converting it into an array of doubles.
|
static double[] |
parseDoubles(java.lang.String sourceString,
java.lang.String delimiter)
The given sourceString is a
delimiter separated list
of doubles. |
static float |
parseFloat(java.lang.String s)
Parse the float value specified by the string s.
|
static float[] |
parseFloats(java.lang.String sourceString)
The given sourceString is a comma separated list of values, this method
parses this String, converting it into an array of floats.
|
static float[] |
parseFloats(java.lang.String sourceString,
java.lang.String delimiter)
The given sourceString is a
delimiter separated list
of doubles. |
static int[] |
parseInts(java.lang.String sourceString,
java.lang.String delimiter)
The given sourceString is a
delimiter separated list
of doubles. |
static double[] |
parseLatLons(java.lang.String sourceString)
The given sourceString is a comma separated list of lat or lon values,
this method parses this String, converting it into an array of doubles.
|
static double[] |
parseLatLons(java.lang.String sourceString,
java.lang.String delimiter)
The given sourceString is a
delimiter separated list
of lats or lons. |
static java.util.List |
parseLineWords(java.lang.String content,
int[] indices,
int[] lengths,
java.lang.String lineDelimiter,
java.lang.String commentString,
boolean trimWords)
Deprecated.
See StringUtil
|
static double |
parseNumber(java.lang.String value)
Provide a consistent parsing that takes into account localization
of the String format of the given numeric value
|
static java.util.Properties |
parseProperties(java.lang.String propString)
Create a Properties table from the given semi-colon delimited attribute
string.
|
static java.util.Properties |
parseProperties(java.lang.String propString,
java.lang.String delimiter)
Create a Properties table from the given semi-colon delimited attribute
string.
|
static double |
parseValue(java.lang.String value)
Deprecated.
replaced by
parseNumber(String) |
static void |
pauseEvery(int minutesDelta)
Pause every n minutes
|
static void |
print(java.util.List l)
A method for printing a list.
|
static void |
printArray(java.lang.String prefix,
boolean[] array)
Print out the values in a boolean array.
|
static void |
printArray(java.lang.String prefix,
byte[] array)
Print out the values in an int array.
|
static void |
printArray(java.lang.String prefix,
double[] array)
Print out the values in a double array.
|
static void |
printArray(java.lang.String prefix,
float[] array)
Print out the values in a float array.
|
static void |
printArray(java.lang.String prefix,
int[] array)
Print out the values in an int array.
|
static void |
printArray(java.lang.String prefix,
java.lang.Object[] array)
Print out the values in an int array.
|
static void |
printBits(int b)
Print out the bit pattern in an integer
|
static void |
printMembers(java.lang.Object o)
Print the members of an Object
|
static void |
printStack(java.lang.String msg)
Print the stack trace for a given line of code.
|
static void |
printStack(java.lang.String msg,
int maxLines)
Print the stack trace for a given line of code.
|
static void |
printStack(java.lang.String msg,
int maxLines,
java.lang.String onlyIfTraceContainsThisString)
Print the stack trace for a given line of code.
|
static void |
propertySet(java.lang.Object object,
java.lang.String name,
java.lang.String value)
Use reflection to find the Method with name "set" + Name.
|
static boolean |
propertySet(java.lang.Object object,
java.lang.String name,
java.lang.String value,
boolean ignoreError)
Use reflection to find the Method with name "set" + Name.
|
static void |
pruneEmptyDirectories(java.io.File root)
Deprecated.
Use IOUtil
|
static byte[] |
readBytes(java.io.InputStream is)
Deprecated.
Use IOUtil
|
static byte[] |
readBytes(java.io.InputStream is,
java.lang.Object loadId)
Deprecated.
Use IOUtil
|
static java.lang.String |
readContents(java.io.File file)
Deprecated.
Use IOUtil
|
static java.lang.String |
readContents(java.io.InputStream is)
Deprecated.
Use IOUtil
|
static java.lang.String |
readContents(java.lang.String contentName)
Deprecated.
Use IOUtil
|
static java.lang.String |
readContents(java.lang.String contentName,
java.lang.Class origin)
Deprecated.
Use IOUtil
|
static java.lang.String |
readContents(java.lang.String contentName,
java.lang.String dflt)
Deprecated.
Use IOUtil
|
static java.lang.String |
readFile(java.lang.String filename,
java.lang.Class origin)
Deprecated.
Use IOUtil
|
static java.lang.String |
readFile(java.lang.String filename,
java.lang.Class origin,
java.lang.String dflt)
Deprecated.
Use IOUtil
|
static java.util.Properties |
readProperties(java.lang.String filename,
java.util.Properties properties,
java.lang.Class origin)
Read the given property filename, defined in relation to the given Class.
|
static void |
removeLast(java.util.List l)
Remove the last element in the given list.
|
static java.lang.String |
removeWhitespace(java.lang.String inputString)
Deprecated.
See StringUtil
|
static java.lang.String |
replace(java.lang.String string,
java.lang.String pattern,
java.lang.String value)
Deprecated.
See StringUtil
|
static java.util.List |
replaceList(java.util.List sourceList,
java.lang.String[] patterns,
java.lang.String[] values)
Deprecated.
See StringUtil
|
static java.lang.String |
replaceList(java.lang.String v,
java.util.List patterns,
java.util.List values)
Deprecated.
See StringUtil
|
static java.lang.String |
replaceList(java.lang.String v,
java.lang.String[] patterns,
java.lang.String[] values)
Deprecated.
See StringUtil
|
static float[] |
reverseArray(float[] a)
Reverse the array
|
static java.lang.Object[] |
reverseArray(java.lang.Object[] fromArray,
java.lang.Object[] toArray)
Reverse an array
|
static java.util.List |
reverseList(java.util.List l)
Reverse an array
|
static void |
run(java.lang.Object object,
java.lang.String methodName)
Call object.runMethod in a different thread
|
static void |
run(java.lang.Object object,
java.lang.String methodName,
java.lang.Object arg)
Call object.runMethod in a different thread.
|
static void |
run(java.lang.Runnable r)
Run the
Runnable . |
static void |
runInABit(long ms,
java.lang.Object object,
java.lang.String methodName,
java.lang.Object arg)
Call object.runMethod in a different thread after a ms millisecond delay
|
static void |
runInABit(long ms,
java.lang.Runnable r)
Call r.run () in a different thread after a ms millisecond delay
|
static java.lang.Object |
safeGet(java.util.List l,
int index)
Utility to do a list get only if the index is ok.
|
static byte[] |
serialize(java.io.Serializable object)
Serialize the given object into its byte array form
|
static void |
setCurrentTime(java.util.Date date)
Set the current time
|
static boolean |
setProperty(java.lang.Object object,
java.lang.reflect.Method method,
java.lang.Object objectValue,
boolean ignoreError)
Set a property on a "bean"
|
static boolean |
setProperty(java.lang.Object object,
java.lang.String name,
java.lang.Object objectValue,
boolean ignoreError)
Set a property on a "bean"
|
static void |
setPrototypeManager(PrototypeManager prototypeManager)
Set the global prototype manager.
|
static java.lang.String |
shorten(java.lang.String s,
int length)
Deprecated.
See StringUtil
|
static void |
sleep(long ms)
Pause the current Thread for a specific number of milliseconds.
|
static void |
sleepSeconds(long seconds)
Pause the current Thread for a specific number of seconds.
|
static java.util.List |
sort(java.util.Collection listToSort)
Sort the given List.
|
static java.io.File[] |
sortFilesOnAge(java.io.File[] files,
boolean youngestFirst)
Deprecated.
Use IOUtil
|
static java.io.File[] |
sortFilesOnAge(java.io.File directory,
java.io.FileFilter filter,
boolean youngestFirst)
Deprecated.
Use IOUtil
|
static java.util.List |
sortTuples(java.util.List pairs,
boolean ascending)
The elements in the given list object arrays.
|
static java.util.List |
split(java.lang.Object source)
Deprecated.
See StringUtil
|
static java.util.List |
split(java.lang.Object source,
java.lang.String delimiter)
Deprecated.
See StringUtil
|
static java.util.List |
split(java.lang.Object source,
java.lang.String delimiter,
boolean trim)
Deprecated.
See StringUtil
|
static java.util.List |
split(java.lang.Object source,
java.lang.String delimiter,
boolean trim,
boolean excludeZeroLength)
Deprecated.
See StringUtil
|
static java.lang.String[] |
split(java.lang.String s,
java.lang.String delimiter,
int cnt)
Deprecated.
See StringUtil
|
static boolean |
startsWithVowel(java.lang.String value)
Deprecated.
See StringUtil
|
static boolean |
stringMatch(java.lang.String input,
java.lang.String patternString)
Deprecated.
See StringUtil
|
static boolean |
stringMatch(java.lang.String input,
java.lang.String patternString,
boolean substring,
boolean caseSensitive)
Deprecated.
See StringUtil
|
static java.lang.String |
stripExtension(java.lang.String f)
Deprecated.
Use IOUtil
|
static java.lang.String |
stripTags(java.lang.String html)
Deprecated.
See StringUtil
|
static float[][] |
subtractArray(float[][] a,
float[][] b,
float[][] c)
Set c=a-b and return c.
|
static double[] |
toDouble(float[] d)
Convert double array to float array
|
static double[][] |
toDouble(float[][] d)
Convert to float
|
static double[] |
toDouble(int[] d)
Convert int array to double array
|
static double[][] |
toDouble(int[][] d)
Convert int array to double array
|
static double |
toDouble(java.lang.Object o)
A method for converting an object to a Double.
|
static java.io.File[] |
toFiles(java.util.List files)
Deprecated.
Use IOUtil
|
static float[] |
toFloat(double[] d)
Convert double array to float array
|
static float[][] |
toFloat(double[][] d)
Convert to float
|
static java.util.List |
toList(java.util.Enumeration enumeration)
Create a list from an enumeration
|
static java.util.List |
toList(java.lang.Object[] l)
Copy the objects with the given objectArray into a new List.
|
static java.util.List |
toString(java.util.List l)
Deprecated.
See StringUtil
|
static java.lang.String |
toString(java.lang.Object[] array)
Deprecated.
See StringUtil
|
static java.util.Vector |
toVector(java.lang.Object[] objectArray)
Copy the objects with the given objectArray into a new Vector.
|
static boolean |
typesMatch(java.lang.Class[] formals,
java.lang.Class[] actuals)
Returns true if the Classes defined in the actual parameter
are equal or a sub-class of the corresponding classes defined in the
formal argument.
|
static boolean |
typesMatchx(java.lang.Class[] formals,
java.lang.Class[] actuals)
dummy
|
static long |
usedMemory()
Get the amount of used memory
|
static java.io.FileFilter |
wrapFilter(javax.swing.filechooser.FileFilter filter)
Deprecated.
Use IOUtil
|
static void |
writeBytes(java.io.File filename,
byte[] contents)
Deprecated.
Use IOUtil
|
static void |
writeFile(java.io.File filename,
java.lang.String contents)
Deprecated.
Use IOUtil
|
static void |
writeFile(java.lang.String filename,
java.lang.String contents)
Deprecated.
Use IOUtil
|
static java.lang.String |
zeroString(int value)
Deprecated.
See StringUtil
|
public static boolean debug
public static final java.lang.String MISSING
public static final java.lang.String NaN
public static void setPrototypeManager(PrototypeManager prototypeManager)
prototypeManager
- The prototype managerpublic static PrototypeManager getPrototypeManager()
public static long getCurrentTime()
public static void setCurrentTime(java.util.Date date)
date
- the date to usepublic static double toDouble(java.lang.Object o)
parseNumber(String)
instead.o
- object in questionpublic static java.lang.String formatLatitude(double value, java.lang.String format)
value
- the value to formatformat
- the formatformatLatOrLon(double, String, boolean, boolean)
public static java.lang.String formatLongitude(double value, java.lang.String format, boolean use360)
value
- the value to formatformat
- the formatuse360
- if true use 0-360 notation instead of -180 to 180 notationformatLatOrLon(double, String, boolean, boolean)
public static java.lang.String formatLatOrLon(double value, java.lang.String format, boolean isLatitude, boolean use360)
Examples for value -34.496 degrees DD:MM:SS ===> -34:29:45 (if longitude and use360 ===> 326:29:45) DDH ===> 34W (or 34S if longitude) DD.d ===> -34.5 DD.dddH ===> 34.496W (or 34.496S if longitude) DD MM" SS.s' ===> -34 29" 45.6'
value
- the value to formatformat
- the formatisLatitude
- true if latitude, false if longitudeuse360
- if true use 0-360 notation instead of -180 to 180 notationpublic static double decodeLatLon(java.lang.String latlon)
+/- DDD:MM, DDD:MM:, DDD:MM:SS, DDD::SS, DDD.ddddd ===> [+/-] DDD.ddddd +/- DDD, DDD:, DDD:: ===> [+/-] DDD +/- :MM, :MM:, :MM:SS, ::SS, .ddddd ===> [+/-] .ddddd +/- :, :: ===> 0.0 Any of the above with N,S,E,W appended
latlon
- string representation of lat or lonpublic static java.util.List reverseList(java.util.List l)
l
- The listpublic static java.lang.Object[] reverseArray(java.lang.Object[] fromArray, java.lang.Object[] toArray)
fromArray
- array to reversetoArray
- reversed arraypublic static java.lang.String getClassName(java.lang.Class c)
c
- The classpublic static void propertySet(java.lang.Object object, java.lang.String name, java.lang.String value) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException
object
- The object to invoke the set property method on.name
- The name of the method.value
- The Strign representation of the value to set.java.lang.IllegalAccessException
java.lang.IllegalArgumentException
java.lang.reflect.InvocationTargetException
public static boolean propertySet(java.lang.Object object, java.lang.String name, java.lang.String value, boolean ignoreError) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException
object
- The object to invoke the set property method on.name
- The name of the method.value
- The String representation of the value to set.ignoreError
- If true then don't print out an errorjava.lang.IllegalAccessException
java.lang.IllegalArgumentException
java.lang.reflect.InvocationTargetException
public static java.lang.String getSetterMethod(java.lang.String prop)
setPropertname
prop
- property namepublic static boolean setProperty(java.lang.Object object, java.lang.String name, java.lang.Object objectValue, boolean ignoreError) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException
object
- object to set property onname
- name of the property. object must have setobjectValue
- value of the propertyignoreError
- true to ignore errorsjava.lang.IllegalAccessException
- security violationjava.lang.IllegalArgumentException
- illegal argumentjava.lang.reflect.InvocationTargetException
- invocation problempublic static boolean setProperty(java.lang.Object object, java.lang.reflect.Method method, java.lang.Object objectValue, boolean ignoreError) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException
object
- object to set property onmethod
- method to callobjectValue
- value of the methodignoreError
- true to ignore errorsjava.lang.IllegalAccessException
- security violationjava.lang.IllegalArgumentException
- illegal argumentjava.lang.reflect.InvocationTargetException
- invocation problempublic static int getInt(java.lang.String stringValue, int dflt)
stringValue
- The integer string value.dflt
- The dflt to return if the decode failspublic static boolean getBoolean(java.lang.String stringValue, boolean dflt)
stringValue
- The boolean string value.dflt
- The dflt to return if the decode failspublic static java.util.Vector toVector(java.lang.Object[] objectArray)
objectArray
- The array of objects.public static <E> java.util.List<E> makeUnique(java.util.List<E> l)
E
- the element typel
- initial listpublic static java.util.List toList(java.lang.Object[] l)
l
- The array of objects.public static java.util.List toList(java.util.Enumeration enumeration)
enumeration
- The enumerationpublic static java.util.List newList(java.lang.Object[] l)
l
- The array of objects.public static java.lang.Object safeGet(java.util.List l, int index)
l
- Listindex
- Indexpublic static java.util.List createIntervalList(int start, int end, int step)
start
- The start valueend
- The end value.step
- The steppublic static java.util.List sort(java.util.Collection listToSort)
listToSort
- The list to sort.public static java.util.List sortTuples(java.util.List pairs, boolean ascending)
pairs
- list to sortascending
- true for ascending sortpublic static java.util.Properties parseProperties(java.lang.String propString)
propString
- The property String.public static java.util.Properties parseProperties(java.lang.String propString, java.lang.String delimiter)
propString
- The property String.delimiter
- The delimiter between each name/value pairpublic static java.lang.String getProperty(java.util.Hashtable p, java.lang.String prop, java.lang.String dflt)
p
- property tableprop
- property to look up.dflt
- default valuepublic static java.awt.Color getProperty(java.util.Hashtable props, java.lang.String prop, java.awt.Color dflt)
props
- properties tableprop
- property namedflt
- default colorpublic static boolean getProperty(java.util.Hashtable props, java.lang.String prop, boolean dflt)
props
- table of propertiesprop
- property namedflt
- default valuepublic static int getProperty(java.util.Hashtable props, java.lang.String prop, int dflt)
props
- table of propertiesprop
- property namedflt
- default valuepublic static float getProperty(java.util.Hashtable props, java.lang.String prop, float dflt)
props
- table of propertiesprop
- property namedflt
- default valuepublic static double getProperty(java.util.Hashtable props, java.lang.String prop, double dflt)
props
- the propsprop
- the prop namedflt
- the default value if none foundpublic static java.util.Properties readProperties(java.lang.String filename, java.util.Properties properties, java.lang.Class origin)
filename
- The property filenameproperties
- Where to put the properties.origin
- Where to look for the properties file.public static java.net.URL getURL(java.lang.String name, java.lang.Class origin)
name
- The resource nameorigin
- Where to look.public static java.lang.String appendUrlArgs(java.lang.String base, java.lang.String[] args)
base
- The base of the url.args
- The name/value pairs.public static java.lang.String appendUrlArgs(java.lang.String base, java.lang.String[] args, boolean addQuestionMark)
base
- The base of the url.args
- The name/value pairs. This may be null.addQuestionMark
- Do we start by appending a "?"public static java.lang.String makeUrl(java.lang.String protocol, java.lang.String server, java.lang.String urlRoot, java.lang.String[] args)
protocol
- The url protocol.server
- The server.urlRoot
- The root of the url path.args
- Any url arguments. This may be null.public static void run(java.lang.Runnable r)
Runnable
.r
- Runnable to runrunInABit(long, java.lang.Object, java.lang.String, java.lang.Object)
public static void run(java.lang.Object object, java.lang.String methodName)
object
- The objectmethodName
- The methodpublic static void run(java.lang.Object object, java.lang.String methodName, java.lang.Object arg)
object
- The objectmethodName
- The methodarg
- The argpublic static void runInABit(long ms, java.lang.Object object, java.lang.String methodName, java.lang.Object arg)
ms
- delay (milliseconds)object
- The objectmethodName
- The methodarg
- The argpublic static void runInABit(long ms, java.lang.Runnable r)
ms
- delay (milliseconds)r
- Runnable to runpublic static java.lang.String doPost(java.lang.String action, java.lang.String data)
action
- post actiondata
- data to postpublic static java.lang.String doPost(java.lang.String action, java.lang.String data, java.lang.String[] attrs)
action
- post actiondata
- data to postattrs
- data attributespublic static java.lang.Object[] doPostAndGetConnection(java.lang.String action, java.lang.String data)
action
- post actiondata
- data to postpublic static java.lang.Object[] doPostAndGetConnection(java.lang.String action, java.lang.String data, java.lang.String[] attrs)
action
- post actiondata
- data to postattrs
- data attributespublic static java.lang.String getValue(java.lang.String key, java.util.Hashtable props)
key
- key for valueprops
- property table to look upnull
public static java.lang.String getUniqueId()
public static java.util.List addUnique(java.util.List dest, java.util.List src, java.util.Hashtable seen)
dest
- The destination list.src
- The list of objects to add if they are unique.seen
- Keeps track of what objects we have seen.public static java.util.List cloneList(java.util.List sourceList)
sourceList
- The source list.public static java.util.Hashtable newHashtable(java.util.Hashtable ht, java.lang.Object[] o)
ht
- The hashtable to put the values into. If
null
, we create a new one.o
- The array of (key,value) objects.public static java.util.Hashtable newHashtable(java.lang.Object[] o)
o
- The array of (key,value) objects.public static java.util.Hashtable newHashtable(java.lang.Object key1, java.lang.Object value1)
key1
- key for tablevalue1
- corresponding valuepublic static java.util.Hashtable newHashtable(java.lang.Object key1, java.lang.Object value1, java.lang.Object key2, java.lang.Object value2)
key1
- first keyvalue1
- corresponding first valuekey2
- second keyvalue2
- corresponding second valuepublic static java.util.Hashtable newHashtable(java.lang.Object key1, java.lang.Object value1, java.lang.Object key2, java.lang.Object value2, java.lang.Object key3, java.lang.Object value3)
key1
- first keyvalue1
- corresponding first valuekey2
- second keyvalue2
- corresponding second valuekey3
- third keyvalue3
- corresponding third valuepublic static java.util.Hashtable newHashtable(java.lang.Object[] keys, java.lang.Object[] values)
keys
- set of keysvalues
- set of corresponding valuespublic static java.lang.Object getLast(java.util.List l)
l
- The listpublic static void removeLast(java.util.List l)
l
- the listpublic static java.util.List newList(java.lang.Object o1)
o1
- object to add to listobject
in itpublic static java.util.List newList(java.lang.Object o1, java.lang.Object o2)
o1
- first object to addo2
- second object to addpublic static java.util.List newList(java.lang.Object o1, java.lang.Object o2, java.lang.Object o3)
o1
- first object to addo2
- second object to addo3
- third object to addpublic static java.util.List newList(java.lang.Object o1, java.lang.Object o2, java.lang.Object o3, java.lang.Object o4)
o1
- first object to addo2
- second object to addo3
- third object to addo4
- fourth object to addpublic static java.util.List newList(java.lang.Object o1, java.lang.Object o2, java.lang.Object o3, java.lang.Object o4, java.lang.Object o5)
o1
- first object to addo2
- second object to addo3
- third object to addo4
- fourth object to addo5
- fifth object to addpublic static java.util.List newList(java.lang.Object o1, java.lang.Object o2, java.lang.Object o3, java.lang.Object o4, java.lang.Object o5, java.lang.Object o6)
o1
- first object to addo2
- second object to addo3
- third object to addo4
- fourth object to addo5
- fifth object to addo6
- fifth object to addpublic static java.util.List newList(java.lang.Object o1, java.lang.Object o2, java.lang.Object o3, java.lang.Object o4, java.lang.Object o5, java.lang.Object o6, java.lang.Object o7)
o1
- first object to addo2
- second object to addo3
- third object to addo4
- fourth object to addo5
- fifth object to addo6
- fifth object to addo7
- fifth object to addpublic static boolean isHtml(java.lang.String s)
s
- String to checkpublic static boolean typesMatch(java.lang.Class[] formals, java.lang.Class[] actuals)
formals
- formal classes (types)actuals
- actual classespublic static boolean typesMatchx(java.lang.Class[] formals, java.lang.Class[] actuals)
formals
- dummyactuals
- dummypublic static java.lang.reflect.Method findMethod(java.lang.Class c, java.lang.String methodName, java.lang.Class[] paramTypes)
c
- class to checkmethodName
- name of methodparamTypes
- parameter typesnull
if one doesn't existpublic static java.lang.String getClassMethod(java.lang.String path)
path
- full path to checkpublic static java.util.List getIndexList(java.util.List values, java.util.List allValues)
values
- The values we look upallValues
- The list that we look intopublic static java.util.List getValuesFromIndices(java.util.List indices, java.util.List allValues)
indices
- A list of Integer indexes into the allValues list.allValues
- The source of the valuespublic static java.lang.reflect.Constructor findConstructor(java.lang.Class c, java.lang.Class[] paramTypes)
c
- class to checkparamTypes
- constructor parameter classesnull
if none matchpublic static java.lang.String getSystemProperty(java.lang.String key, java.lang.String dflt)
key
- key for propertydflt
- default valuepublic static byte[] serialize(java.io.Serializable object)
object
- object to serializepublic static java.lang.Object deserialize(byte[] bytes)
bytes
- serialized object bytespublic static java.text.DecimalFormat getDecimalFormat(double v)
v
- value in questionpublic static java.lang.String format(double value)
value
- value to formatpublic static double parseValue(java.lang.String value) throws java.lang.NumberFormatException
parseNumber(String)
value
- String representation of a number. Use double since
that is the highest common denominatorjava.lang.NumberFormatException
- unable to parse the valuepublic static double parseNumber(java.lang.String value) throws java.lang.NumberFormatException
value
- String representation of a number. Use double since
that is the highest common denominatorjava.lang.NumberFormatException
- unable to parse the valuepublic static int hashcode(java.lang.Object o1)
o1
- object in questiono1
-s hashCode or 1 if o1
is nullpublic static boolean equals(java.lang.Object o1, java.lang.Object o2)
o1
- first Object
in questiono2
- second Object
in questionpublic static boolean equalsIgnoreCase(java.lang.Object o1, java.lang.Object o2)
o1
- first object to compareo2
- second object to comparepublic static boolean haveSeen(java.lang.Object o, java.util.Hashtable map)
o
- object in questionmap
- map of seen objectspublic static boolean haveNotSeen(java.lang.Object o, java.util.Hashtable map)
o
- object in questionmap
- map of seen objectspublic static void printArray(java.lang.String prefix, java.lang.Object[] array)
prefix
- prefix to append to outputarray
- array to printpublic static void printArray(java.lang.String prefix, byte[] array)
prefix
- prefix stringarray
- array to printpublic static void printArray(java.lang.String prefix, int[] array)
prefix
- prefix stringarray
- array to printpublic static void printArray(java.lang.String prefix, float[] array)
prefix
- prefix stringarray
- array to printpublic static void printArray(java.lang.String prefix, double[] array)
prefix
- prefix stringarray
- array to printpublic static void printArray(java.lang.String prefix, boolean[] array)
prefix
- prefix stringarray
- array to printpublic static void printMembers(java.lang.Object o)
o
- Object in questionpublic static void printStack(java.lang.String msg, int maxLines, java.lang.String onlyIfTraceContainsThisString)
msg
- message to printmaxLines
- number of lines in the stack to printonlyIfTraceContainsThisString
- if true, only print if it
contains this Stringpublic static void printStack(java.lang.String msg, int maxLines)
msg
- message to printmaxLines
- number of lines in the stack to printpublic static void printStack(java.lang.String msg)
msg
- message to printpublic static long usedMemory()
public static long gc()
usedMemory()
public static void sleepSeconds(long seconds)
seconds
- seconds to pausepublic static void sleep(long ms)
ms
- milliseconds to pausepublic static void fatal(java.lang.Throwable exc)
exc
- exception that was thrownpublic static void fatal(java.lang.String msg)
msg
- message to printpublic static float[] toFloat(double[] d)
d
- double arraypublic static double[] toDouble(float[] d)
d
- double arraypublic static double[][] toDouble(int[][] d)
d
- inputpublic static double[] toDouble(int[] d)
d
- inputpublic static double[] arrayToDouble(float[] d)
d
- float arraypublic static float[][] toFloat(double[][] d)
d
- inputpublic static double[][] toDouble(float[][] d)
d
- inputpublic static double parseDouble(java.lang.String s)
s
- parse the String representation of a double, must
conform to the form of a floating point number as
defined in 3.10.2 of the Java Language Specification.public static float getAverage(float[] values)
values
- values to averagepublic static float parseFloat(java.lang.String s)
s
- parse the String representation of a float, must
conform to the form of a floating point number as
defined in 3.10.2 of the Java Language Specification.public static double[] parseDoubles(java.lang.String sourceString)
sourceString
- The comma separated list.public static double[] parseDoubles(java.lang.String sourceString, java.lang.String delimiter)
delimiter
separated list
of doubles. This method parses this String, converting it into an
array of doubles.sourceString
- The comma separated list.delimiter
- delimiter between valuespublic static double[] parseLatLons(java.lang.String sourceString)
sourceString
- The comma separated list.public static double[] parseLatLons(java.lang.String sourceString, java.lang.String delimiter)
delimiter
separated list
of lats or lons. This method parses this String, converting it into an
array of doubles.sourceString
- The comma separated list.delimiter
- delimiter between valuespublic static float[] parseFloats(java.lang.String sourceString)
sourceString
- The comma separated list.public static float[] parseFloats(java.lang.String sourceString, java.lang.String delimiter)
delimiter
separated list
of doubles. This method parses this String, converting it into an
array of floats.sourceString
- The comma separated list.delimiter
- delimiter between valuespublic static int[] parseInts(java.lang.String sourceString, java.lang.String delimiter)
delimiter
separated list
of doubles. This method parses this String, converting it into an
array of ints.sourceString
- The comma separated list.delimiter
- delimiter between valuespublic static double normalizeLongitude(double lonValue)
lonValue
- longitude value to adjust (in degrees)public static double[] computeTicks(double high, double low, double base, double interval)
high
- highest value of rangelow
- low value of rangebase
- base value for centering ticksinterval
- interval between tickspublic static float[] computeTicks(float high, float low, float base, float interval)
high
- highest value of rangelow
- low value of rangebase
- base value for centering ticksinterval
- interval between tickspublic static double computeTickSpacing(double min, double max)
min
- minimum value in rangemax
- maximum value in rangepublic static java.util.Hashtable createLabelTable(double max, double min, double base, double increment)
max
- highest value of rangemin
- low value of rangebase
- base value for centering ticksincrement
- interval between tickspublic static void print(java.util.List l)
l
- List to printpublic static boolean containsString(java.lang.String string, java.util.List objects, boolean lowerCase)
string
- the string to search forobjects
- the list of objectslowerCase
- check case insensiblypublic static boolean contains(java.lang.Object object, java.lang.Object[] array)
object
- THe objectarray
- The arraypublic static int indexOf(java.lang.Object object, java.lang.Object[] array)
object
- THe objectarray
- The arraypublic static boolean allStrings(java.util.List listToCheck)
listToCheck
- List to Checkpublic static boolean hasSuffix(java.lang.String fileOrUrl, java.lang.String suffix)
fileOrUrl
- The name of the file or urlsuffix
- The suffixpublic static boolean isTextFile(java.lang.String filename)
filename
- The filename to check.public static boolean isImageFile(java.lang.String filename)
filename
- The filename to check.public static boolean isHtmlFile(java.lang.String filenameOrUrl)
filenameOrUrl
- The filename to check.public static java.io.InputStream getInputStream(java.lang.String filename) throws java.io.FileNotFoundException, java.io.IOException
filename
- name of filejava.io.FileNotFoundException
- couldn't find the filejava.io.IOException
- problem opening streampublic static java.io.InputStream getInputStream(java.lang.String filename, java.lang.Class origin) throws java.io.FileNotFoundException, java.io.IOException
filename
- name of fileorigin
- relative origin point for file locationjava.io.FileNotFoundException
- couldn't find the filejava.io.IOException
- problem opening streampublic static java.lang.String readContents(java.io.File file) throws java.io.FileNotFoundException, java.io.IOException
file
- file to read.java.io.FileNotFoundException
- couldn't find the filejava.io.IOException
- problem opening streampublic static java.lang.String readContents(java.lang.String contentName, java.lang.String dflt)
contentName
- URL or filenamedflt
- default to return if a problempublic static java.lang.String readContents(java.lang.String contentName) throws java.io.FileNotFoundException, java.io.IOException
contentName
- can either be a URL, a filename or a resource.null
if there is a problem.java.io.FileNotFoundException
- couldn't find the filejava.io.IOException
- problem reading contentspublic static java.lang.String readContents(java.lang.String contentName, java.lang.Class origin) throws java.io.FileNotFoundException, java.io.IOException
contentName
- can either be a URL, a filename or a resource.origin
- relative origin for path to filenull
if there is a problem.java.io.FileNotFoundException
- couldn't find the filejava.io.IOException
- problem reading contentspublic static java.lang.String readContents(java.io.InputStream is) throws java.io.IOException
is
- InputStream to read fromjava.io.IOException
- problem reading contentspublic static byte[] readBytes(java.io.InputStream is) throws java.io.IOException
is
- InputStream to read fromjava.io.IOException
- problem reading contentspublic static byte[] readBytes(java.io.InputStream is, java.lang.Object loadId) throws java.io.IOException
is
- InputStream to read fromloadId
- loadidjava.io.IOException
- problem reading contentspublic static java.io.File getMostRecentFile(java.io.File dir)
dir
- The directory to search in.public static java.io.File getMostRecentFile(java.io.File dir, java.io.FileFilter filter)
dir
- The directory to search in.filter
- The FileFilter
to be used to limit what files we look at (may be null).public static java.io.File[] sortFilesOnAge(java.io.File directory, java.io.FileFilter filter, boolean youngestFirst)
directory
- The directoryfilter
- The filteryoungestFirst
- Ascending or descendingpublic static java.io.File[] sortFilesOnAge(java.io.File[] files, boolean youngestFirst)
files
- The filesyoungestFirst
- Ascending or descendingpublic static java.io.File[] toFiles(java.util.List files)
files
- List of filespublic static java.io.FileFilter wrapFilter(javax.swing.filechooser.FileFilter filter)
filter
- The filechooser file filterpublic static java.io.File getMostRecentFile(java.io.File dir, javax.swing.filechooser.FileFilter filter)
dir
- The directory to search in.filter
- The filter to be used to limit what files we look at (may be null).public static java.lang.String getFileTail(java.lang.String f)
f
- The file path.public static java.lang.String getFileRoot(java.lang.String f)
f
- The file path.public static java.lang.String stripExtension(java.lang.String f)
f
- The file path.public static java.lang.String cleanFileName(java.lang.String name)
name
- The filename to be cleaned uppublic static java.lang.String getFileExtension(java.lang.String f)
f
- The file path.public static void writeFile(java.lang.String filename, java.lang.String contents) throws java.io.FileNotFoundException, java.io.IOException
filename
- filename to write tocontents
- file contentsjava.io.FileNotFoundException
- if the file does not existjava.io.IOException
- if there is a problem writingpublic static void writeFile(java.io.File filename, java.lang.String contents) throws java.io.FileNotFoundException, java.io.IOException
filename
- File to write tocontents
- file contentsjava.io.FileNotFoundException
- if the file does not existjava.io.IOException
- if there is a problem writingpublic static void writeBytes(java.io.File filename, byte[] contents) throws java.io.FileNotFoundException, java.io.IOException
File
specified.filename
- File to write tocontents
- file contentsjava.io.FileNotFoundException
- if the file does not existjava.io.IOException
- if there is a problem writingpublic static java.lang.String readFile(java.lang.String filename, java.lang.Class origin, java.lang.String dflt)
filename
- file nameorigin
- anchor point for relative location of filedflt
- default to returndflt
public static java.lang.String readFile(java.lang.String filename, java.lang.Class origin) throws java.io.FileNotFoundException, java.io.IOException
filename
- file nameorigin
- anchor point for relative location of filejava.io.FileNotFoundException
- if the file does not existjava.io.IOException
- if there is a problem writingpublic static void moveFile(java.io.File from, java.io.File to) throws java.io.FileNotFoundException, java.io.IOException
from
- File to moveto
- The destinationjava.io.FileNotFoundException
- When we cannot find the filejava.io.IOException
- When something untoward happenspublic static void copyFile(java.io.File from, java.io.File to) throws java.io.FileNotFoundException, java.io.IOException
from
- File to copyto
- The destinationjava.io.FileNotFoundException
- When we cannot find the filejava.io.IOException
- When something untoward happenspublic static java.lang.String joinDir(java.lang.String f1, java.lang.String f2)
f1
- directory pathf2
- filenamepublic static java.lang.String joinDir(java.io.File f1, java.lang.String filename)
f1
- directory pathfilename
- filenamepublic static java.lang.String makeDir(java.lang.String path)
path
- directory to makepublic static java.lang.String makeDir(java.io.File f)
f
- directory as a filepublic static java.util.List getDirectories(java.io.File dir, boolean recurse)
dir
- The directory to look atrecurse
- Do we recursepublic static java.util.List getDirectories(java.util.List dirs, boolean recurse)
dirs
- List of directories to look atrecurse
- Do we recursepublic static void pruneEmptyDirectories(java.io.File root)
root
- Directory to prunepublic static void deleteDirectory(java.io.File root)
root
- rootpublic static java.lang.Object findMatch(java.lang.String source, java.util.List patternList, java.lang.Object dflt)
source
- Source String to match on.patternList
- List of objects whose toString is the pattern.dflt
- The default if nothing matches.public static java.lang.Object findMatch(java.lang.String source, java.util.List patternList, java.util.List results, java.lang.Object dflt)
source
- Source String to match on.patternList
- List of objects whose toString is the pattern.results
- The list of return objects.dflt
- The default if nothing matches.public static boolean containsRegExp(java.lang.String patternString)
patternString
- pattern string to checkpublic static boolean stringMatch(java.lang.String input, java.lang.String patternString)
input
- The input source string.patternString
- The regular expression pattern.public static boolean stringMatch(java.lang.String input, java.lang.String patternString, boolean substring, boolean caseSensitive)
input
- The input source string.patternString
- The regular expression pattern.substring
- Search for substringscaseSensitive
- Is case sensitivepublic static boolean startsWithVowel(java.lang.String value)
value
- String to checkpublic static java.lang.String breakText(java.lang.String text, java.lang.String insert, int lineSize)
text
- The text to convertinsert
- string to insertlineSize
- line size to insert atpublic static java.lang.String stripTags(java.lang.String html)
html
- The source html string.public static java.lang.String removeWhitespace(java.lang.String inputString)
inputString
- The string to remove the whitespace.public static java.lang.String zeroString(int value)
value
- The value.public static java.lang.String padZero(int value, int numDigits)
value
- The value.numDigits
- number of digitspublic static java.lang.String padLeft(java.lang.String s, int desiredLength)
s
- String to paddesiredLength
- ending lengthpublic static java.lang.String padLeft(java.lang.String s, int desiredLength, java.lang.String padString)
s
- String to paddesiredLength
- ending lengthpadString
- String to pad with (e.g, " ")public static java.lang.String padRight(java.lang.String s, int desiredLength)
s
- String to paddesiredLength
- ending lengthpublic static java.lang.String padRight(java.lang.String s, int desiredLength, java.lang.String padString)
s
- String to paddesiredLength
- ending lengthpadString
- String to pad with (e.g, " ")public static java.lang.String join(java.lang.String[] args)
args
- An array of Strings to merge.public static java.lang.String join(java.lang.String delimiter, java.lang.Object[] args)
delimiter
- The delimiter.args
- An array of Strings to merge.public static java.lang.String join(java.lang.String delimiter, java.lang.Object[] args, boolean ignoreEmptyStrings)
delimiter
- The delimiter.args
- An array of Strings to merge.ignoreEmptyStrings
- Don't join empty stringspublic static java.lang.String join(java.lang.String delimiter, java.util.List args)
delimiter
- The delimiter.args
- A List of objects whose toString value are merged.public static java.lang.String join(java.lang.String delimiter, java.util.List args, boolean ignoreEmptyStrings)
delimiter
- The delimiter.args
- A List of objects whose toString value are merged.ignoreEmptyStrings
- Should ignore empty stringspublic static java.util.List split(java.lang.Object source)
source
- The source object string.public static java.util.List parseLineWords(java.lang.String content, int[] indices, int[] lengths, java.lang.String lineDelimiter, java.lang.String commentString, boolean trimWords)
content
- The String to parseindices
- the index in the line which defines the word start.lengths
- the length of each word.lineDelimiter
- What to split the line content string on (usually "\n").commentString
- If non-null defines the comment String in the content.trimWords
- Do we trim each word.public static java.util.List split(java.lang.Object source, java.lang.String delimiter)
source
- The source object string.delimiter
- The delimiter to break up the sourceString on.public static java.util.List split(java.lang.Object source, java.lang.String delimiter, boolean trim)
source
- The source object string.delimiter
- The delimiter to break up the sourceString on.trim
- Do we string trim the tokens.public static java.util.List split(java.lang.Object source, java.lang.String delimiter, boolean trim, boolean excludeZeroLength)
source
- The source object string.delimiter
- The delimiter to break up the sourceString on.trim
- Do we string trim the tokens.excludeZeroLength
- If true then don't add in zero length strings.public static java.lang.String[] split(java.lang.String s, java.lang.String delimiter, int cnt)
s
- String to splitdelimiter
- token delimetercnt
- max number of tokensnull
if unable to split
the string.public static java.lang.String[] listToStringArray(java.util.List objectList)
objectList
- The list of objects.public static java.lang.String listToString(java.util.List l)
l
- list of objectspublic static java.util.List toString(java.util.List l)
l
- List of objectspublic static java.lang.String replace(java.lang.String string, java.lang.String pattern, java.lang.String value)
string
- string to mungepattern
- pattern to replacevalue
- replacement valuepublic static java.lang.String replaceList(java.lang.String v, java.lang.String[] patterns, java.lang.String[] values)
v
- original Stringpatterns
- patterns to matchvalues
- replacement valuespublic static java.lang.String replaceList(java.lang.String v, java.util.List patterns, java.util.List values)
v
- original Stringpatterns
- patterns to matchvalues
- replacement valuespublic static java.util.List replaceList(java.util.List sourceList, java.lang.String[] patterns, java.lang.String[] values)
sourceList
- original list of Stringspatterns
- patterns to replacevalues
- replacement valuespublic static java.lang.StringBuffer append(java.lang.StringBuffer sb, java.lang.Object s1)
sb
- StringBuffer to append to (may be null
)s1
- object to appendpublic static java.lang.StringBuffer append(java.lang.StringBuffer sb, java.lang.Object s1, java.lang.Object s2)
sb
- StringBuffer to append to (may be null
)s1
- first object to appends2
- second object to appendpublic static java.lang.StringBuffer append(java.lang.StringBuffer sb, java.lang.Object s1, java.lang.Object s2, java.lang.Object s3)
sb
- StringBuffer to append to (may be null
)s1
- first object to appends2
- second object to appends3
- third object to appendpublic static java.lang.StringBuffer append(java.lang.StringBuffer sb, java.lang.Object s1, java.lang.Object s2, java.lang.Object s3, java.lang.Object s4)
sb
- StringBuffer to append to (may be null
)s1
- first object to appends2
- second object to appends3
- third object to appends4
- fourth object to appendpublic static java.lang.StringBuffer append(java.lang.StringBuffer sb, java.lang.Object s1, java.lang.Object s2, java.lang.Object s3, java.lang.Object s4, java.lang.Object s5)
sb
- StringBuffer to append to (may be null
)s1
- first object to appends2
- second object to appends3
- third object to appends4
- fourth object to appends5
- fifth object to appendpublic static java.util.List parseCsv(java.lang.String s, boolean skipFirst)
s
- String to parseskipFirst
- true to skip the first valuepublic static final java.lang.String shorten(java.lang.String s, int length)
s
- String to shortenlength
- shortened length where elipses will startpublic static java.lang.String toString(java.lang.Object[] array)
array
- array to printpublic static void addClassLoader(java.lang.ClassLoader cl)
cl
- The class loaderpublic static java.util.List<java.lang.ClassLoader> getClassLoaders()
public static java.lang.Class findClass(java.lang.String className) throws java.lang.ClassNotFoundException
className
- The class namejava.lang.ClassNotFoundException
- When the className could not be foundpublic static long getPauseEveryTime(int minutesDelta)
minutesDelta
- time to wait forpublic static void pauseEvery(int minutesDelta)
minutesDelta
- number of minutespublic static float[][] cloneArray(float[][] a)
a
- array to clonepublic static float[] reverseArray(float[] a)
a
- input arraypublic static float[][] subtractArray(float[][] a, float[][] b, float[][] c)
a
- the arrayb
- the the other arrayc
- the return arraypublic static float[][] addArray(float[][] a, float[][] b, float[][] c)
a
- the arrayb
- the the other arrayc
- the return arraypublic static float[] getRange(float[][] a)
a
- arrays of valuespublic static float[][] getRanges(float[][] a)
a
- arrays of valuespublic static void fillArray(float[][] a, float value)
a
- arrayvalue
- valuepublic static double[][] cloneArray(double[][] a)
a
- array to clonepublic static boolean arraysEquals(double[] a, double[] b)
a
- array 1b
- array 2public static boolean arraysEquals(int[] a, int[] b)
a
- array 1b
- array 2public static boolean arraysEquals(float[] a, float[] b)
a
- array 1b
- array 2public static boolean arraysEquals(java.lang.String[] a, java.lang.String[] b)
a
- array 1b
- array 2public static boolean arraysEquals(float[][] a, float[][] b)
a
- array 1b
- array 2public static boolean arraysEquals(double[][] a, double[][] b)
a
- array 1b
- array 2public static boolean arraysEquals(int[][] a, int[][] b)
a
- array 1b
- array 2public static boolean arraysEquals(int[][][] a, int[][][] b)
a
- array 1b
- array 2public static float[] merge(float[] a, float[] b)
a
- array 1b
- array 2public static float[] interpolate(int cnt, float start, float end)
cnt
- number of pointsstart
- start valueend
- end valuepublic static float[][] copy(float[][] pts, int pointCnt)
pts
- the inputpointCnt
- the number of points to copypublic static float[][] expand(float[][] pts)
pts
- the pointspublic static java.lang.Runnable getRunnable()
public static void printBits(int b)
b
- the integerpublic static java.lang.String getStackTrace()
public static java.lang.String getStackTrace(java.lang.Throwable exc)
exc
- The exception to get the trace frompublic static void main(java.lang.String[] args)
args
- ignoredpublic static int[] find(int value, int[] array)
value
- the value to look forarray
- the arraypublic static int[] find(float value, float[] array)
value
- the value to look forarray
- the arraypublic static int[] find(double value, double[] array)
value
- the value to look forarray
- the arraypublic static boolean isNaN(float[][] values)
values
- the array valuespublic static boolean isNaN(double[][] values)
values
- array values