|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectucar.unidata.util.Misc
public class Misc
Static class of miscellaneous methods
| Field Summary | |
|---|---|
static boolean |
debug
debug flag |
static String |
MISSING
missing string |
| Constructor Summary | |
|---|---|
Misc()
Default constructor; does nothing |
|
| Method Summary | |
|---|---|
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 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 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 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 long |
gc()
Run the garbage collector. |
static boolean |
getBoolean(String stringValue,
boolean dflt)
Try to decode the given stringValue as an boolean. |
static List |
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 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 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 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 |
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)
Main method for testing |
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 |
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 Object[] |
reverseArray(Object[] fromArray,
Object[] toArray)
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< | |