Package ucar.unidata.util
Class Misc
java.lang.Object
ucar.unidata.util.Misc
Static class of miscellaneous methods
- Version:
- $Revision: 1.271 $
- Author:
- IDV development group.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic float[][]
addArray
(float[][] a, float[][] b, float[][] c) Add two arrays togetherstatic void
Add the given class loader into the list of custom class loadersstatic List
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) static StringBuffer
append
(StringBuffer sb, Object s1, Object s2) static StringBuffer
append
(StringBuffer sb, Object s1, Object s2, Object s3) static StringBuffer
static StringBuffer
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 arraystatic String
static String
cleanFileName
(String name) static double[][]
cloneArray
(double[][] a) Clone an array of doublesstatic float[][]
cloneArray
(float[][] a) Clone an array of floatsstatic List
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
Does the given array contain the given object.static boolean
containsRegExp
(String patternString) static boolean
containsString
(String string, List objects, boolean lowerCase) Does the the list contain the stringstatic float[][]
copy
(float[][] pts, int pointCnt) Copy an array to anotherstatic void
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 IOUtilstatic Object
deserialize
(byte[] bytes) Deserialize the given byte array into an objectstatic String
Post the form datastatic String
Post the form datastatic 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
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 pointsstatic void
Utility method to print an error and exitstatic void
Utility method to print an exception and exitstatic void
fillArray
(float[][] a, float value) fill array with valuestatic int[]
find
(double value, double[] array) Find the indices of the array where it is equal to the valuestatic int[]
find
(float value, float[] array) Find the indices of the array where it is equal to the valuestatic int[]
find
(int value, int[] array) Find the indices of the array where it is equal to the valuestatic Class
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
static Object
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 valuestatic 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> Get the list of dynamic class loadersstatic String
getClassMethod
(String path) Utility method that returns the ClassName.methodName part of the (possibly) full package.ClassName.methodName path.static String
Return the end part of the class namestatic long
Get the current timestatic DecimalFormat
getDecimalFormat
(double v) Return different pre-defined DecimalFormat objects depending on the value of the given doublestatic List
getDirectories
(File dir, boolean recurse) static List
getDirectories
(List dirs, boolean recurse) static String
static String
static String
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) static InputStream
getInputStream
(String filename, Class origin) static int
Try to decode the given stringValue as an integer.static Object
Return the last object in the given list or null if the list is empty.static File
getMostRecentFile
(File dir) static File
getMostRecentFile
(File dir, FileFilter filter) static File
getMostRecentFile
(File dir, FileFilter filter) static long
getPauseEveryTime
(int minutesDelta) figure out how long to wait forstatic boolean
getProperty
(Hashtable props, String prop, boolean dflt) Look up the prop in the given set of Hashtable.static double
getProperty
(Hashtable props, String prop, double dflt) get a double property from the props tablestatic 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 Color
getProperty
(Hashtable props, String prop, Color dflt) Look up the prop in the given set of properties.static String
getProperty
(Hashtable p, String prop, String dflt) Look up the String prop in the given set of properties.static PrototypeManager
Get the prototype managerstatic float[]
getRange
(float[][] a) Get the range of all valuesstatic float[][]
getRanges
(float[][] a) Get the ranges for each columnstatic Runnable
Get a Runnable objectstatic String
getSetterMethod
(String prop) For the given property name get the set method name, e.g., returns:static String
Return the stack trace of this calling threadstatic String
getStackTrace
(Throwable exc) Get the stack trace from the given exceptionstatic String
getSystemProperty
(String key, String dflt) Read the given system property.static String
Gets a (sort of) unique String identifier.static URL
Find the url with the given name as a resource relative to the given class.static String
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
Return the hashcode for the object.static boolean
Does the given file or url have the given suffixstatic boolean
haveNotSeen
(Object o, Hashtable map) The inverse of haveSeenstatic boolean
Checks to see if the object o is in the given Hashtable.static int
What is the index of the given objectstatic float[]
interpolate
(int cnt, float start, float end) Do a linear interpolation with cnt points between start and endstatic boolean
See if the string is HTML.static boolean
isHtmlFile
(String filenameOrUrl) static boolean
isImageFile
(String filename) static boolean
isNaN
(double[][] values) Check if all the values in the array are NaNsstatic boolean
isNaN
(float[][] values) Check if all the values in the array are NaNsstatic boolean
isTextFile
(String filename) static String
static String
static String
static String
static String
static String
static String
static String
listToString
(List l) static String[]
listToStringArray
(List objectList) static void
Test this classstatic String
static String
static <E> List
<E> makeUnique
(List<E> l) Make the list unique.static String
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
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
Create a Hashtable and add the given keys and their corresponding values into it.static Hashtable
newHashtable
(Hashtable ht, Object[] o) Create a Hashtable.static List
Create a List and add the argument to it.static List
Copy the objects with the given objectArray into a new List.static List
Create a List and add the arguments to it.static List
Create a List and add the arguments to it.static List
Create a List and add the arguments to it.static List
Create a List and add the arguments to it.static List
Create a List and add the arguments to it.static List
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
static String
static String
static String
static String
padZero
(int value, int numDigits) static List
static double
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 adelimiter
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 adelimiter
separated list of doubles.static int[]
The given sourceString is adelimiter
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 adelimiter
separated list of lats or lons.static List
parseLineWords
(String content, int[] indices, int[] lengths, String lineDelimiter, String commentString, boolean trimWords) static double
parseNumber
(String value) Provide a consistent parsing that takes into account localization of the String format of the given numeric valuestatic 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) Provide a consistent parsing that takes into account localization of the String format of the given numeric valuestatic void
pauseEvery
(int minutesDelta) Pause every n minutesstatic void
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 integerstatic void
Print the members of an Objectstatic 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) static byte[]
readBytes
(InputStream is) static byte[]
readBytes
(InputStream is, Object loadId) static String
readContents
(File file) static String
static String
readContents
(String contentName) static String
readContents
(String contentName, Class origin) static String
readContents
(String contentName, String dflt) static String
static String
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) static String
static String
replaceList
(String v, String[] patterns, String[] values) static String
replaceList
(String v, List patterns, List values) static List
replaceList
(List sourceList, String[] patterns, String[] values) static float[]
reverseArray
(float[] a) Reverse the arraystatic Object[]
reverseArray
(Object[] fromArray, Object[] toArray) Reverse an arraystatic List
reverseList
(List l) Reverse an arraystatic void
Call object.runMethod in a different threadstatic void
Call object.runMethod in a different thread.static void
Run theRunnable
.static void
Call object.runMethod in a different thread after a ms millisecond delaystatic void
Call r.run () in a different thread after a ms millisecond delaystatic Object
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 formstatic void
setCurrentTime
(Date date) Set the current timestatic 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 final String
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) static File[]
sortFilesOnAge
(File directory, FileFilter filter, boolean youngestFirst) static List
sortTuples
(List pairs, boolean ascending) The elements in the given list object arrays.static List
static List
static List
static List
static String[]
static boolean
startsWithVowel
(String value) static boolean
stringMatch
(String input, String patternString) static boolean
stringMatch
(String input, String patternString, boolean substring, boolean caseSensitive) static String
Remove any file extension from the given file name.static String
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 arraystatic double[][]
toDouble
(float[][] d) Convert to floatstatic double[]
toDouble
(int[] d) Convert int array to double arraystatic double[][]
toDouble
(int[][] d) Convert int array to double arraystatic double
A method for converting an object to a Double.static File[]
static float[]
toFloat
(double[] d) Convert double array to float arraystatic float[][]
toFloat
(double[][] d) Convert to floatstatic List
Copy the objects with the given objectArray into a new List.static List
toList
(Enumeration enumeration) Create a list from an enumerationstatic String
static List
static Vector
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) dummystatic long
Get the amount of used memorystatic FileFilter
wrapFilter
(FileFilter filter) static void
writeBytes
(File filename, byte[] contents) Write out a file to theFile
specified.static void
static void
static String
zeroString
(int value)
-
Field Details
-
debug
public static boolean debugdebug flag -
MISSING
missing string- See Also:
-
NaN
NaN string- See Also:
-
-
Constructor Details
-
Misc
public Misc()Default constructor; does nothing
-
-
Method Details
-
setPrototypeManager
Set the global prototype manager. We needed some palce to put this method.- Parameters:
prototypeManager
- The prototype manager
-
getPrototypeManager
Get the prototype manager- Returns:
- The prototype manager
-
getCurrentTime
public static long getCurrentTime()Get the current time- Returns:
- the time in milliseconds
-
setCurrentTime
Set the current time- Parameters:
date
- the date to use
-
toDouble
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. UseparseNumber(String)
instead.- Parameters:
o
- object in question- Returns:
- a double value
-
formatLatitude
Format a latitude to the given format.- Parameters:
value
- the value to formatformat
- the format- Returns:
- formatted value
- See Also:
-
formatLongitude
Format a longitude to the given format.- Parameters:
value
- the value to formatformat
- the formatuse360
- if true use 0-360 notation instead of -180 to 180 notation- Returns:
- formatted value
- See Also:
-
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 formatformat
- the formatisLatitude
- true if latitude, false if longitudeuse360
- if true use 0-360 notation instead of -180 to 180 notation- Returns:
- formatted value
-
decodeLatLon
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
Reverse an array- Parameters:
l
- The list- Returns:
- reversed array
-
reverseArray
Reverse an array- Parameters:
fromArray
- array to reversetoArray
- reversed array- Returns:
- reversed array
-
getClassName
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
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 onname
- name of the property. object must have setmethod. objectValue
- value of the propertyignoreError
- true to ignore errors- Returns:
- true if successful
- Throws:
IllegalAccessException
- security violationIllegalArgumentException
- illegal argumentInvocationTargetException
- 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 onmethod
- method to callobjectValue
- value of the methodignoreError
- true to ignore errors- Returns:
- true if successful
- Throws:
IllegalAccessException
- security violationIllegalArgumentException
- illegal argumentInvocationTargetException
- invocation problem
-
getInt
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
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
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
Make the list unique.- Type Parameters:
E
- the element type- Parameters:
l
- initial list- Returns:
- unique list
-
toList
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
Create a list from an enumeration- Parameters:
enumeration
- The enumeration- Returns:
- The list
-
newList
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
Utility to do a list get only if the index is ok. Else return null.- Parameters:
l
- Listindex
- Index- Returns:
- List value or null
-
createIntervalList
Create and return a List that holds Integers starting at start to end by step.- Parameters:
start
- The start valueend
- The end value.step
- The step- Returns:
- List of Integers.
-
sort
Sort the given List. Note: The return type may vary.- Parameters:
listToSort
- The list to sort.- Returns:
- A new List, sorted.
-
sortTuples
The elements in the given list object arrays. The sort is done on the first element of of the array.- Parameters:
pairs
- list to sortascending
- true for ascending sort- Returns:
- A new List, sorted.
-
parseProperties
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
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
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 tableprop
- property to look up.dflt
- default value- Returns:
- existing property value or default if it doesn't exist
-
getProperty
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 tableprop
- property namedflt
- default color- Returns:
- a color defined by the property value or the default
-
getProperty
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 propertiesprop
- property namedflt
- default value- Returns:
- value converted to a boolean or the default
-
getProperty
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 propertiesprop
- property namedflt
- default value- Returns:
- value converted to an int or the default
-
getProperty
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 propertiesprop
- property namedflt
- default value- Returns:
- value converted to a float or the default
-
getProperty
get a double property from the props table- Parameters:
props
- the propsprop
- the prop namedflt
- the default value if none found- Returns:
- the value
-
readProperties
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 filenameproperties
- Where to put the properties.origin
- Where to look for the properties file.- Returns:
- The properties object.
-
getURL
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 nameorigin
- Where to look.- Returns:
- The URL or null if not found.
-
appendUrlArgs
Create a url argument String with the given args. Example: "?arg1=value1invalid input: '&arg2'=value2"- Parameters:
base
- The base of the url.args
- The name/value pairs.- Returns:
- The contructed url string.
-
appendUrlArgs
Create a url argument String with the given args. Example: "?arg1=value1invalid input: '&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
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
Run theRunnable
.- Parameters:
r
- Runnable to run- See Also:
-
run
Call object.runMethod in a different thread- Parameters:
object
- The objectmethodName
- The method
-
run
Call object.runMethod in a different thread. If arg is non-null pass it to the method- Parameters:
object
- The objectmethodName
- The methodarg
- The arg
-
runInABit
Call object.runMethod in a different thread after a ms millisecond delay- Parameters:
ms
- delay (milliseconds)object
- The objectmethodName
- The methodarg
- The arg
-
runInABit
Call r.run () in a different thread after a ms millisecond delay- Parameters:
ms
- delay (milliseconds)r
- Runnable to run
-
doPost
Post the form data- Parameters:
action
- post actiondata
- data to post- Returns:
- posted data
-
doPost
Post the form data- Parameters:
action
- post actiondata
- data to postattrs
- data attributes- Returns:
- posted data
-
doPostAndGetConnection
Do an http post with the given action, writing the given data as the post data.- Parameters:
action
- post actiondata
- data to post- Returns:
- returned data
-
doPostAndGetConnection
Do an http post with the given action, writing the given data as the post data.- Parameters:
action
- post actiondata
- data to postattrs
- data attributes- Returns:
- returned data
-
getValue
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 valueprops
- property table to look up- Returns:
- the value, or
null
-
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
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
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
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. Ifnull
, we create a new one.o
- The array of (key,value) objects.- Returns:
- The added to Hashtable.
-
newHashtable
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
Create a Hashtable and add the given keys and their corresponding values into it.- Parameters:
key1
- key for tablevalue1
- corresponding value- Returns:
- A new Hashtable containg the given keys and values.
-
newHashtable
Create a Hashtable and add the given keys and their corresponding values into it.- Parameters:
key1
- first keyvalue1
- corresponding first valuekey2
- second keyvalue2
- 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 keyvalue1
- corresponding first valuekey2
- second keyvalue2
- corresponding second valuekey3
- third keyvalue3
- corresponding third value- Returns:
- A new Hashtable containg the given keys and values.
-
newHashtable
Create a Hashtable and add the given keys and their corresponding values into it.- Parameters:
keys
- set of keysvalues
- set of corresponding values- Returns:
- A new Hashtable containg the given keys and values.
-
getLast
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
Remove the last element in the given list.- Parameters:
l
- the list
-
newList
Create a List and add the argument to it.- Parameters:
o1
- object to add to list- Returns:
- a list with
object
in it
-
newList
Create a List and add the arguments to it.- Parameters:
o1
- first object to addo2
- second object to add- Returns:
- list with the two objects
-
newList
Create a List and add the arguments to it.- Parameters:
o1
- first object to addo2
- second object to addo3
- third object to add- Returns:
- list with the three objects
-
newList
Create a List and add the arguments to it.- Parameters:
o1
- first object to addo2
- second object to addo3
- third object to addo4
- fourth object to add- Returns:
- list with the four objects
-
newList
Create a List and add the arguments to it.- Parameters:
o1
- first object to addo2
- second object to addo3
- third object to addo4
- fourth object to addo5
- fifth object to add- Returns:
- list with the five objects
-
newList
Create a List and add the arguments to it.- Parameters:
o1
- first object to addo2
- second object to addo3
- third object to addo4
- fourth object to addo5
- fifth object to addo6
- fifth object to add- Returns:
- list with the five objects
-
newList
public static List newList(Object o1, Object o2, Object o3, Object o4, Object o5, Object o6, Object o7) Create a List and add the arguments to it.- Parameters:
o1
- first object to addo2
- second object to addo3
- third object to addo4
- fourth object to addo5
- fifth object to addo6
- fifth object to addo7
- fifth object to add- Returns:
- list with the five objects
-
isHtml
See if the string is HTML.- Parameters:
s
- String to check- Returns:
- true if it looks like HTML
-
typesMatch
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
dummy- Parameters:
formals
- dummyactuals
- dummy- Returns:
- dummy
-
findMethod
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 checkmethodName
- name of methodparamTypes
- parameter types- Returns:
- class method or
null
if one doesn't exist
-
getClassMethod
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
Return a list of Integer indexes, the indexes that each value object is in the all values list.- Parameters:
values
- The values we look upallValues
- The list that we look into- Returns:
- The list of indices.
-
getValuesFromIndices
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
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 checkparamTypes
- constructor parameter classes- Returns:
- constructor that matches or
null
if none match
-
getSystemProperty
Read the given system property. Return it if found. If not found then return the given dflt- Parameters:
key
- key for propertydflt
- default value- Returns:
- property value or default if not defined
-
serialize
Serialize the given object into its byte array form- Parameters:
object
- object to serialize- Returns:
- serialized byte array
-
deserialize
Deserialize the given byte array into an object- Parameters:
bytes
- serialized object bytes- Returns:
- Object
-
getDecimalFormat
Return different pre-defined DecimalFormat objects depending on the value of the given double- Parameters:
v
- value in question- Returns:
- appropriate decimal format pattern
-
format
Provide a consistent String formatting of the given double value- Parameters:
value
- value to format- Returns:
- formatted value
-
parseValue
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
deprecated replaced by
parseNumber(String)
- Throws:
NumberFormatException
- unable to parse the value
-
parseNumber
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
Return the hashcode for the object. Accounts for null objects by returning 1.- Parameters:
o1
- object in question- Returns:
o1
-s hashCode or 1 ifo1
is null
-
equals
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
- firstObject
in questiono2
- secondObject
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
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 compareo2
- second object to compare- Returns:
- true if both are non-null and their toString() methods are equal.
-
haveSeen
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 questionmap
- map of seen objects- Returns:
- true if o is in map
-
haveNotSeen
The inverse of haveSeen- Parameters:
o
- object in questionmap
- map of seen objects- Returns:
- true if o is not in map
-
printArray
Print out the values in an int array.- Parameters:
prefix
- prefix to append to outputarray
- array to print
-
printArray
Print out the values in an int array.- Parameters:
prefix
- prefix stringarray
- array to print
-
printArray
Print out the values in an int array.- Parameters:
prefix
- prefix stringarray
- array to print
-
printArray
Print out the values in a float array.- Parameters:
prefix
- prefix stringarray
- array to print
-
printArray
Print out the values in a double array.- Parameters:
prefix
- prefix stringarray
- array to print
-
printArray
Print out the values in a boolean array.- Parameters:
prefix
- prefix stringarray
- array to print
-
printMembers
Print the members of an Object- Parameters:
o
- Object in question
-
printStack
Print the stack trace for a given line of code.- Parameters:
msg
- message to printmaxLines
- number of lines in the stack to printonlyIfTraceContainsThisString
- if true, only print if it contains this String
-
printStack
Print the stack trace for a given line of code.- Parameters:
msg
- message to printmaxLines
- number of lines in the stack to print
-
printStack
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:
-
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
Utility method to print an exception and exit- Parameters:
exc
- exception that was thrown
-
fatal
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
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
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
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
The given sourceString is adelimiter
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
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
The given sourceString is adelimiter
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
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
The given sourceString is adelimiter
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
The given sourceString is adelimiter
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 rangelow
- low value of rangebase
- base value for centering ticksinterval
- 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 rangelow
- low value of rangebase
- base value for centering ticksinterval
- 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 rangemax
- maximum value in range- Returns:
- tick spacing
-
createLabelTable
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 rangemin
- low value of rangebase
- base value for centering ticksincrement
- 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
A method for printing a list. Each element is preceded by it's position in the list- Parameters:
l
- List to print
-
containsString
Does the the list contain the string- Parameters:
string
- the string to search forobjects
- the list of objectslowerCase
- check case insensibly- Returns:
- true if the string matches the string values of the objects
-
contains
Does the given array contain the given object.- Parameters:
object
- THe objectarray
- The array- Returns:
- Array contains object
-
indexOf
What is the index of the given object- Parameters:
object
- THe objectarray
- The array- Returns:
- index of object or -1
-
allStrings
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
Does the given file or url have the given suffix- Parameters:
fileOrUrl
- The name of the file or urlsuffix
- The suffix- Returns:
- Does the fileOrUrl have the suffix
-
isTextFile
- Parameters:
filename
- The filename to check.- Returns:
- Is the filename a text file. deprecated Use IOUtil
-
isImageFile
- Parameters:
filename
- The filename to check.- Returns:
- Is the filename an image file. deprecated Use IOUtil
-
isHtmlFile
- Parameters:
filenameOrUrl
- The filename to check.- Returns:
- Is the filename an html file. deprecated Use IOUtil
-
getInputStream
- Parameters:
filename
- name of file- Returns:
- corresponding input stream
- Throws:
FileNotFoundException
- couldn't find the fileIOException
- problem opening stream deprecated Use IOUtil
-
getInputStream
public static InputStream getInputStream(String filename, Class origin) throws FileNotFoundException, IOException - Parameters:
filename
- name of fileorigin
- relative origin point for file location- Returns:
- corresponding input stream
- Throws:
FileNotFoundException
- couldn't find the fileIOException
- problem opening stream deprecated Use IOUtil
-
readContents
- Parameters:
file
- file to read.- Returns:
- contents as a String
- Throws:
FileNotFoundException
- couldn't find the fileIOException
- problem opening stream deprecated Use IOUtil
-
readContents
- Parameters:
contentName
- URL or filenamedflt
- default to return if a problem- Returns:
- contents or default value deprecated Use IOUtil
-
readContents
- 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 fileIOException
- problem reading contents deprecated Use IOUtil
-
readContents
public static String readContents(String contentName, Class origin) throws FileNotFoundException, IOException - 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 fileIOException
- problem reading contents deprecated Use IOUtil
-
readContents
- Parameters:
is
- InputStream to read from- Returns:
- contents as a String
- Throws:
IOException
- problem reading contents deprecated Use IOUtil
-
readBytes
- Parameters:
is
- InputStream to read from- Returns:
- bytes read
- Throws:
IOException
- problem reading contents deprecated Use IOUtil
-
readBytes
- Parameters:
is
- InputStream to read fromloadId
- loadid- Returns:
- bytes read
- Throws:
IOException
- problem reading contents deprecated Use IOUtil
-
getMostRecentFile
- Parameters:
dir
- The directory to search in.- Returns:
- The most recent file (or null if none found). deprecated Use IOUtil
-
getMostRecentFile
- Parameters:
dir
- The directory to search in.filter
- TheFileFilter
to be used to limit what files we look at (may be null).- Returns:
- The most recent file (or null if none found). deprecated Use IOUtil
-
sortFilesOnAge
- Parameters:
directory
- The directoryfilter
- The filteryoungestFirst
- Ascending or descending deprecated Use IOUtil- Returns:
- The sorted files
-
sortFilesOnAge
- Parameters:
files
- The filesyoungestFirst
- Ascending or descending deprecated Use IOUtil- Returns:
- Just return the given array
-
toFiles
- Parameters:
files
- List of files- Returns:
- array of files deprecated Use IOUtil
-
wrapFilter
- Parameters:
filter
- The filechooser file filter- Returns:
- The javaio FileFilter. deprecated Use IOUtil
-
getMostRecentFile
- 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). deprecated Use IOUtil
-
getFileTail
- Parameters:
f
- The file path.- Returns:
- The file name. deprecated Use IOUtil
-
getFileRoot
- Parameters:
f
- The file path.- Returns:
- The file name. deprecated Use IOUtil
-
stripExtension
Remove any file extension from the given file name.- Parameters:
f
- The file path.- Returns:
- The file name without the extension. deprecated Use IOUtil
-
cleanFileName
- Parameters:
name
- The filename to be cleaned up- Returns:
- The cleaned up filename deprecated Use IOUtil
-
getFileExtension
- Parameters:
f
- The file path.- Returns:
- The file extension or an empty string if none found. deprecated Use IOUtil
-
writeFile
public static void writeFile(String filename, String contents) throws FileNotFoundException, IOException - Parameters:
filename
- filename to write tocontents
- file contents- Throws:
FileNotFoundException
- if the file does not existIOException
- if there is a problem writing deprecated Use IOUtil
-
writeFile
public static void writeFile(File filename, String contents) throws FileNotFoundException, IOException - Parameters:
filename
- File to write tocontents
- file contents- Throws:
FileNotFoundException
- if the file does not existIOException
- if there is a problem writing deprecated Use IOUtil
-
writeBytes
public static void writeBytes(File filename, byte[] contents) throws FileNotFoundException, IOException Write out a file to theFile
specified.- Parameters:
filename
- File to write tocontents
- file contents- Throws:
FileNotFoundException
- if the file does not existIOException
- if there is a problem writing deprecated Use IOUtil
-
readFile
- Parameters:
filename
- file nameorigin
- anchor point for relative location of filedflt
- default to return- Returns:
- contents as a String or
dflt
deprecated Use IOUtil
-
readFile
public static String readFile(String filename, Class origin) throws FileNotFoundException, IOException - Parameters:
filename
- file nameorigin
- anchor point for relative location of file- Returns:
- null if the file can't be found
- Throws:
FileNotFoundException
- if the file does not existIOException
- if there is a problem writing deprecated Use IOUtil
-
moveFile
- Parameters:
from
- File to moveto
- The destination- Throws:
FileNotFoundException
- When we cannot find the fileIOException
- When something untoward happens deprecated Use IOUtil
-
copyFile
- Parameters:
from
- File to copyto
- The destination- Throws:
FileNotFoundException
- When we cannot find the fileIOException
- When something untoward happens deprecated Use IOUtil
-
joinDir
- Parameters:
f1
- directory pathf2
- filename- Returns:
- concatenated String with the appropriate file separator deprecated Use IOUtil
-
joinDir
- Parameters:
f1
- directory pathfilename
- filename- Returns:
- concatenated String with the appropriate file separator deprecated Use IOUtil
-
makeDir
- Parameters:
path
- directory to make- Returns:
- the directory path deprecated Use IOUtil
-
makeDir
- Parameters:
f
- directory as a file- Returns:
- directory path deprecated Use IOUtil
-
getDirectories
- Parameters:
dir
- The directory to look atrecurse
- Do we recurse- Returns:
- List of subdirs (File) deprecated Use IOUtil
-
getDirectories
- Parameters:
dirs
- List of directories to look atrecurse
- Do we recurse- Returns:
- List of subdirs (File) deprecated Use IOUtil
-
pruneEmptyDirectories
- Parameters:
root
- Directory to prune deprecated Use IOUtil
-
deleteDirectory
deprecated Use IOUtil- Parameters:
root
- root
-
findMatch
- Parameters:
source
- Source String to match on.patternList
- List of objects whose toString is the pattern.dflt
- The default if nothing matches. deprecated See StringUtil- Returns:
- The Object whose toString matches the source or the dflt if no matches found.
-
findMatch
- 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. deprecated See StringUtil- Returns:
- The return Object whose toString matches the source or the dflt if no matches found.
-
containsRegExp
- Parameters:
patternString
- pattern string to check deprecated See StringUtil- Returns:
- true if it contains (^,*,$,+).
-
stringMatch
- Parameters:
input
- The input source string.patternString
- The regular expression pattern. deprecated See StringUtil- Returns:
- true if the pattern match the input.
-
stringMatch
public static boolean stringMatch(String input, String patternString, boolean substring, boolean caseSensitive) - Parameters:
input
- The input source string.patternString
- The regular expression pattern.substring
- Search for substringscaseSensitive
- Is case sensitive deprecated See StringUtil- Returns:
- true if the pattern match the input.
-
startsWithVowel
- Parameters:
value
- String to check deprecated See StringUtil- Returns:
- true if value starts with a, e, i, o, or u (but not sometimes y). Check is case insensitive.
-
breakText
- Parameters:
text
- The text to convertinsert
- string to insertlineSize
- line size to insert at deprecated See StringUtil- Returns:
- The text with added br tags.
-
stripTags
- Parameters:
html
- The source html string. deprecated See StringUtil- Returns:
- The raw text.
-
removeWhitespace
- Parameters:
inputString
- The string to remove the whitespace. deprecated See StringUtil- Returns:
- The whitespaceless result.
-
zeroString
- Parameters:
value
- The value. deprecated See StringUtil- Returns:
- The String represenation of the value, padded with a leading "0" if value < 10
-
padZero
- Parameters:
value
- The value.numDigits
- number of digits deprecated See StringUtil- Returns:
- The String represenation of the value, padded with leading "0"-s if value < 10E(numDigits-1)
-
padLeft
- Parameters:
s
- String to paddesiredLength
- ending length deprecated See StringUtil- Returns:
- padded String
-
padLeft
- Parameters:
s
- String to paddesiredLength
- ending lengthpadString
- String to pad with (e.g, " ") deprecated See StringUtil- Returns:
- padded String
-
padRight
- Parameters:
s
- String to paddesiredLength
- ending length deprecated See StringUtil- Returns:
- padded String
-
padRight
- Parameters:
s
- String to paddesiredLength
- ending lengthpadString
- String to pad with (e.g, " ") deprecated See StringUtil- Returns:
- padded String
-
join
- Parameters:
args
- An array of Strings to merge. deprecated See StringUtil- Returns:
- The given strings concatenated together with a space between each.
-
join
- Parameters:
delimiter
- The delimiter.args
- An array of Strings to merge. deprecated See StringUtil- Returns:
- The given strings concatenated together with the delimiter between each.
-
join
- Parameters:
delimiter
- The delimiter.args
- An array of Strings to merge.ignoreEmptyStrings
- Don't join empty strings deprecated See StringUtil- Returns:
- The given strings concatenated together with the delimiter between each.
-
join
- Parameters:
delimiter
- The delimiter.args
- A List of objects whose toString value are merged. deprecated See StringUtil- Returns:
- The given object.toString values concatenated together with the delimiter between each.
-
join
- Parameters:
delimiter
- The delimiter.args
- A List of objects whose toString value are merged.ignoreEmptyStrings
- Should ignore empty strings deprecated See StringUtil- Returns:
- The given object.toString values concatenated together with the delimiter between each.
-
split
- Parameters:
source
- The source object string. deprecated See StringUtil- Returns:
- List of String tokens.
-
parseLineWords
public static List parseLineWords(String content, int[] indices, int[] lengths, String lineDelimiter, String commentString, boolean trimWords) - Parameters:
content
- The String to parseindices
- the index in the line which defines the word start.lengths
- the length of each word.lineDelimiter
- What to split the line content string on (usually "\n").commentString
- If non-null defines the comment String in the content.trimWords
- Do we trim each word. deprecated See StringUtil- Returns:
- A list of String arrays that holds the words.
-
split
- Parameters:
source
- The source object string.delimiter
- The delimiter to break up the sourceString on. deprecated See StringUtil- Returns:
- List of String tokens.
-
split
- Parameters:
source
- The source object string.delimiter
- The delimiter to break up the sourceString on.trim
- Do we string trim the tokens. deprecated See StringUtil- Returns:
- List of String tokens.
-
split
- 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. deprecated See StringUtil- Returns:
- List of String tokens.
-
split
- Parameters:
s
- String to splitdelimiter
- token delimetercnt
- max number of tokens deprecated See StringUtil- Returns:
- array of strings or
null
if unable to split the string.
-
listToStringArray
- Parameters:
objectList
- The list of objects. deprecated See StringUtil- Returns:
- The array of the object string values.
-
listToString
- Parameters:
l
- list of objects deprecated See StringUtil- Returns:
- semicolon separated String of Strings.
-
toString
- Parameters:
l
- List of objects deprecated See StringUtil- Returns:
- List of strings.
-
replace
- Parameters:
string
- string to mungepattern
- pattern to replacevalue
- replacement value deprecated See StringUtil- Returns:
- munged string
-
replaceList
- Parameters:
v
- original Stringpatterns
- patterns to matchvalues
- replacement values deprecated See StringUtil- Returns:
- munged String
-
replaceList
- Parameters:
v
- original Stringpatterns
- patterns to matchvalues
- replacement values deprecated See StringUtil- Returns:
- munged String
-
replaceList
- Parameters:
sourceList
- original list of Stringspatterns
- patterns to replacevalues
- replacement values deprecated See StringUtil- Returns:
- new list with replaced values
-
append
- Parameters:
sb
- StringBuffer to append to (may benull
)s1
- object to append deprecated See StringUtil- Returns:
- StringBuffer with appended object
-
append
- Parameters:
sb
- StringBuffer to append to (may benull
)s1
- first object to appends2
- second object to append deprecated See StringUtil- Returns:
- StringBuffer with appended objects `
-
append
- Parameters:
sb
- StringBuffer to append to (may benull
)s1
- first object to appends2
- second object to appends3
- third object to append deprecated See StringUtil- Returns:
- StringBuffer with appended objects
-
append
- Parameters:
sb
- StringBuffer to append to (may benull
)s1
- first object to appends2
- second object to appends3
- third object to appends4
- fourth object to append deprecated See StringUtil- Returns:
- StringBuffer with appended objects
-
append
public static StringBuffer append(StringBuffer sb, Object s1, Object s2, Object s3, Object s4, Object s5) - Parameters:
sb
- StringBuffer to append to (may benull
)s1
- first object to appends2
- second object to appends3
- third object to appends4
- fourth object to appends5
- fifth object to append deprecated See StringUtil- Returns:
- StringBuffer with appended objects
-
parseCsv
- Parameters:
s
- String to parseskipFirst
- true to skip the first value deprecated See StringUtil- Returns:
- list of parsed Strings
-
shorten
- Parameters:
s
- String to shortenlength
- shortened length where elipses will start deprecated See StringUtil- Returns:
- shortened string.
-
toString
- Parameters:
array
- array to print deprecated See StringUtil- Returns:
- array as a String
-
addClassLoader
Add the given class loader into the list of custom class loaders- Parameters:
cl
- The class loader
-
getClassLoaders
Get the list of dynamic class loaders- Returns:
- List of dynamic classloaders
-
findClass
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 arrayb
- the the other arrayc
- 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 arrayb
- the the other arrayc
- 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
- arrayvalue
- 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 1b
- 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 1b
- 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 1b
- array 2- Returns:
- equals
-
arraysEquals
check for equality a or b can be null;- Parameters:
a
- array 1b
- 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 1b
- 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 1b
- 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 1b
- 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 1b
- 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 1b
- 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 pointsstart
- start valueend
- end value- Returns:
- Array of interpolated points
-
copy
public static float[][] copy(float[][] pts, int pointCnt) Copy an array to another- Parameters:
pts
- the inputpointCnt
- 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
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
Return the stack trace of this calling thread- Returns:
- The stack trace
-
getStackTrace
Get the stack trace from the given exception- Parameters:
exc
- The exception to get the trace from- Returns:
- The stack trace
-
main
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 forarray
- 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 forarray
- 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 forarray
- 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
-