|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjist.runtime.Util
public final class Util
Miscellaneous utilities used by JIST.
| Field Summary | |
|---|---|
static char |
IDENTIFIER_ESCAPE_CHAR
Escape character used when converting String into Java-safe identifiers. |
private static java.lang.Integer[] |
INTS
An array of Integers for small primitive integers. |
static java.lang.reflect.Method |
method_printType
Method stub for printType method. |
| Constructor Summary | |
|---|---|
Util()
|
|
| Method Summary | |
|---|---|
static void |
assertion(boolean cond)
Validate condition. |
static boolean |
contains(java.lang.Object[] set,
java.lang.Object item)
Return whether a given Objects exists within an Object array. |
static java.lang.String |
escapeChar(java.lang.String s,
char c)
Escape character in string. |
static java.lang.String |
escapeJavaIdent(java.lang.String s)
Escape string so that it conforms to Java identifier rules. |
static java.lang.reflect.Method |
findUniqueMethod(java.lang.Class c,
java.lang.String name)
Lookup method in a class by name. |
static java.lang.String |
getHexCode(char c)
Return hexadecimal representation of given character. |
static java.lang.String |
getHMS(long second)
Return seconds as string of hours, minutes and seconds. |
static int[] |
getRange(int max)
Return a range of integers in an array: [0, max). |
static byte[] |
getResourceBytes(java.lang.String name)
Get data of given named resource as byte array. |
static java.lang.Integer |
getSmallInteger(int i)
Return the Integer for a small integer, hopefully without a new allocation. |
static long |
getUsedMemory()
Return the number of memory bytes used, which is computed by subtracting the 'free' memory from 'total' memory. |
static java.lang.Object |
printType(java.lang.Object o)
Method that prints the type of the object passed to it. |
static byte[] |
readAll(java.io.InputStream in)
Read an entire stream and return byte[]. |
static double |
round(double num,
int decimal)
Round-off double to given number of decimal places. |
static void |
showStack()
Display a stack trace. |
static void |
showThreads()
Display the currently active threads. |
static int |
sign(long l)
Return the sign of a long. |
static void |
startIdleThread()
Start an idle thread. |
static java.lang.String |
stringJoin(java.lang.String[] strings,
java.lang.String delim)
Concatenate array of Strings separated by given delimeter. |
static java.lang.Object[] |
union(java.lang.Object[] set1,
java.lang.Object[] set2)
Return the set union of two array of objects. |
static java.lang.String[] |
union(java.lang.String[] set1,
java.lang.String[] set2)
Same as union, but for Strings. |
static java.lang.Object[] |
unique(java.lang.Object[] elements)
Return a set (array of unique objects). |
static java.lang.String[] |
unique(java.lang.String[] elements)
Same as unique, but for Strings. |
static java.lang.String |
unqualifiedName(java.lang.String s)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final char IDENTIFIER_ESCAPE_CHAR
private static final java.lang.Integer[] INTS
public static java.lang.reflect.Method method_printType
| Constructor Detail |
|---|
public Util()
| Method Detail |
|---|
public static boolean contains(java.lang.Object[] set,
java.lang.Object item)
set - an array of objects to test for membershipitem - object to test membership
public static java.lang.String escapeChar(java.lang.String s,
char c)
s - string to escapec - character to replace/escape
public static java.lang.String escapeJavaIdent(java.lang.String s)
s - string to escape
public static java.lang.String getHexCode(char c)
c - character to convert
public static java.lang.Object[] unique(java.lang.Object[] elements)
elements - array of objects, possibly with duplicates
public static java.lang.Object[] union(java.lang.Object[] set1,
java.lang.Object[] set2)
set1 - first set of objectsset2 - second set of objects
public static java.lang.String[] unique(java.lang.String[] elements)
elements - array of Strings, possibly with duplicates
public static java.lang.String[] union(java.lang.String[] set1,
java.lang.String[] set2)
set1 - first set of Stringsset2 - second set of Strings
public static void startIdleThread()
public static void showThreads()
public static java.lang.String stringJoin(java.lang.String[] strings,
java.lang.String delim)
strings - array of strings to concatenatedelim - delimeter to insert between each pair of strings
public static int[] getRange(int max)
max - range maximum limit
public static java.lang.Object printType(java.lang.Object o)
DUP
INVOKE Util.printType
o - some object
public static double round(double num,
int decimal)
num - number to rounddecimal - decimal places
public static long getUsedMemory()
public static void showStack()
public static byte[] readAll(java.io.InputStream in)
throws java.io.IOException
in - inputstream to devour
java.io.IOException - on error from given inputstreampublic static byte[] getResourceBytes(java.lang.String name)
name - resource to retrieve
public static java.lang.String getHMS(long second)
second - number of seconds
public static void assertion(boolean cond)
cond - condition to validate
public static java.lang.reflect.Method findUniqueMethod(java.lang.Class c,
java.lang.String name)
throws java.lang.NoSuchMethodException
c - class to scanname - method name
java.lang.NoSuchMethodException - if method not found or not uniquepublic static java.lang.Integer getSmallInteger(int i)
i - some integer to convert to an Integer
public static int sign(long l)
public static java.lang.String unqualifiedName(java.lang.String s)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||