|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.miginfocom.util.MigUtil
public class MigUtil
Generic utility class.
| Field Summary | |
|---|---|
static int |
BIG_INT
Use instead of Integer.MAX_VALUE to denote some generic big value. |
static long |
BIG_LONG
Use instead of Integer.MAX_VALUE to denote some generic big value. |
static boolean |
DEBUG
|
static javax.swing.JFrame |
dFrame
|
static java.awt.Rectangle[] |
EMPTY_RECT_ARRAY
Rectangle[0]. |
static int |
SMALL_INT
Use instead of Integer.MAX_VALUE to denote some generic small value. |
static long |
SMALL_LONG
Use instead of Integer.MAX_VALUE to denote some generic small value. |
| Constructor Summary | |
|---|---|
MigUtil()
|
|
| Method Summary | |
|---|---|
static int[] |
addToArray(int[] source,
int o,
int index)
Creates a new array, copy the source array but insets o at index. |
static java.lang.Object[] |
addToArray(java.lang.Object[] source,
java.lang.Object o,
int index)
Creates a new array, copy the source array but insets o at index. |
static boolean |
canHandleThreads()
Returns if there is enough permissions to start/stop threads. Caches check so it will be really fast from 2:nd call.. |
static void |
checkComponentVersion(int version)
Check for a certain version and throws a IllegalAccessException if the version is too small. |
static void |
drawDebugRect(java.awt.Graphics2D g,
java.awt.Shape s,
java.awt.Color c)
Draws a red rectanlge at the exact bounds |
static boolean |
equals(java.lang.Object o1,
java.lang.Object o2)
Compares two objects for equality but in a safe way considering null values |
static boolean |
equalsLenient(java.lang.Object o1,
java.lang.Object o2)
Compares two objects for equality but in a safe way considering null values. |
static int |
findIndex(java.lang.Object[] a,
java.lang.Object o,
boolean ref)
Returns the index if the element that equals or is same as o. |
static java.lang.String[] |
flatten(java.lang.String[][] str)
Flattens the two dimensional array into one with all possible combinations. |
static java.lang.String |
getFirstUpperCase(java.lang.String s)
Makes sure the first character is upper case. |
static java.lang.String |
getSimpleClassName(java.lang.Class c)
Returns the simple class name of the class without the package hierarchy. |
static java.lang.String |
getStackTrace()
Returns the stach trace for the current thread. |
static java.lang.String |
getStackTrace(java.lang.Throwable t)
Returns the stach trace for the current thread. |
static boolean |
inCSString(java.lang.String str,
java.lang.String csStr)
Returns if a string is in a comma separaded string. |
static java.lang.String |
intToString(int i,
int numChars)
Returns a string with at least length numChars by adding zeros before. |
static boolean |
isAtLeastJRE6()
|
static boolean |
isSandbox()
Returns is we are currently running in a sandbox by checking if we can read system properties. Caches check so it will be really fast from 2:nd call.. |
static boolean |
isTrue(java.lang.Object o)
Return true if v is a Boolean that is true OR a when converted to a String
it equals (ignoring case) "true". |
static void |
printToDebugDialog(java.lang.String s)
|
static java.lang.Object[] |
removeFromArray(java.lang.Object[] arr,
int index)
Creates a new array that is one lement shorer and doesn't have element at index. |
static java.lang.Object[] |
removeFromArray(java.lang.Object[] arr,
java.lang.Object o,
boolean ref)
Returns an array that is either new but same as arr with o removed
or returns arr itself if o wasn't found. |
static java.lang.Object[] |
removeNullArrayElements(java.lang.Object[] arr)
Remove all null elements and return the cleaned array. |
static void |
removeNullElements(java.util.List list)
Remove all null elements from the list |
static java.util.ArrayList |
removeNullElements(java.lang.Object[] arr)
Remove all null elements and return the elements in a list |
static int |
toBounds(int c,
int min,
int max)
Returns a cell index within bounds. |
static java.lang.String |
toCSString(java.lang.String[] strings)
Returns a comma separated string. |
static java.lang.String |
toCSString(java.lang.String[] strings,
java.lang.String elementPrefix,
java.lang.String elementSuffix)
Returns a comma separated string. |
static int[] |
toIntArray(java.lang.String s,
char sep)
Parses a string and returns it in those parts of the string that are separated with a sep converted to ints. |
static java.lang.String[] |
toTokens(java.lang.String s,
char sep)
Parses a string and returns it in those parts of the string that are separated with a sep |
static void |
TRACE(java.lang.String errorMsg)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.awt.Rectangle[] EMPTY_RECT_ARRAY
Rectangle[0].
public static final int BIG_INT
Integer.MAX_VALUE to denote some generic big value. Not Integer.MAX_VALUE since
it's so close to overflow to negative...
public static final int SMALL_INT
Integer.MAX_VALUE to denote some generic small value. Not Integer.MIN_VALUE since
it's so close to overflow to negative...
public static final long BIG_LONG
Integer.MAX_VALUE to denote some generic big value. Not Integer.MAX_VALUE since
it's so close to overflow to negative...
public static final long SMALL_LONG
Integer.MAX_VALUE to denote some generic small value. Not Integer.MIN_VALUE since
it's so close to overflow to negative...
public static final boolean DEBUG
public static javax.swing.JFrame dFrame
| Constructor Detail |
|---|
public MigUtil()
| Method Detail |
|---|
public static void TRACE(java.lang.String errorMsg)
public static boolean isAtLeastJRE6()
public static void checkComponentVersion(int version)
IllegalAccessException if the version is too small.
version - E.g. 600 for ver 6.0.0.public static java.lang.String getFirstUpperCase(java.lang.String s)
s - The string. May be "" or null in which case they are returned unchanged.
public static java.lang.String getStackTrace()
public static java.lang.String getStackTrace(java.lang.Throwable t)
public static final boolean isSandbox()
true is sandbox.public static final boolean canHandleThreads()
true if allowed.
public static final int[] addToArray(int[] source,
int o,
int index)
o at index.
Optimized for smallish arrays (doesn't use System.arrayCopy().
source - The source array to copy. Not null.o - The integer to insert. Might be null.index - The index to insert o at. If larger than what fits in the new array it will be
put last in it. A very big value can therefore be used to ensure it will be placed last.
public static final java.lang.Object[] addToArray(java.lang.Object[] source,
java.lang.Object o,
int index)
o at index.
Optimized for smallish arrays (doesn't use System.arrayCopy().
source - The source array to copy. Not null.o - The object to insert. Might be null.index - The index to insert o at. If larger than what fits in the new array it will be
put last in it. A very big value can therefore be used to ensure it will be placed last.
public static final java.lang.Object[] removeFromArray(java.lang.Object[] arr,
int index)
index.
Optimized for smallish arrays (doesn't use System.arrayCopy().
arr - The array to remove from and copy. Not null and length must be > 1.index - The index of the element to remove. Must be a valid array index.
index.
public static final java.lang.Object[] removeFromArray(java.lang.Object[] arr,
java.lang.Object o,
boolean ref)
arr with o removed
or returns arr itself if o wasn't found.
Optimized for smallish arrays (doesn't use System.arrayCopy().
arr - The array to remove from and copy. Not null and length must be > 1.o - The object to remove. Either by equals or the actual object.ref - If true then == is used, otherquse .equals is used to check for equality.
o. Returns arr if o couldn't
be found.
public static final int findIndex(java.lang.Object[] a,
java.lang.Object o,
boolean ref)
o.
a - The array to check. Not null.o - The object to check for. May be null. null == null and null equals null.ref - If true then == is used, otherquse .equals is used to check for equality.
o is in, or equals, any element in the array that index is returned.
public static final java.lang.String intToString(int i,
int numChars)
numChars by adding zeros before.
e.g. toString(1, 3) returns "001"
e.g.. toString(1234, 2) returns "1234"
i - The integer to return as a stringnumChars - The least number of chars to return. Max 20.public static final java.lang.String[] flatten(java.lang.String[][] str)
Example:
str = new String[][] { // Internal arrays explanation:
{"1", "2"}, // ix[0] => 0, 1
{"3", "4", "5"}, // ix[1] => 0, 1, 2, 0, 1, 2
{"6", "7"} // ix[2] => 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1
};
Becomes: {"136", "137, "146, "147, "156, "257, "236", "237, "246, "247, "256, "257"}
str - The two dimentsional array. All arrays must be of length %gt 0!!.
public static final boolean isTrue(java.lang.Object o)
true if v is a Boolean that is true OR a when converted to a String
it equals (ignoring case) "true".
o - The value to check if it if "true". null returns false.
true or false...
public static final java.lang.String[] toTokens(java.lang.String s,
char sep)
sep
s - The string to parse. If it starts and/or ends with a sep the first and/or last element returned will be "". If
two sep are next to eachother and empty element will be "between" the periods. The sep themselves will never be returned.
sep. Never null and at least of size 1
public static final int[] toIntArray(java.lang.String s,
char sep)
sep converted to ints.
s - The string to parse. all sep must be surrounded by integer strings. They do not need to be trimmed though, that will be done for each token.
null if there was a parsing error or the string was empty.public static java.lang.String toCSString(java.lang.String[] strings)
strings - The strings. null elements will be ignored. If null "" is returned
public static java.lang.String toCSString(java.lang.String[] strings,
java.lang.String elementPrefix,
java.lang.String elementSuffix)
strings - The strings. null elements will be ignored. If null "" is returnedelementPrefix - Will be added first to every element. For instance \". null means no prefix.elementSuffix - Will be added last to every element. For instance \" null means no suffix.
public static java.lang.String getSimpleClassName(java.lang.Class c)
c - The class to return the name for. Not null.
public static final boolean equals(java.lang.Object o1,
java.lang.Object o2)
null values
o1 - the first objecto2 - the second object
true if o1.equals(o2) or the obects are equals (==). null == null !
public static final boolean equalsLenient(java.lang.Object o1,
java.lang.Object o2)
null values. Does the comparison
in a lenient way so that:null equals: null, "null", "false", "" and "0" using the .toString() method.
o1 - the first objecto2 - the second object
true if o1.equals(o2) or the obects are equals (==). null == null !
public static final boolean inCSString(java.lang.String str,
java.lang.String csStr)
str - The string to search for. Not null but can be empty. Must not contain commas.csStr - A string with possibly comma separated sub-strings. Not null.
str is within csStr
public static final int toBounds(int c,
int min,
int max)
c - the cell that may be outside the boundsmin - The minimm value of c;max - The maximum value of c;
public static final void removeNullElements(java.util.List list)
list - The array that might contain null elements.public static final java.util.ArrayList removeNullElements(java.lang.Object[] arr)
arr - The array that might contain null elements.
null. Never null.public static final java.lang.Object[] removeNullArrayElements(java.lang.Object[] arr)
arr - The array that might contain null elements.
null. Never null. Might be arr.
public static final void drawDebugRect(java.awt.Graphics2D g,
java.awt.Shape s,
java.awt.Color c)
public static void printToDebugDialog(java.lang.String s)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||