ucar.unidata.util
Class Misc

java.lang.Object
  extended by ucar.unidata.util.Misc

public class Misc
extends Object

Static class of miscellaneous methods

Version:
$Revision: 1.271 $
Author:
IDV development group.

Field Summary
static boolean debug
          debug flag
static String MISSING
          missing string
static String NaN
          NaN string
 
Constructor Summary
Misc()
          Default constructor; does nothing
 
Method Summary
static float[][] addArray(float[][] a, float[][] b, float[][] c)
          Add two arrays together
static void addClassLoader(ClassLoader cl)
          Add the given class loader into the list of custom class loaders
static List addUnique(List dest, List src, 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(List listToCheck)
          Is the given List a list of String objects.
static StringBuffer append(StringBuffer sb, Object s1)
          Deprecated. See StringUtil
static StringBuffer append(StringBuffer sb, Object s1, Object s2)
          Deprecated. See StringUtil
static StringBuffer append(StringBuffer sb, Object s1, Object s2, Object s3)
          Deprecated. See StringUtil
static StringBuffer append(StringBuffer sb, Object s1, Object s2, Object s3, Object s4)
          Deprecated. See StringUtil
static StringBuffer append(StringBuffer sb, Object s1, Object s2, Object s3, Object s4, Object s5)
          Deprecated. See StringUtil
static String appendUrlArgs(String base, String[] args)
          Create a url argument String with the given args.
static String appendUrlArgs(String base, 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(String[] a, String[] b)
          check for equality a or b can be null;
static double[] arrayToDouble(float[] d)
          convert float array to double array
static String breakText(String text, String insert, int lineSize)
          Deprecated. See StringUtil
static String cleanFileName(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 List cloneList(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(Object object, Object[] array)
          Does the given array contain the given object.
static boolean containsRegExp(String patternString)
          Deprecated. See StringUtil
static boolean containsString(String string, 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(File from, File to)
          Deprecated. Use IOUtil
static List createIntervalList(int start, int end, int step)
          Create and return a List that holds Integers starting at start to end by step.
static 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(String latlon)
          Decodes a string representation of a latitude or longitude and returns a double version (in degrees).
static void deleteDirectory(File root)
          Deprecated. Use IOUtil
static Object deserialize(byte[] bytes)
          Deserialize the given byte array into an object
static String doPost(String action, String data)
          Post the form data
static String doPost(String action, String data, String[] attrs)
          Post the form data
static Object[] doPostAndGetConnection(String action, String data)
          Do an http post with the given action, writing the given data as the post data.
static Object[] doPostAndGetConnection(String action, String data, String[] attrs)
          Do an http post with the given action, writing the given data as the post data.
static boolean equals(Object o1, Object o2)
          Does an o1.equals (o2) if both objects are non-null.
static boolean equalsIgnoreCase(Object o1, 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(String msg)
          Utility method to print an error and exit
static void fatal(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 Class findClass(String className)
          Find the Class for the given class name.
static Constructor findConstructor(Class c, 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 Object findMatch(String source, List patternList, List results, Object dflt)
          Deprecated. See StringUtil
static Object findMatch(String source, List patternList, Object dflt)
          Deprecated. See StringUtil
static Method findMethod(Class c, String methodName, Class[] paramTypes)
          Find all methods with the given name.
static String format(double value)
          Provide a consistent String formatting of the given double value
static String formatLatitude(double value, String format)
          Format a latitude to the given format.
static String formatLatOrLon(double value, String format, boolean isLatitude, boolean use360)
          Format a latitude or longitude value to the given format.
static String formatLongitude(double value, 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(String stringValue, boolean dflt)
          Try to decode the given stringValue as an boolean.
static List<ClassLoader> getClassLoaders()
          Get the list of dynamic class loaders
static String getClassMethod(String path)
          Utility method that returns the ClassName.methodName part of the (possibly) full package.ClassName.methodName path.
static String getClassName(Class c)
          Return the end part of the class name
static long getCurrentTime()
          Get the current time
static DecimalFormat getDecimalFormat(double v)
          Return different pre-defined DecimalFormat objects depending on the value of the given double
static List getDirectories(File dir, boolean recurse)
          Deprecated. Use IOUtil
static List getDirectories(List dirs, boolean recurse)
          Deprecated. Use IOUtil
static String getFileExtension(String f)
          Deprecated. Use IOUtil
static String getFileRoot(String f)
          Deprecated. Use IOUtil
static String getFileTail(String f)
          Deprecated. Use IOUtil
static List getIndexList(List values, List allValues)
          Return a list of Integer indexes, the indexes that each value object is in the all values list.
static InputStream getInputStream(String filename)
          Deprecated. Use IOUtil
static InputStream getInputStream(String filename, Class origin)
          Deprecated. Use IOUtil
static int getInt(String stringValue, int dflt)
          Try to decode the given stringValue as an integer.
static Object getLast(List l)
          Return the last object in the given list or null if the list is empty.
static File getMostRecentFile(File dir)
          Deprecated. Use IOUtil
static File getMostRecentFile(File dir, FileFilter filter)
          Deprecated. Use IOUtil
static File getMostRecentFile(File dir, FileFilter filter)
          Deprecated. Use IOUtil
static long getPauseEveryTime(int minutesDelta)
          figure out how long to wait for
static boolean getProperty(Hashtable props, String prop, boolean dflt)
          Look up the prop in the given set of Hashtable.
static Color getProperty(Hashtable props, String prop, Color dflt)
          Look up the prop in the given set of properties.
static double getProperty(Hashtable props, String prop, double dflt)
          get a double property from the props table
static float getProperty(Hashtable props, String prop, float dflt)
          Look up the prop in the given set of Hashtable.
static int getProperty(Hashtable props, String prop, int dflt)
          Look up the prop in the given set of Hashtable.
static String getProperty(Hashtable p, String prop, 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 Runnable getRunnable()
          Get a Runnable object
static String getSetterMethod(String prop)
          For the given property name get the set method name, e.g., returns:
static String getStackTrace()
          Return the stack trace of this calling thread
static String getStackTrace(Throwable exc)
          Get the stack trace from the given exception
static String getSystemProperty(String key, String dflt)
          Read the given system property.
static String getUniqueId()
          Gets a (sort of) unique String identifier.
static URL getURL(String name, Class origin)
          Find the url with the given name as a resource relative to the given class.
static String getValue(String key, Hashtable props)
          Looks up the named value in the props hashtable.
static List getValuesFromIndices(List indices, 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(Object o1)
          Return the hashcode for the object.
static boolean hasSuffix(String fileOrUrl, String suffix)
          Does the given file or url have the given suffix
static boolean haveNotSeen(Object o, Hashtable map)
          The inverse of haveSeen
static boolean haveSeen(Object o, Hashtable map)
          Checks to see if the object o is in the given Hashtable.
static int indexOf(Object object, 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(String s)
          See if the string is HTML.
static boolean isHtmlFile(String filenameOrUrl)
          Deprecated. Use IOUtil
static boolean isImageFile(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(String filename)
          Deprecated. Use IOUtil
static String join(String[] args)
          Deprecated. See StringUtil
static String join(String delimiter, List args)
          Deprecated. See StringUtil
static String join(String delimiter, List args, boolean ignoreEmptyStrings)
          Deprecated. See StringUtil
static String join(String delimiter, Object[] args)
          Deprecated. See StringUtil
static String join(String delimiter, Object[] args, boolean ignoreEmptyStrings)
          Deprecated. See StringUtil
static String joinDir(File f1, String filename)
          Deprecated. Use IOUtil
static String joinDir(String f1, String f2)
          Deprecated. Use IOUtil
static String listToString(List l)
          Deprecated. See StringUtil
static String[] listToStringArray(List objectList)
          Deprecated. See StringUtil
static void main(String[] args)
          Test this class
static String makeDir(File f)
          Deprecated. Use IOUtil
static String makeDir(String path)
          Deprecated. Use IOUtil
static List makeUnique(List l)
          Make the list unique
static String makeUrl(String protocol, String server, String urlRoot, 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(File from, File to)
          Deprecated. Use IOUtil
static Hashtable newHashtable(Hashtable ht, Object[] o)
          Create a Hashtable.
static Hashtable newHashtable(Object[] o)
          Create a new Hashtable.
static Hashtable newHashtable(Object[] keys, Object[] values)
          Create a Hashtable and add the given keys and their corresponding values into it.
static Hashtable newHashtable(Object key1, Object value1)
          Create a Hashtable and add the given keys and their corresponding values into it.
static Hashtable newHashtable(Object key1, Object value1, Object key2, Object value2)
          Create a Hashtable and add the given keys and their corresponding values into it.
static Hashtable newHashtable(Object key1, Object value1, Object key2, Object value2, Object key3, Object value3)
          Create a Hashtable and add the given keys and their corresponding values into it.
static List newList(Object o1)
          Create a List and add the argument to it.
static List newList(Object[] l)
          Copy the objects with the given objectArray into a new List.
static List newList(Object o1, Object o2)
          Create a List and add the arguments to it.
static List newList(Object o1, Object o2, Object o3)
          Create a List and add the arguments to it.
static List newList(Object o1, Object o2, Object o3, Object o4)
          Create a List and add the arguments to it.
static List newList(Object o1, Object o2, Object o3, Object o4, Object o5)
          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 String padLeft(String s, int desiredLength)
          Deprecated. See StringUtil
static String padLeft(String s, int desiredLength, String padString)
          Deprecated. See StringUtil
static String padRight(String s, int desiredLength)
          Deprecated. See StringUtil
static String padRight(String s, int desiredLength, String padString)
          Deprecated. See StringUtil
static String padZero(int value, int numDigits)
          Deprecated. See StringUtil
static List parseCsv(String s, boolean skipFirst)
          Deprecated. See StringUtil
static double parseDouble(String s)
          Parse the double value specified by the string s.
static double[] parseDoubles(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(String sourceString, String delimiter)
          The given sourceString is a delimiter separated list of doubles.
static float parseFloat(String s)
          Parse the float value specified by the string s.
static float[] parseFloats(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(String sourceString, String delimiter)
          The given sourceString is a delimiter separated list of doubles.
static int[] parseInts(String sourceString, String delimiter)
          The given sourceString is a delimiter separated list of doubles.
static double[] parseLatLons(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(String sourceString, String delimiter)
          The given sourceString is a delimiter separated list of lats or lons.
static List parseLineWords(String content, int[] indices, int[] lengths, String lineDelimiter, String commentString, boolean trimWords)
          Deprecated. See StringUtil
static double parseNumber(String value)
          Provide a consistent parsing that takes into account localization of the String format of the given numeric value
static Properties parseProperties(String propString)
          Create a Properties table from the given semi-colon delimited attribute string.
static Properties parseProperties(String propString, String delimiter)
          Create a Properties table from the given semi-colon delimited attribute string.
static double parseValue(String value)
          Deprecated. replaced by parseNumber(String)
static void pauseEvery(int minutesDelta)
          Pause every n minutes
static void print(List l)
          A method for printing a list.
static void printArray(String prefix, boolean[] array)
          Print out the values in a boolean array.
static void printArray(String prefix, byte[] array)
          Print out the values in an int array.
static void printArray(String prefix, double[] array)
          Print out the values in a double array.
static void printArray(String prefix, float[] array)
          Print out the values in a float array.
static void printArray(String prefix, int[] array)
          Print out the values in an int array.
static void printArray(String prefix, 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(Object o)
          Print the members of an Object
static void printStack(String msg)
          Print the stack trace for a given line of code.
static void printStack(String msg, int maxLines)
          Print the stack trace for a given line of code.
static void printStack(String msg, int maxLines, String onlyIfTraceContainsThisString)
          Print the stack trace for a given line of code.
static void propertySet(Object object, String name, String value)
          Use reflection to find the Method with name "set" + Name.
static boolean propertySet(Object object, String name, String value, boolean ignoreError)
          Use reflection to find the Method with name "set" + Name.
static void pruneEmptyDirectories(File root)
          Deprecated. Use IOUtil
static byte[] readBytes(InputStream is)
          Deprecated. Use IOUtil
static byte[] readBytes(InputStream is, Object loadId)
          Deprecated. Use IOUtil
static String readContents(File file)
          Deprecated. Use IOUtil
static String readContents(InputStream is)
          Deprecated. Use IOUtil
static String readContents(String contentName)
          Deprecated. Use IOUtil
static String readContents(String contentName, Class origin)
          Deprecated. Use IOUtil
static String readContents(String contentName, String dflt)
          Deprecated. Use IOUtil
static String readFile(String filename, Class origin)
          Deprecated. Use IOUtil
static String readFile(String filename, Class origin, String dflt)
          Deprecated. Use IOUtil
static Properties readProperties(String filename, Properties properties, Class origin)
          Read the given property filename, defined in relation to the given Class.
static void removeLast(List l)
          Remove the last element in the given list.
static String removeWhitespace(String inputString)
          Deprecated. See StringUtil
static String replace(String string, String pattern, String value)
          Deprecated. See StringUtil
static List replaceList(List sourceList, String[] patterns, String[] values)
          Deprecated. See StringUtil
static String replaceList(String v, List patterns, List values)
          Deprecated. See StringUtil
static String replaceList(String v, String[] patterns, String[] values)
          Deprecated. See StringUtil
static float[] reverseArray(float[] a)
          Reverse the array
static Object[] reverseArray(Object[] fromArray, Object[] toArray)
          Reverse an array
static List reverseList(List l)
          Reverse an array
static void run(Object object, String methodName)
          Call object.runMethod in a different thread
static void run(Object object, String methodName, Object arg)
          Call object.runMethod in a different thread.
static void run(Runnable r)
          Run the Runnable.
static void runInABit(long ms, Object object, String methodName, Object arg)
          Call object.runMethod in a different thread after a ms millisecond delay
static void runInABit(long ms, Runnable r)
          Call r.run () in a different thread after a ms millisecond delay
static Object safeGet(List l, int index)
          Utility to do a list get only if the index is ok.
static byte[] serialize(Serializable object)
          Serialize the given object into its byte array form
static void setCurrentTime(Date date)
          Set the current time
static boolean setProperty(Object object, Method method, Object objectValue, boolean ignoreError)
          Set a property on a "bean"
static boolean setProperty(Object object, String name, Object objectValue, boolean ignoreError)
          Set a property on a "bean"
static void setPrototypeManager(PrototypeManager prototypeManager)
          Set the global prototype manager.
static String shorten(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 List sort(Collection listToSort)
          Sort the given List.
static File[] sortFilesOnAge(File[] files, boolean youngestFirst)
          Deprecated. Use IOUtil
static File[] sortFilesOnAge(File directory, FileFilter filter, boolean youngestFirst)
          Deprecated. Use IOUtil
static List sortTuples(List pairs, boolean ascending)
          The elements in the given list object arrays.
static List split(Object source)
          Deprecated. See StringUtil
static List split(Object source, String delimiter)
          Deprecated. See StringUtil
static List split(Object source, String delimiter, boolean trim)
          Deprecated. See StringUtil
static List split(Object source, String delimiter, boolean trim, boolean excludeZeroLength)
          Deprecated. See StringUtil
static String[] split(String s, String delimiter, int cnt)
          Deprecated. See StringUtil
static boolean startsWithVowel(String value)
          Deprecated. See StringUtil
static boolean stringMatch(String input, String patternString)
          Deprecated. See StringUtil
static boolean stringMatch(String input, String patternString, boolean substring, boolean caseSensitive)
          Deprecated. See StringUtil
static String stripExtension(String f)
          Deprecated. Use IOUtil
static String stripTags(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(Object o)
          A method for converting an object to a Double.
static File[] toFiles(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 List toList(Enumeration enumeration)
          Create a list from an enumeration
static List toList(Object[] l)
          Copy the objects with the given objectArray into a new List.
static List toString(List l)
          Deprecated. See StringUtil
static String toString(Object[] array)
          Deprecated. See StringUtil
static Vector toVector(Object[] objectArray)
          Copy the objects with the given objectArray into a new Vector.
static boolean typesMatch(Class[] formals, 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(Class[] formals, Class[] actuals)
          dummy
static long usedMemory()
          Get the amount of used memory
static FileFilter wrapFilter(FileFilter filter)
          Deprecated. Use IOUtil
static void writeBytes(File filename, byte[] contents)
          Deprecated. Use IOUtil
static void writeFile(File filename, String contents)
          Deprecated. Use IOUtil
static void writeFile(String filename, String contents)
          Deprecated. Use IOUtil
static String zeroString(int value)
          Deprecated. See StringUtil
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debug

public static boolean debug
debug flag


MISSING

public static final String MISSING
missing string

See Also:
Constant Field Values

NaN

public static final String NaN
NaN string

See Also:
Constant Field Values
Constructor Detail

Misc

public Misc()
Default constructor; does nothing

Method Detail

setPrototypeManager

public static void setPrototypeManager(PrototypeManager prototypeManager)
Set the global prototype manager. We needed some palce to put this method.

Parameters:
prototypeManager - The prototype manager

getPrototypeManager

public static PrototypeManager getPrototypeManager()
Get the prototype manager

Returns:
The prototype manager

getCurrentTime

public static long getCurrentTime()
Get the current time

Returns:
the time in milliseconds

setCurrentTime

public static void setCurrentTime(Date date)
Set the current time

Parameters:
date - the date to use

toDouble

public static double toDouble(Object o)
A method for converting an object to a Double. No check is made to see if this is a Number or not. This will not handle a localized String representation of a floating point number. Use parseNumber(String) instead.

Parameters:
o - object in question
Returns:
a double value

formatLatitude

public static String formatLatitude(double value,
                                    String format)
Format a latitude to the given format.

Parameters:
value - the value to format
format - the format
Returns:
formatted value
See Also:
formatLatOrLon(double, String, boolean, boolean)

formatLongitude

public static String formatLongitude(double value,
                                     String format,
                                     boolean use360)
Format a longitude to the given format.

Parameters:
value - the value to format
format - the format
use360 - if true use 0-360 notation instead of -180 to 180 notation
Returns:
formatted value
See Also:
formatLatOrLon(double, String, boolean, boolean)

formatLatOrLon

public static String formatLatOrLon(double value,
                                    String format,
                                    boolean isLatitude,
                                    boolean use360)
Format a latitude or longitude value to the given format. Formats use DD for degrees, MM for minutes, SS for seconds and d, m, s for decimal fractions of degrees, minutes, seconds. H designates the hemisphere (N,S,E,W).
 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'

 

Parameters:
value - the value to format
format - the format
isLatitude - true if latitude, false if longitude
use360 - if true use 0-360 notation instead of -180 to 180 notation
Returns:
formatted value

decodeLatLon

public static double decodeLatLon(String latlon)
Decodes a string representation of a latitude or longitude and returns a double version (in degrees). Acceptable formats are:
 +/-  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
 

Parameters:
latlon - string representation of lat or lon
Returns:
the decoded value in degrees

reverseList

public static List reverseList(List l)
Reverse an array

Parameters:
l - The list
Returns:
reversed array

reverseArray

public static Object[] reverseArray(Object[] fromArray,
                                    Object[] toArray)
Reverse an array

Parameters:
fromArray - array to reverse
toArray - reversed array
Returns:
reversed array

getClassName

public static String getClassName(Class c)
Return the end part of the class name

Parameters:
c - The class
Returns:
The end part of the class name

propertySet

public static void propertySet(Object object,
                               String name,
                               String value)
                        throws IllegalAccessException,
                               IllegalArgumentException,
                               InvocationTargetException
Use reflection to find the Method with name "set" + Name. If found then convert the given value to the appropriate type and invoke the method.

Parameters:
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.
Throws:
IllegalAccessException
IllegalArgumentException
InvocationTargetException

propertySet

public static boolean propertySet(Object object,
                                  String name,
                                  String value,
                                  boolean ignoreError)
                           throws IllegalAccessException,
                                  IllegalArgumentException,
                                  InvocationTargetException
Use reflection to find the Method with name "set" + Name. If found then convert the given value to the appropriate type and invoke the method.

Parameters:
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 error
Returns:
Did we successfully set the property
Throws:
IllegalAccessException
IllegalArgumentException
InvocationTargetException

getSetterMethod

public static String getSetterMethod(String prop)
For the given property name get the set method name, e.g., returns:
 setPropertname
 

Parameters:
prop - property name
Returns:
setter method

setProperty

public static boolean setProperty(Object object,
                                  String name,
                                  Object objectValue,
                                  boolean ignoreError)
                           throws IllegalAccessException,
                                  IllegalArgumentException,
                                  InvocationTargetException
Set a property on a "bean"

Parameters:
object - object to set property on
name - name of the property. object must have set method.
objectValue - value of the property
ignoreError - true to ignore errors
Returns:
true if successful
Throws:
IllegalAccessException - security violation
IllegalArgumentException - illegal argument
InvocationTargetException - invocation problem

setProperty

public static boolean setProperty(Object object,
                                  Method method,
                                  Object objectValue,
                                  boolean ignoreError)
                           throws IllegalAccessException,
                                  IllegalArgumentException,
                                  InvocationTargetException
Set a property on a "bean"

Parameters:
object - object to set property on
method - method to call
objectValue - value of the method
ignoreError - true to ignore errors
Returns:
true if successful
Throws:
IllegalAccessException - security violation
IllegalArgumentException - illegal argument
InvocationTargetException - invocation problem

getInt

public static int getInt(String stringValue,
                         int dflt)
Try to decode the given stringValue as an integer. If it fails return the dflt.

Parameters:
stringValue - The integer string value.
dflt - The dflt to return if the decode fails
Returns:
The decoded int value.

getBoolean

public static boolean getBoolean(String stringValue,
                                 boolean dflt)
Try to decode the given stringValue as an boolean. If it fails return the dflt.

Parameters:
stringValue - The boolean string value.
dflt - The dflt to return if the decode fails
Returns:
The decoded boolean value.

toVector

public static Vector toVector(Object[] objectArray)
Copy the objects with the given objectArray into a new Vector.

Parameters:
objectArray - The array of objects.
Returns:
The Vector that contains the objects from the array.

makeUnique

public static List makeUnique(List l)
Make the list unique

Parameters:
l - initial list
Returns:
unique list

toList

public static List toList(Object[] l)
Copy the objects with the given objectArray into a new List.

Parameters:
l - The array of objects.
Returns:
The List that contains the objects from the array.

toList

public static List toList(Enumeration enumeration)
Create a list from an enumeration

Parameters:
enumeration - The enumeration
Returns:
The list

newList

public static List newList(Object[] l)
Copy the objects with the given objectArray into a new List.

Parameters:
l - The array of objects.
Returns:
The List that contains the objects from the array.

safeGet

public static Object safeGet(List l,
                             int index)
Utility to do a list get only if the index is ok. Else return null.

Parameters:
l - List
index - Index
Returns:
List value or null

createIntervalList

public static List createIntervalList(int start,
                                      int end,
                                      int step)
Create and return a List that holds Integers starting at start to end by step.

Parameters:
start - The start value
end - The end value.
step - The step
Returns:
List of Integers.

sort

public static List sort(Collection listToSort)
Sort the given List. Note: The return type may vary.

Parameters:
listToSort - The list to sort.
Returns:
A new List, sorted.

sortTuples

public static List sortTuples(List pairs,
                              boolean ascending)
The elements in the given list object arrays. The sort is done on the first element of of the array.

Parameters:
pairs - list to sort
ascending - true for ascending sort
Returns:
A new List, sorted.

parseProperties

public static Properties parseProperties(String propString)
Create a Properties table from the given semi-colon delimited attribute string. The propString is of the form: "name1=value1;name2=value2;"

Parameters:
propString - The property String.
Returns:
The properties table.

parseProperties

public static Properties parseProperties(String propString,
                                         String delimiter)
Create a Properties table from the given semi-colon delimited attribute string. The propString is of the form: "name1=value1;name2=value2;"

Parameters:
propString - The property String.
delimiter - The delimiter between each name/value pair
Returns:
The properties table.

getProperty

public static String getProperty(Hashtable p,
                                 String prop,
                                 String dflt)
Look up the String prop in the given set of properties. If it exists then return it. Else return the given dflt.

Parameters:
p - property table
prop - property to look up.
dflt - default value
Returns:
existing property value or default if it doesn't exist

getProperty

public static Color getProperty(Hashtable props,
                                String prop,
                                Color dflt)
Look up the prop in the given set of properties. If it exists convert it to a Color and return it. Else return the given dflt.

Parameters:
props - properties table
prop - property name
dflt - default color
Returns:
a color defined by the property value or the default

getProperty

public static boolean getProperty(Hashtable props,
                                  String prop,
                                  boolean dflt)
Look up the prop in the given set of Hashtable. If it exists convert it to a boolean and return it. Else return the given dflt.

Parameters:
props - table of properties
prop - property name
dflt - default value
Returns:
value converted to a boolean or the default

getProperty

public static int getProperty(Hashtable props,
                              String prop,
                              int dflt)
Look up the prop in the given set of Hashtable. If it exists convert it to a int and return it. Else return the given dflt.

Parameters:
props - table of properties
prop - property name
dflt - default value
Returns:
value converted to an int or the default

getProperty

public static float getProperty(Hashtable props,
                                String prop,
                                float dflt)
Look up the prop in the given set of Hashtable. If it exists convert it to a float and return it. Else return the given dflt.

Parameters:
props - table of properties
prop - property name
dflt - default value
Returns:
value converted to a float or the default

getProperty

public static double getProperty(Hashtable props,
                                 String prop,
                                 double dflt)
get a double property from the props table

Parameters:
props - the props
prop - the prop name
dflt - the default value if none found
Returns:
the value

readProperties

public static Properties readProperties(String filename,
                                        Properties properties,
                                        Class origin)
Read the given property filename, defined in relation to the given Class. If the given Properties object is null create a new one.

Parameters:
filename - The property filename
properties - Where to put the properties.
origin - Where to look for the properties file.
Returns:
The properties object.

getURL

public static URL getURL(String name,
                         Class origin)
Find the url with the given name as a resource relative to the given class. Look up the class hierarchy until found.

Parameters:
name - The resource name
origin - Where to look.
Returns:
The URL or null if not found.

appendUrlArgs

public static String appendUrlArgs(String base,
                                   String[] args)
Create a url argument String with the given args. Example: "?arg1=value1&arg2=value2"

Parameters:
base - The base of the url.
args - The name/value pairs.
Returns:
The contructed url string.

appendUrlArgs

public static String appendUrlArgs(String base,
                                   String[] args,
                                   boolean addQuestionMark)
Create a url argument String with the given args. Example: "?arg1=value1&arg2=value2"

Parameters:
base - The base of the url.
args - The name/value pairs. This may be null.
addQuestionMark - Do we start by appending a "?"
Returns:
The constructed url string.

makeUrl

public static String makeUrl(String protocol,
                             String server,
                             String urlRoot,
                             String[] args)
Create a URL String with the given protocol, server, url and url arguments. The result is: "protocol://server/urlRoot?args"

Parameters:
protocol - The url protocol.
server - The server.
urlRoot - The root of the url path.
args - Any url arguments. This may be null.
Returns:
the constructed URL string

run

public static void run(Runnable r)
Run the Runnable.

Parameters:
r - Runnable to run
See Also:
runInABit(long, java.lang.Object, java.lang.String, java.lang.Object)

run

public static void run(Object object,
                       String methodName)
Call object.runMethod in a different thread

Parameters:
object - The object
methodName - The method

run

public static void run(Object object,
                       String methodName,
                       Object arg)
Call object.runMethod in a different thread. If arg is non-null pass it to the method

Parameters:
object - The object
methodName - The method
arg - The arg

runInABit

public static void runInABit(long ms,
                             Object object,
                             String methodName,
                             Object arg)
Call object.runMethod in a different thread after a ms millisecond delay

Parameters:
ms - delay (milliseconds)
object - The object
methodName - The method
arg - The arg

runInABit

public static void runInABit(long ms,
                             Runnable r)
Call r.run () in a different thread after a ms millisecond delay

Parameters:
ms - delay (milliseconds)
r - Runnable to run

doPost

public static String doPost(String action,
                            String data)
Post the form data

Parameters:
action - post action
data - data to post
Returns:
posted data

doPost

public static String doPost(String action,
                            String data,
                            String[] attrs)
Post the form data

Parameters:
action - post action
data - data to post
attrs - data attributes
Returns:
posted data

doPostAndGetConnection

public static Object[] doPostAndGetConnection(String action,
                                              String data)
Do an http post with the given action, writing the given data as the post data.

Parameters:
action - post action
data - data to post
Returns:
returned data

doPostAndGetConnection

public static Object[] doPostAndGetConnection(String action,
                                              String data,
                                              String[] attrs)
Do an http post with the given action, writing the given data as the post data.

Parameters:
action - post action
data - data to post
attrs - data attributes
Returns:
returned data

getValue

public static String getValue(String key,
                              Hashtable props)
Looks up the named value in the props hashtable. This does a hash lookup of the key. If a value is found it iterates across that value looking for all occurrences of the string "macro.[a-zA-Z0-9]+" it then does a second lookup in the hashtable with the macro name, substiting the found value in the result string.

Parameters:
key - key for value
props - property table to look up
Returns:
the value, or null

getUniqueId

public static String getUniqueId()
Gets a (sort of) unique String identifier. We use the system time (in milliseconds) append with a counter. This might no be unique if there is another run of the IDV that got a call to this method at the exact same time.

Returns:
A (sortof) unique id.

addUnique

public static List addUnique(List dest,
                             List src,
                             Hashtable seen)
Adds all of the elements held by src into the dest list if they are not held in the seen Hashtable. Adds them to seen when added to dest. returns the given dest List parameter.

Parameters:
dest - The destination list.
src - The list of objects to add if they are unique.
seen - Keeps track of what objects we have seen.
Returns:
new list with unique items added

cloneList

public static List cloneList(List sourceList)
Utility to create a new list or handle a null argument gracefully.

Parameters:
sourceList - The source list.
Returns:
If the given list argument is null then return null, else return a new list which holds the elements of the original list.

newHashtable

public static Hashtable newHashtable(Hashtable ht,
                                     Object[] o)
Create a Hashtable. Put the values held in the given array into the hashtable. The argument array consists of: name1,value1,name2,value2, etc.

Parameters:
ht - The hashtable to put the values into. If null, we create a new one.
o - The array of (key,value) objects.
Returns:
The added to Hashtable.

newHashtable

public static Hashtable newHashtable(Object[] o)
Create a new Hashtable. Put the values held in the given array into the hashtable. The argument array consists of: name1,value1,name2,value2, etc.

Parameters:
o - The array of (key,value) objects.
Returns:
The newly created Hashtable.

newHashtable

public static Hashtable newHashtable(Object key1,
                                     Object value1)
Create a Hashtable and add the given keys and their corresponding values into it.

Parameters:
key1 - key for table
value1 - corresponding value
Returns:
A new Hashtable containg the given keys and values.

newHashtable

public static Hashtable newHashtable(Object key1,
                                     Object value1,
                                     Object key2,
                                     Object value2)
Create a Hashtable and add the given keys and their corresponding values into it.

Parameters:
key1 - first key
value1 - corresponding first value
key2 - second key
value2 - corresponding second value
Returns:
A new Hashtable containg the given keys and values.

newHashtable

public static Hashtable newHashtable(Object key1,
                                     Object value1,
                                     Object key2,
                                     Object value2,
                                     Object key3,
                                     Object value3)
Create a Hashtable and add the given keys and their corresponding values into it.

Parameters:
key1 - first key
value1 - corresponding first value
key2 - second key
value2 - corresponding second value
key3 - third key
value3 - corresponding third value
Returns:
A new Hashtable containg the given keys and values.

newHashtable

public static Hashtable newHashtable(Object[] keys,
                                     Object[] values)
Create a Hashtable and add the given keys and their corresponding values into it.

Parameters:
keys - set of keys
values - set of corresponding values
Returns:
A new Hashtable containg the given keys and values.

getLast

public static Object getLast(List l)
Return the last object in the given list or null if the list is empty.

Parameters:
l - The list
Returns:
The last object in the list.

removeLast

public static void removeLast(List l)
Remove the last element in the given list.

Parameters:
l - the list

newList

public static List newList(Object o1)
Create a List and add the argument to it.

Parameters:
o1 - object to add to list
Returns:
a list with object in it

newList

public static List newList(Object o1,
                           Object o2)
Create a List and add the arguments to it.

Parameters:
o1 - first object to add
o2 - second object to add
Returns:
list with the two objects

newList

public static List newList(Object o1,
                           Object o2,
                           Object o3)
Create a List and add the arguments to it.

Parameters:
o1 - first object to add
o2 - second object to add
o3 - third object to add
Returns:
list with the three objects

newList

public static List newList(Object o1,
                           Object o2,
                           Object o3,
                           Object o4)
Create a List and add the arguments to it.

Parameters:
o1 - first object to add
o2 - second object to add
o3 - third object to add
o4 - fourth object to add
Returns:
list with the four objects

newList

public static List newList(Object o1,
                           Object o2,
                           Object o3,
                           Object o4,
                           Object o5)
Create a List and add the arguments to it.

Parameters:
o1 - first object to add
o2 - second object to add
o3 - third object to add
o4 - fourth object to add
o5 - fifth object to add
Returns:
list with the five objects

isHtml

public static boolean isHtml(String s)
See if the string is HTML.

Parameters:
s - String to check
Returns:
true if it looks like HTML

typesMatch

public static boolean typesMatch(Class[] formals,
                                 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.

Parameters:
formals - formal classes (types)
actuals - actual classes
Returns:
true if they match

typesMatchx

public static boolean typesMatchx(Class[] formals,
                                  Class[] actuals)
dummy

Parameters:
formals - dummy
actuals - dummy
Returns:
dummy

findMethod

public static Method findMethod(Class c,
                                String methodName,
                                Class[] paramTypes)
Find all methods with the given name. Of these methods find one whose parameter types are assignable from the given parameter types.

Parameters:
c - class to check
methodName - name of method
paramTypes - parameter types
Returns:
class method or null if one doesn't exist

getClassMethod

public static String getClassMethod(String path)
Utility method that returns the ClassName.methodName part of the (possibly) full package.ClassName.methodName path.

Parameters:
path - full path to check
Returns:
ClassName.methodName portion of the full path

getIndexList

public static List getIndexList(List values,
                                List allValues)
Return a list of Integer indexes, the indexes that each value object is in the all values list.

Parameters:
values - The values we look up
allValues - The list that we look into
Returns:
The list of indices.

getValuesFromIndices

public static List getValuesFromIndices(List indices,
                                        List allValues)
Return a list of objects from the allValues list that are at the indices contained by the given indices list.

Parameters:
indices - A list of Integer indexes into the allValues list.
allValues - The source of the values
Returns:
The values within allValues at the given indices.

findConstructor

public static Constructor findConstructor(Class c,
                                          Class[] paramTypes)
Find all constructors of the given class Of these methods find one whose parameter types are assignable from the given parameter types.

Parameters:
c - class to check
paramTypes - constructor parameter classes
Returns:
constructor that matches or null if none match

getSystemProperty

public static String getSystemProperty(String key,
                                       String dflt)
Read the given system property. Return it if found. If not found then return the given dflt

Parameters:
key - key for property
dflt - default value
Returns:
property value or default if not defined

serialize

public static byte[] serialize(Serializable object)
Serialize the given object into its byte array form

Parameters:
object - object to serialize
Returns:
serialized byte array

deserialize

public static Object deserialize(byte[] bytes)
Deserialize the given byte array into an object

Parameters:
bytes - serialized object bytes
Returns:
Object

getDecimalFormat

public static DecimalFormat getDecimalFormat(double v)
Return different pre-defined DecimalFormat objects depending on the value of the given double

Parameters:
v - valut in question
Returns:
appropriate formatter

format

public static String format(double value)
Provide a consistent String formatting of the given double value

Parameters:
value - value to format
Returns:
formatted value

parseValue

public static double parseValue(String value)
                         throws NumberFormatException
Deprecated. replaced by parseNumber(String)

Provide a consistent parsing that takes into account localization of the String format of the given numeric value

Parameters:
value - String representation of a number. Use double since that is the highest common denominator
Returns:
parsed value as a double
Throws:
NumberFormatException - unable to parse the value

parseNumber

public static double parseNumber(String value)
                          throws NumberFormatException
Provide a consistent parsing that takes into account localization of the String format of the given numeric value

Parameters:
value - String representation of a number. Use double since that is the highest common denominator
Returns:
parsed value as a double
Throws:
NumberFormatException - unable to parse the value

hashcode

public static int hashcode(Object o1)
Return the hashcode for the object. Accounts for null objects by returning 1.

Parameters:
o1 - object in question
Returns:
o1-s hashCode or 1 if o1 is null

equals

public static boolean equals(Object o1,
                             Object o2)
Does an o1.equals (o2) if both objects are non-null. Else if one or both are null then returns whether they are both null.

Parameters:
o1 - first Object in question
o2 - second Object in question
Returns:
true if both objects are non-null and they are equal, or if both are null, otherwise false if only one is null or they are non-null, but not equal.

equalsIgnoreCase

public static boolean equalsIgnoreCase(Object o1,
                                       Object o2)
Compares two object-s toString() methods to see if they are equal, ignoring case. Uses same logic as equals(o1,o2) for handling null-objects.

Parameters:
o1 - first object to compare
o2 - second object to compare
Returns:
true if both are non-null and their toString() methods are equal.

haveSeen

public static boolean haveSeen(Object o,
                               Hashtable map)
Checks to see if the object o is in the given Hashtable. If it is then return true. If not then add the object to the hasthable and return false

Parameters:
o - object in question
map - map of seen objects
Returns:
true if o is in map

haveNotSeen

public static boolean haveNotSeen(Object o,
                                  Hashtable map)
The inverse of haveSeen

Parameters:
o - object in question
map - map of seen objects
Returns:
true if o is not in map

printArray

public static void printArray(String prefix,
                              Object[] array)
Print out the values in an int array.

Parameters:
prefix - prefix to append to output
array - array to print

printArray

public static void printArray(String prefix,
                              byte[] array)
Print out the values in an int array.

Parameters:
prefix - prefix string
array - array to print

printArray

public static void printArray(String prefix,
                              int[] array)
Print out the values in an int array.

Parameters:
prefix - prefix string
array - array to print

printArray

public static void printArray(String prefix,
                              float[] array)
Print out the values in a float array.

Parameters:
prefix - prefix string
array - array to print

printArray

public static void printArray(String prefix,
                              double[] array)
Print out the values in a double array.

Parameters:
prefix - prefix string
array - array to print

printArray

public static void printArray(String prefix,
                              boolean[] array)
Print out the values in a boolean array.

Parameters:
prefix - prefix string
array - array to print

printMembers

public static void printMembers(Object o)
Print the members of an Object

Parameters:
o - Object in question

printStack

public static void printStack(String msg,
                              int maxLines,
                              String onlyIfTraceContainsThisString)
Print the stack trace for a given line of code.

Parameters:
msg - message to print
maxLines - number of lines in the stack to print
onlyIfTraceContainsThisString - if true, only print if it contains this String

printStack

public static void printStack(String msg,
                              int maxLines)
Print the stack trace for a given line of code.

Parameters:
msg - message to print
maxLines - number of lines in the stack to print

printStack

public static void printStack(String msg)
Print the stack trace for a given line of code.

Parameters:
msg - message to print

usedMemory

public static long usedMemory()
Get the amount of used memory

Returns:
amount of memory (total-free)

gc

public static long gc()
Run the garbage collector.

Returns:
used memory
See Also:
usedMemory()

sleepSeconds

public static void sleepSeconds(long seconds)
Pause the current Thread for a specific number of seconds.

Parameters:
seconds - seconds to pause

sleep

public static void sleep(long ms)
Pause the current Thread for a specific number of milliseconds.

Parameters:
ms - milliseconds to pause

fatal

public static void fatal(Throwable exc)
Utility method to print an exception and exit

Parameters:
exc - exception that was thrown

fatal

public static void fatal(String msg)
Utility method to print an error and exit

Parameters:
msg - message to print

toFloat

public static float[] toFloat(double[] d)
Convert double array to float array

Parameters:
d - double array
Returns:
float array

toDouble

public static double[] toDouble(float[] d)
Convert double array to float array

Parameters:
d - double array
Returns:
float array

toDouble

public static double[][] toDouble(int[][] d)
Convert int array to double array

Parameters:
d - input
Returns:
double array

toDouble

public static double[] toDouble(int[] d)
Convert int array to double array

Parameters:
d - input
Returns:
double array

arrayToDouble

public static double[] arrayToDouble(float[] d)
convert float array to double array

Parameters:
d - float array
Returns:
double array

toFloat

public static float[][] toFloat(double[][] d)
Convert to float

Parameters:
d - input
Returns:
float

toDouble

public static double[][] toDouble(float[][] d)
Convert to float

Parameters:
d - input
Returns:
float

parseDouble

public static double parseDouble(String s)
Parse the double value specified by the string s. If s == null or s == "NaN" return Double.NaN. String must be in the form of the a floating point number as defined in 3.10.2 of the Java Language Specification.

Parameters:
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.
Returns:
value as a double.

getAverage

public static float getAverage(float[] values)
Average the array. This ignores NaNs. If all NaNs or values array empty return NaN

Parameters:
values - values to average
Returns:
the average.

parseFloat

public static float parseFloat(String s)
Parse the float value specified by the string s. If s == null or s == "NaN" return Float.NaN String must be in the form of the a floating point number as defined in 3.10.2 of the Java Language Specification.

Parameters:
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.
Returns:
value as a float.

parseDoubles

public static double[] parseDoubles(String sourceString)
The given sourceString is a comma separated list of values, this method parses this String, converting it into an array of doubles.

Parameters:
sourceString - The comma separated list.
Returns:
Array of doubles.

parseDoubles

public static double[] parseDoubles(String sourceString,
                                    String delimiter)
The given sourceString is a delimiter separated list of doubles. This method parses this String, converting it into an array of doubles.

Parameters:
sourceString - The comma separated list.
delimiter - delimiter between values
Returns:
Array of doubles.

parseLatLons

public static double[] parseLatLons(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.

Parameters:
sourceString - The comma separated list.
Returns:
Array of doubles.

parseLatLons

public static double[] parseLatLons(String sourceString,
                                    String delimiter)
The given sourceString is a delimiter separated list of lats or lons. This method parses this String, converting it into an array of doubles.

Parameters:
sourceString - The comma separated list.
delimiter - delimiter between values
Returns:
Array of doubles.

parseFloats

public static float[] parseFloats(String sourceString)
The given sourceString is a comma separated list of values, this method parses this String, converting it into an array of floats.

Parameters:
sourceString - The comma separated list.
Returns:
Array of floats.

parseFloats

public static float[] parseFloats(String sourceString,
                                  String delimiter)
The given sourceString is a delimiter separated list of doubles. This method parses this String, converting it into an array of floats.

Parameters:
sourceString - The comma separated list.
delimiter - delimiter between values
Returns:
Array of doubles.

parseInts

public static int[] parseInts(String sourceString,
                              String delimiter)
The given sourceString is a delimiter separated list of doubles. This method parses this String, converting it into an array of ints.

Parameters:
sourceString - The comma separated list.
delimiter - delimiter between values
Returns:
Array of doubles.

normalizeLongitude

public static double normalizeLongitude(double lonValue)
Normalize a longitude value to the range between -180 and 180.

Parameters:
lonValue - longitude value to adjust (in degrees)
Returns:
adjusted value.

computeTicks

public static double[] computeTicks(double high,
                                    double low,
                                    double base,
                                    double interval)
Compute the tick mark values based on the input. Useful for labels, contour values.

Parameters:
high - highest value of range
low - low value of range
base - base value for centering ticks
interval - interval between ticks
Returns:
array of computed tick values

computeTicks

public static float[] computeTicks(float high,
                                   float low,
                                   float base,
                                   float interval)
Compute the tick mark values based on the input. Useful for labels, contour values.

Parameters:
high - highest value of range
low - low value of range
base - base value for centering ticks
interval - interval between ticks
Returns:
array of computed tick values

computeTickSpacing

public static double computeTickSpacing(double min,
                                        double max)
Calculate a good spacing interval for labels, contours based on the range of the data.

Parameters:
min - minimum value in range
max - maximum value in range
Returns:
tick spacing

createLabelTable

public static 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. If you call createStandardLabels(100, 0, 2.0, 10.0), then it will make labels for the values 2, 12, 22, 32, etc.

Parameters:
max - highest value of range
min - low value of range
base - base value for centering ticks
increment - interval between ticks
Returns:
a table of values with a Double as the key and a formatted String as the value or an empty table if there are no labels

print

public static void print(List l)
A method for printing a list. Each element is preceded by it's position in the list

Parameters:
l - List to print

containsString

public static boolean containsString(String string,
                                     List objects,
                                     boolean lowerCase)
Does the the list contain the string

Parameters:
string - the string to search for
objects - the list of objects
lowerCase - check case insensibly
Returns:
true if the string matches the string values of the objects

contains

public static boolean contains(Object object,
                               Object[] array)
Does the given array contain the given object.

Parameters:
object - THe object
array - The array
Returns:
Array contains object

indexOf

public static int indexOf(Object object,
                          Object[] array)
What is the index of the given object

Parameters:
object - THe object
array - The array
Returns:
index of object or -1

allStrings

public static boolean allStrings(List listToCheck)
Is the given List a list of String objects.

Parameters:
listToCheck - List to Check
Returns:
true if all the objects in the list are Strings.

hasSuffix

public static boolean hasSuffix(String fileOrUrl,
                                String suffix)
Does the given file or url have the given suffix

Parameters:
fileOrUrl - The name of the file or url
suffix - The suffix
Returns:
Does the fileOrUrl have the suffix

isTextFile

public static boolean isTextFile(String filename)
Deprecated. Use IOUtil

Parameters:
filename - The filename to check.
Returns:
Is the filename a text file.

isImageFile

public static boolean isImageFile(String filename)
Deprecated. Use IOUtil

Parameters:
filename - The filename to check.
Returns:
Is the filename an image file.

isHtmlFile

public static boolean isHtmlFile(String filenameOrUrl)
Deprecated. Use IOUtil

Parameters:
filenameOrUrl - The filename to check.
Returns:
Is the filename an html file.

getInputStream

public static InputStream getInputStream(String filename)
                                  throws FileNotFoundException,
                                         IOException
Deprecated. Use IOUtil

Parameters:
filename - name of file
Returns:
corresponding input stream
Throws:
FileNotFoundException - couldn't find the file
IOException - problem opening stream

getInputStream

public static InputStream getInputStream(String filename,
                                         Class origin)
                                  throws FileNotFoundException,
                                         IOException
Deprecated. Use IOUtil

Parameters:
filename - name of file
origin - relative origin point for file location
Returns:
corresponding input stream
Throws:
FileNotFoundException - couldn't find the file
IOException - problem opening stream

readContents

public static String readContents(File file)
                           throws FileNotFoundException,
                                  IOException
Deprecated. Use IOUtil

Parameters:
file - file to read.
Returns:
contents as a String
Throws:
FileNotFoundException - couldn't find the file
IOException - problem opening stream

readContents

public static String readContents(String contentName,
                                  String dflt)
Deprecated. Use IOUtil

Parameters:
contentName - URL or filename
dflt - default to return if a problem
Returns:
contents or default value

readContents

public static String readContents(String contentName)
                           throws FileNotFoundException,
                                  IOException
Deprecated. Use IOUtil

Parameters:
contentName - can either be a URL, a filename or a resource.
Returns:
contents or null if there is a problem.
Throws:
FileNotFoundException - couldn't find the file
IOException - problem reading contents

readContents

public static String readContents(String contentName,
                                  Class origin)
                           throws FileNotFoundException,
                                  IOException
Deprecated. Use IOUtil

Parameters:
contentName - can either be a URL, a filename or a resource.
origin - relative origin for path to file
Returns:
contents or null if there is a problem.
Throws:
FileNotFoundException - couldn't find the file
IOException - problem reading contents

readContents

public static String readContents(InputStream is)
                           throws IOException
Deprecated. Use IOUtil

Parameters:
is - InputStream to read from
Returns:
contents as a String
Throws:
IOException - problem reading contents

readBytes

public static byte[] readBytes(InputStream is)
                        throws IOException
Deprecated. Use IOUtil

Parameters:
is - InputStream to read from
Returns:
bytes read
Throws:
IOException - problem reading contents

readBytes

public static byte[] readBytes(InputStream is,
                               Object loadId)
                        throws IOException
Deprecated. Use IOUtil

Parameters:
is - InputStream to read from
loadId - loadid
Returns:
bytes read
Throws:
IOException - problem reading contents

getMostRecentFile

public static File getMostRecentFile(File dir)
Deprecated. Use IOUtil

Parameters:
dir - The directory to search in.
Returns:
The most recent file (or null if none found).

getMostRecentFile

public static File getMostRecentFile(File dir,
                                     FileFilter filter)
Deprecated. Use IOUtil

Parameters:
dir - The directory to search in.
filter - The FileFilter to be used to limit what files we look at (may be null).
Returns:
The most recent file (or null if none found).

sortFilesOnAge

public static File[] sortFilesOnAge(File directory,
                                    FileFilter filter,
                                    boolean youngestFirst)
Deprecated. Use IOUtil

Parameters:
directory - The directory
filter - The filter
youngestFirst - Ascending or descending
Returns:
The sorted files

sortFilesOnAge

public static File[] sortFilesOnAge(File[] files,
                                    boolean youngestFirst)
Deprecated. Use IOUtil

Parameters:
files - The files
youngestFirst - Ascending or descending
Returns:
Just return the given array

toFiles

public static File[] toFiles(List files)
Deprecated. Use IOUtil

Parameters:
files - List of files
Returns:
array of files

wrapFilter

public static FileFilter wrapFilter(FileFilter filter)
Deprecated. Use IOUtil

Parameters:
filter - The filechooser file filter
Returns:
The javaio FileFilter.

getMostRecentFile

public static File getMostRecentFile(File dir,
                                     FileFilter filter)
Deprecated. Use IOUtil

Parameters:
dir - The directory to search in.
filter - The filter to be used to limit what files we look at (may be null).
Returns:
The most recent file (or null if none found).

getFileTail

public static String getFileTail(String f)
Deprecated. Use IOUtil

Parameters:
f - The file path.
Returns:
The file name.

getFileRoot

public static String getFileRoot(String f)
Deprecated. Use IOUtil

Parameters:
f - The file path.
Returns:
The file name.

stripExtension

public static String stripExtension(String f)
Deprecated. Use IOUtil

Remove any file extension from the given file name.

Parameters:
f - The file path.
Returns:
The file name without the extension.

cleanFileName

public static String cleanFileName(String name)
Deprecated. Use IOUtil

Parameters:
name - The filename to be cleaned up
Returns:
The cleaned up filename

getFileExtension

public static String getFileExtension(String f)
Deprecated. Use IOUtil

Parameters:
f - The file path.
Returns:
The file extension or an empty string if none found.

writeFile

public static void writeFile(String filename,
                             String contents)
                      throws FileNotFoundException,
                             IOException
Deprecated. Use IOUtil

Parameters:
filename - filename to write to
contents - file contents
Throws:
FileNotFoundException - if the file does not exist
IOException - if there is a problem writing

writeFile

public static void writeFile(File filename,
                             String contents)
                      throws FileNotFoundException,
                             IOException
Deprecated. Use IOUtil

Parameters:
filename - File to write to
contents - file contents
Throws:
FileNotFoundException - if the file does not exist
IOException - if there is a problem writing

writeBytes

public static void writeBytes(File filename,
                              byte[] contents)
                       throws FileNotFoundException,
                              IOException
Deprecated. Use IOUtil

Write out a file to the File specified.

Parameters:
filename - File to write to
contents - file contents
Throws:
FileNotFoundException - if the file does not exist
IOException - if there is a problem writing

readFile

public static String readFile(String filename,
                              Class origin,
                              String dflt)
Deprecated. Use IOUtil

Parameters:
filename - file name
origin - anchor point for relative location of file
dflt - default to return
Returns:
contents as a String or dflt

readFile

public static String readFile(String filename,
                              Class origin)
                       throws FileNotFoundException,
                              IOException
Deprecated. Use IOUtil

Parameters:
filename - file name
origin - anchor point for relative location of file
Returns:
null if the file can't be found
Throws:
FileNotFoundException - if the file does not exist
IOException - if there is a problem writing

moveFile

public static void moveFile(File from,
                            File to)
                     throws FileNotFoundException,
                            IOException
Deprecated. Use IOUtil

Parameters:
from - File to move
to - The destination
Throws:
FileNotFoundException - When we cannot find the file
IOException - When something untoward happens

copyFile

public static void copyFile(File from,
                            File to)
                     throws FileNotFoundException,
                            IOException
Deprecated. Use IOUtil

Parameters:
from - File to copy
to - The destination
Throws:
FileNotFoundException - When we cannot find the file
IOException - When something untoward happens

joinDir

public static String joinDir(String f1,
                             String f2)
Deprecated. Use IOUtil

Parameters:
f1 - directory path
f2 - filename
Returns:
concatenated String with the appropriate file separator

joinDir

public static String joinDir(File f1,
                             String filename)
Deprecated. Use IOUtil

Parameters:
f1 - directory path
filename - filename
Returns:
concatenated String with the appropriate file separator

makeDir

public static String makeDir(String path)
Deprecated. Use IOUtil

Parameters:
path - directory to make
Returns:
the directory path

makeDir

public static String makeDir(File f)
Deprecated. Use IOUtil

Parameters:
f - directory as a file
Returns:
directory path

getDirectories

public static List getDirectories(File dir,
                                  boolean recurse)
Deprecated. Use IOUtil

Parameters:
dir - The directory to look at
recurse - Do we recurse
Returns:
List of subdirs (File)

getDirectories

public static List getDirectories(List dirs,
                                  boolean recurse)
Deprecated. Use IOUtil

Parameters:
dirs - List of directories to look at
recurse - Do we recurse
Returns:
List of subdirs (File)

pruneEmptyDirectories

public static void pruneEmptyDirectories(File root)
Deprecated. Use IOUtil

Parameters:
root - Directory to prune

deleteDirectory

public static void deleteDirectory(File root)
Deprecated. Use IOUtil

Parameters:
root - root

findMatch

public static Object findMatch(String source,
                               List patternList,
                               Object dflt)
Deprecated. See StringUtil

Parameters:
source - Source String to match on.
patternList - List of objects whose toString is the pattern.
dflt - The default if nothing matches.
Returns:
The Object whose toString matches the source or the dflt if no matches found.

findMatch

public static Object findMatch(String source,
                               List patternList,
                               List results,
                               Object dflt)
Deprecated. See StringUtil

Parameters:
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.
Returns:
The return Object whose toString matches the source or the dflt if no matches found.

containsRegExp

public static boolean containsRegExp(String patternString)
Deprecated. See StringUtil

Parameters:
patternString - pattern string to check
Returns:
true if it contains (^,*,$,+).

stringMatch

public static boolean stringMatch(String input,
                                  String patternString)
Deprecated. See StringUtil

Parameters:
input - The input source string.
patternString - The regular expression pattern.
Returns:
true if the pattern match the input.

stringMatch

public static boolean stringMatch(String input,
                                  String patternString,
                                  boolean substring,
                                  boolean caseSensitive)
Deprecated. See StringUtil

Parameters:
input - The input source string.
patternString - The regular expression pattern.
substring - Search for substrings
caseSensitive - Is case sensitive
Returns:
true if the pattern match the input.

startsWithVowel

public static boolean startsWithVowel(String value)
Deprecated. See StringUtil

Parameters:
value - String to check
Returns:
true if value starts with a, e, i, o, or u (but not sometimes y). Check is case insensitive.

breakText

public static String breakText(String text,
                               String insert,
                               int lineSize)
Deprecated. See StringUtil

Parameters:
text - The text to convert
insert - string to insert
lineSize - line size to insert at
Returns:
The text with added br tags.

stripTags

public static String stripTags(String html)
Deprecated. See StringUtil

Parameters:
html - The source html string.
Returns:
The raw text.

removeWhitespace

public static String removeWhitespace(String inputString)
Deprecated. See StringUtil

Parameters:
inputString - The string to remove the whitespace.
Returns:
The whitespaceless result.

zeroString

public static String zeroString(int value)
Deprecated. See StringUtil

Parameters:
value - The value.
Returns:
The String represenation of the value, padded with a leading "0" if value < 10

padZero

public static String padZero(int value,
                             int numDigits)
Deprecated. See StringUtil

Parameters:
value - The value.
numDigits - number of digits
Returns:
The String represenation of the value, padded with leading "0"-s if value < 10E(numDigits-1)

padLeft

public static String padLeft(String s,
                             int desiredLength)
Deprecated. See StringUtil

Parameters:
s - String to pad
desiredLength - ending length
Returns:
padded String

padLeft

public static String padLeft(String s,
                             int desiredLength,
                             String padString)
Deprecated. See StringUtil

Parameters:
s - String to pad
desiredLength - ending length
padString - String to pad with (e.g, " ")
Returns:
padded String

padRight

public static String padRight(String s,
                              int desiredLength)
Deprecated. See StringUtil

Parameters:
s - String to pad
desiredLength - ending length
Returns:
padded String

padRight

public static String padRight(String s,
                              int desiredLength,
                              String padString)
Deprecated. See StringUtil

Parameters:
s - String to pad
desiredLength - ending length
padString - String to pad with (e.g, " ")
Returns:
padded String

join

public static String join(String[] args)
Deprecated. See StringUtil

Parameters:
args - An array of Strings to merge.
Returns:
The given strings concatenated together with a space between each.

join

public static String join(String delimiter,
                          Object[] args)
Deprecated. See StringUtil

Parameters:
delimiter - The delimiter.
args - An array of Strings to merge.
Returns:
The given strings concatenated together with the delimiter between each.

join

public static String join(String delimiter,
                          Object[] args,
                          boolean ignoreEmptyStrings)
Deprecated. See StringUtil

Parameters:
delimiter - The delimiter.
args - An array of Strings to merge.
ignoreEmptyStrings - Don't join empty strings
Returns:
The given strings concatenated together with the delimiter between each.

join

public static String join(String delimiter,
                          List args)
Deprecated. See StringUtil

Parameters:
delimiter - The delimiter.
args - A List of objects whose toString value are merged.
Returns:
The given object.toString values concatenated together with the delimiter between each.

join

public static String join(String delimiter,
                          List args,
                          boolean ignoreEmptyStrings)
Deprecated. See StringUtil

Parameters:
delimiter - The delimiter.
args - A List of objects whose toString value are merged.
ignoreEmptyStrings - Should ignore empty strings
Returns:
The given object.toString values concatenated together with the delimiter between each.

split

public static List split(Object source)
Deprecated. See StringUtil

Parameters:
source - The source object string.
Returns:
List of String tokens.

parseLineWords

public static List parseLineWords(String content,
                                  int[] indices,
                                  int[] lengths,
                                  String lineDelimiter,
                                  String commentString,
                                  boolean trimWords)
Deprecated. See StringUtil

Parameters:
content - The String to parse
indices - 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.
Returns:
A list of String arrays that holds the words.

split

public static List split(Object source,
                         String delimiter)
Deprecated. See StringUtil

Parameters:
source - The source object string.
delimiter - The delimiter to break up the sourceString on.
Returns:
List of String tokens.

split

public static List split(Object source,
                         String delimiter,
                         boolean trim)
Deprecated. See StringUtil

Parameters:
source - The source object string.
delimiter - The delimiter to break up the sourceString on.
trim - Do we string trim the tokens.
Returns:
List of String tokens.

split

public static List split(Object source,
                         String delimiter,
                         boolean trim,
                         boolean excludeZeroLength)
Deprecated. See StringUtil

Parameters:
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.
Returns:
List of String tokens.

split

public static String[] split(String s,
                             String delimiter,
                             int cnt)
Deprecated. See StringUtil

Parameters:
s - String to split
delimiter - token delimeter
cnt - max number of tokens
Returns:
array of strings or null if unable to split the string.

listToStringArray

public static String[] listToStringArray(List objectList)
Deprecated. See StringUtil

Parameters:
objectList - The list of objects.
Returns:
The array of the object string values.

listToString

public static String listToString(List l)
Deprecated. See StringUtil

Parameters:
l - list of objects
Returns:
semicolon separated String of Strings.

toString

public static List toString(List l)
Deprecated. See StringUtil

Parameters:
l - List of objects
Returns:
List of strings.

replace

public static String replace(String string,
                             String pattern,
                             String value)
Deprecated. See StringUtil

Parameters:
string - string to munge
pattern - pattern to replace
value - replacement value
Returns:
munged string

replaceList

public static String replaceList(String v,
                                 String[] patterns,
                                 String[] values)
Deprecated. See StringUtil

Parameters:
v - original String
patterns - patterns to match
values - replacement values
Returns:
munged String

replaceList

public static String replaceList(String v,
                                 List patterns,
                                 List values)
Deprecated. See StringUtil

Parameters:
v - original String
patterns - patterns to match
values - replacement values
Returns:
munged String

replaceList

public static List replaceList(List sourceList,
                               String[] patterns,
                               String[] values)
Deprecated. See StringUtil

Parameters:
sourceList - original list of Strings
patterns - patterns to replace
values - replacement values
Returns:
new list with replaced values

append

public static StringBuffer append(StringBuffer sb,
                                  Object s1)
Deprecated. See StringUtil

Parameters:
sb - StringBuffer to append to (may be null)
s1 - object to append
Returns:
StringBuffer with appended object

append

public static StringBuffer append(StringBuffer sb,
                                  Object s1,
                                  Object s2)
Deprecated. See StringUtil

Parameters:
sb - StringBuffer to append to (may be null)
s1 - first object to append
s2 - second object to append
Returns:
StringBuffer with appended objects `

append

public static StringBuffer append(StringBuffer sb,
                                  Object s1,
                                  Object s2,
                                  Object s3)
Deprecated. See StringUtil

Parameters:
sb - StringBuffer to append to (may be null)
s1 - first object to append
s2 - second object to append
s3 - third object to append
Returns:
StringBuffer with appended objects

append

public static StringBuffer append(StringBuffer sb,
                                  Object s1,
                                  Object s2,
                                  Object s3,
                                  Object s4)
Deprecated. See StringUtil

Parameters:
sb - StringBuffer to append to (may be null)
s1 - first object to append
s2 - second object to append
s3 - third object to append
s4 - fourth object to append
Returns:
StringBuffer with appended objects

append

public static StringBuffer append(StringBuffer sb,
                                  Object s1,
                                  Object s2,
                                  Object s3,
                                  Object s4,
                                  Object s5)
Deprecated. See StringUtil

Parameters:
sb - StringBuffer to append to (may be null)
s1 - first object to append
s2 - second object to append
s3 - third object to append
s4 - fourth object to append
s5 - fifth object to append
Returns:
StringBuffer with appended objects

parseCsv

public static List parseCsv(String s,
                            boolean skipFirst)
Deprecated. See StringUtil

Parameters:
s - String to parse
skipFirst - true to skip the first value
Returns:
list of parsed Strings

shorten

public static final String shorten(String s,
                                   int length)
Deprecated. See StringUtil

Parameters:
s - String to shorten
length - shortened length where elipses will start
Returns:
shortened string.

toString

public static String toString(Object[] array)
Deprecated. See StringUtil

Parameters:
array - array to print
Returns:
array as a String

addClassLoader

public static void addClassLoader(ClassLoader cl)
Add the given class loader into the list of custom class loaders

Parameters:
cl - The class loader

getClassLoaders

public static List<ClassLoader> getClassLoaders()
Get the list of dynamic class loaders

Returns:
List of dynamic classloaders

findClass

public static Class findClass(String className)
                       throws ClassNotFoundException
Find the Class for the given class name. This first checks any custom class loaders the app may be using. Next it just uses the standard Class.forName

Parameters:
className - The class name
Returns:
The class
Throws:
ClassNotFoundException - When the className could not be found

getPauseEveryTime

public static long getPauseEveryTime(int minutesDelta)
figure out how long to wait for

Parameters:
minutesDelta - time to wait for
Returns:
hummm

pauseEvery

public static void pauseEvery(int minutesDelta)
Pause every n minutes

Parameters:
minutesDelta - number of minutes

cloneArray

public static float[][] cloneArray(float[][] a)
Clone an array of floats

Parameters:
a - array to clone
Returns:
cloned array

reverseArray

public static float[] reverseArray(float[] a)
Reverse the array

Parameters:
a - input array
Returns:
the array in reverse order

subtractArray

public static float[][] subtractArray(float[][] a,
                                      float[][] b,
                                      float[][] c)
Set c=a-b and return c. If c is null then create a new array

Parameters:
a - the array
b - the the other array
c - the return array
Returns:
the new array

addArray

public static float[][] addArray(float[][] a,
                                 float[][] b,
                                 float[][] c)
Add two arrays together

Parameters:
a - the array
b - the the other array
c - the return array
Returns:
the new array

getRange

public static float[] getRange(float[][] a)
Get the range of all values

Parameters:
a - arrays of values
Returns:
the range (min,max)

getRanges

public static float[][] getRanges(float[][] a)
Get the ranges for each column

Parameters:
a - arrays of values
Returns:
the range (min,max) of each column

fillArray

public static void fillArray(float[][] a,
                             float value)
fill array with value

Parameters:
a - array
value - value

cloneArray

public static double[][] cloneArray(double[][] a)
Clone an array of doubles

Parameters:
a - array to clone
Returns:
cloned array

arraysEquals

public static boolean arraysEquals(double[] a,
                                   double[] b)
check for equality a or b can be null;

Parameters:
a - array 1
b - array 2
Returns:
equals

arraysEquals

public static boolean arraysEquals(int[] a,
                                   int[] b)
check for equality a or b can be null;

Parameters:
a - array 1
b - array 2
Returns:
equals

arraysEquals

public static boolean arraysEquals(float[] a,
                                   float[] b)
check for equality a or b can be null;

Parameters:
a - array 1
b - array 2
Returns:
equals

arraysEquals

public static boolean arraysEquals(String[] a,
                                   String[] b)
check for equality a or b can be null;

Parameters:
a - array 1
b - array 2
Returns:
equals

arraysEquals

public static boolean arraysEquals(float[][] a,
                                   float[][] b)
check for equality a or b can be null;

Parameters:
a - array 1
b - array 2
Returns:
equals

arraysEquals

public static boolean arraysEquals(double[][] a,
                                   double[][] b)
check for equality a or b can be null;

Parameters:
a - array 1
b - array 2
Returns:
equals

arraysEquals

public static boolean arraysEquals(int[][] a,
                                   int[][] b)
check for equality a or b can be null;

Parameters:
a - array 1
b - array 2
Returns:
equals

arraysEquals

public static boolean arraysEquals(int[][][] a,
                                   int[][][] b)
check for equality a or b can be null;

Parameters:
a - array 1
b - array 2
Returns:
equals

merge

public static float[] merge(float[] a,
                            float[] b)
Merge the two arrays into one. Either of the arrays can be null

Parameters:
a - array 1
b - array 2
Returns:
An array of length a.length + b.length with the values copied

interpolate

public static float[] interpolate(int cnt,
                                  float start,
                                  float end)
Do a linear interpolation with cnt points between start and end

Parameters:
cnt - number of points
start - start value
end - end value
Returns:
Array of interpolated points

copy

public static float[][] copy(float[][] pts,
                             int pointCnt)
Copy an array to another

Parameters:
pts - the input
pointCnt - the number of points to copy
Returns:
the copied array

expand

public static float[][] expand(float[][] pts)
Expand an array of points

Parameters:
pts - the points
Returns:
the expanded array

getRunnable

public static Runnable getRunnable()
Get a Runnable object

Returns:
the Runnable

printBits

public static void printBits(int b)
Print out the bit pattern in an integer

Parameters:
b - the integer

getStackTrace

public static String getStackTrace()
Return the stack trace of this calling thread

Returns:
The stack trace

getStackTrace

public static String getStackTrace(Throwable exc)
Get the stack trace from the given exception

Parameters:
exc - The exception to get the trace from
Returns:
The stack trace

main

public static void main(String[] args)
Test this class

Parameters:
args - ignored

find

public static int[] find(int value,
                         int[] array)
Find the indices of the array where it is equal to the value

Parameters:
value - the value to look for
array - the array
Returns:
the array of indices

find

public static int[] find(float value,
                         float[] array)
Find the indices of the array where it is equal to the value

Parameters:
value - the value to look for
array - the array
Returns:
the array of indices

find

public static int[] find(double value,
                         double[] array)
Find the indices of the array where it is equal to the value

Parameters:
value - the value to look for
array - the array
Returns:
the array of indices

isNaN

public static boolean isNaN(float[][] values)
Check if all the values in the array are NaNs

Parameters:
values - the array values
Returns:
true if all NaN

isNaN

public static boolean isNaN(double[][] values)
Check if all the values in the array are NaNs

Parameters:
values - array values
Returns:
true if all NaN