|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.ksu.cis.projects.bogor.util.Util
public final class Util
This class provides miscellaneous helper methods.
Constructor Summary | |
---|---|
Util()
|
Method Summary | ||
---|---|---|
static boolean |
assertInstanceof(Collection<?> collection,
Class c)
Asserts elements of a collection as instanceof a class. |
|
static boolean |
assertNonNull(Object[] array)
Asserts non-null. |
|
static boolean |
assertNonNull(Object[][] array)
Asserts non-null. |
|
static boolean |
checkInstanceof(Collection<?> collection,
Class c)
Deterines whether all elements of a collection belong to a certain class. |
|
static boolean |
checkInstanceof(Object[] collection,
Class c)
Deterines whether all elements of an array belong to a certain class. |
|
static int |
compare(double d1,
double d2)
Compare two doubles. |
|
static int |
compare(float f1,
float f2)
Compare two floats. |
|
static int |
compare(int i1,
int i2)
Compare two integers. |
|
static int |
compare(long l1,
long l2)
Compare two longs. |
|
static String |
decodeString(String s)
|
|
static String |
diff(String file1,
String file2)
Compare two files using diff. |
|
static String |
encodeString(String s)
|
|
static String |
encodeXML(String s)
Encode a string to XML string. |
|
static int |
fact(int x)
|
|
static Class[] |
getInterfaces(Class c)
Calculate the set of all interfaces extended by a particular interface. |
|
static int |
search(int[] array,
int key)
|
|
static
|
sort(T[] elements)
|
|
static List<String> |
splitCommaSeparatedList(String input)
|
|
static String |
toString(Collection<?> collection,
String indent)
Pretty print a collection. |
|
static String |
toString(int[] items)
Pretty print a sorted sequence of integers. |
|
static String |
toString(IntIntTable map,
String indent)
Pretty print an int to int map. |
|
static
|
toString(IntObjectTable<V> map,
String indent)
Pretty print an int to object map. |
|
static String |
toString(Map<?,?> map,
String indent)
Pretty print a map. |
|
static String |
toString(Object[] map,
String indent)
Pretty print an int to object map. |
|
static
|
toString(ObjectIntTable<K> map,
Class<K> keyClass,
String indent)
Pretty print an object to int map. |
|
static boolean |
warnAssert(PrintWriter pw,
String text)
|
|
static int |
widthInBits(int n)
Calculate how many bits wide a number is, i.e. |
|
static int |
widthInBits(long n)
Calculate how many bits wide a number is, i.e. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Util()
Method Detail |
---|
public static Class[] getInterfaces(Class c)
c
- class object for the leaf-level interface type
c
public static boolean assertInstanceof(Collection<?> collection, Class c)
collection
- The collection whose elements to be asserted. Must be
non-null.c
- The class/type of instanceof. Must be non-null.
public static boolean assertNonNull(Object[] array)
array
- The array. Must be non-null. Each element must be non-null.
public static boolean assertNonNull(Object[][] array)
array
- The array. Must be non-null. Each element must be non-null.
public static boolean checkInstanceof(Collection<?> collection, Class c)
collection
- The collection whose elements should be tested. Must be
non-null.c
- The class/type of instanceof. Must be non-null.
public static boolean checkInstanceof(Object[] collection, Class c)
collection
- The collection whose elements should be tested. Must be
non-null.c
- The class/type of instanceof. Must be non-null.
public static int compare(int i1, int i2)
i1
- An integer.i2
- Another integer.
public static int compare(long l1, long l2)
l1
- A long.l2
- Another long.
public static int compare(double d1, double d2)
d1
- A double.d2
- Another double.
public static int compare(float f1, float f2)
f1
- A float.f2
- Another float.
public static String decodeString(String s)
public static String diff(String file1, String file2)
file1
- The first file. Non-null.file2
- The second file. Non-null.
public static String encodeString(String s)
public static String encodeXML(String s)
s
- The string to be encoded.
public static int fact(int x)
public static int search(int[] array, int key)
public static <T> T[] sort(T[] elements)
public static List<String> splitCommaSeparatedList(String input)
public static String toString(Map<?,?> map, String indent)
map
- The map to be pretty printed.
public static <K> String toString(ObjectIntTable<K> map, Class<K> keyClass, String indent)
map
- The map to be pretty printed.
public static <V> String toString(IntObjectTable<V> map, String indent)
map
- The map to be pretty printed.
public static String toString(IntIntTable map, String indent)
map
- The map to be pretty printed.
public static String toString(Object[] map, String indent)
map
- The map to be pretty printed.
public static String toString(int[] items)
map
- The map to be pretty printed.
public static String toString(Collection<?> collection, String indent)
collection
- The collection to be pretty printed.
public static boolean warnAssert(PrintWriter pw, String text)
public static int widthInBits(int n)
n
- The number to check bits width on. (author Dirk Bosmans
Dirk.Bosmans@tijd.com)
public static int widthInBits(long n)
n
- The number to check bits width on.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |