| java.lang.Object org.eclipse.jface.util.Util
Util | final public class Util (Code) | |
A static class providing utility methods to all of JFace.
since: 3.1 |
Method Summary | |
final public static void | assertInstance(Object object, Class c) Verifies that the given object is an instance of the given class. | final public static int | compare(boolean left, boolean right) Compares two boolean values. | final public static int | compare(int left, int right) Compares two integer values. | final public static int | compare(Comparable left, Comparable right) Compares to comparable objects -- defending against null .
Parameters: left - The left object to compare; may be null . Parameters: right - The right object to compare; may be null . | final public static int | compare(Comparable[] left, Comparable[] right) Compares two arrays of comparable objects -- accounting for
null .
Parameters: left - The left array to be compared; may be null . Parameters: right - The right array to be compared; may be null . | final public static int | compare(List left, List right) Compares two lists -- account for null . | final public static boolean | endsWith(Object[] left, Object[] right, boolean equals) Tests whether the first array ends with the second array.
Parameters: left - The array to check (larger); may be null . Parameters: right - The array that should be a subsequence (smaller); may benull . Parameters: equals - Whether the two array are allowed to be equal. | final public static boolean | equals(Object left, Object right) Checks whether the two objects are null -- allowing for
null .
Parameters: left - The left object to compare; may be null . Parameters: right - The right object to compare; may be null . | final public static boolean | equals(Object[] leftArray, Object[] rightArray) Tests whether two arrays of objects are equal to each other. | final public static int | hashCode(int i) Provides a hash code based on the given integer value. | final public static int | hashCode(Object object) Provides a hash code for the object -- defending against
null .
Parameters: object - The object for which a hash code is required. | final public static int | hashCode(Object[] objects) Computes the hash code for an array of objects, but with defense against
null .
Parameters: objects - The array of objects for which a hash code is needed; may benull . | final public static boolean | startsWith(Object[] left, Object[] right, boolean equals) Checks whether the second array is a subsequence of the first array, and
that they share common starting elements.
Parameters: left - The first array to compare (large); may be null . Parameters: right - The second array to compare (small); may be null . Parameters: equals - Whether it is allowed for the two arrays to be equivalent. | final public static String | toString(Object[] array) Converts an array into a string representation that is suitable for
debugging.
Parameters: array - The array to convert; may be null . | final public static String | translateString(ResourceBundle resourceBundle, String key, String defaultString) Provides a translation of a particular key from the resource bundle.
Parameters: resourceBundle - The key to look up in the resource bundle; should not benull . Parameters: key - The key to look up in the resource bundle; should not benull . Parameters: defaultString - The value to return if the resource cannot be found; may benull . |
EMPTY_SORTED_SET | final public static SortedSet EMPTY_SORTED_SET(Code) | | An unmodifiable, empty, sorted set. This value is guaranteed to never
change and never be null .
|
ZERO_LENGTH_STRING | final public static String ZERO_LENGTH_STRING(Code) | | A common zero-length string. It avoids needing write NON-NLS
next to code fragments. It's also a bit clearer to read.
|
assertInstance | final public static void assertInstance(Object object, Class c)(Code) | | Verifies that the given object is an instance of the given class.
Parameters: object - The object to check; may be null . Parameters: c - The class which the object should be; must not benull . |
compare | final public static int compare(boolean left, boolean right)(Code) | | Compares two boolean values. false is considered to be
"less than" true .
Parameters: left - The left value to compare Parameters: right - The right value to compare -1 if the left is false and theright is true . 1 if the oppositeis true. If they are equal, then it returns 0 . |
compare | final public static int compare(int left, int right)(Code) | | Compares two integer values.
Parameters: left - The left value to compare Parameters: right - The right value to compare left - right |
compare | final public static int compare(Comparable left, Comparable right)(Code) | | Compares to comparable objects -- defending against null .
Parameters: left - The left object to compare; may be null . Parameters: right - The right object to compare; may be null . The result of the comparison. null is consideredto be the least possible value. |
compare | final public static int compare(Comparable[] left, Comparable[] right)(Code) | | Compares two arrays of comparable objects -- accounting for
null .
Parameters: left - The left array to be compared; may be null . Parameters: right - The right array to be compared; may be null . The result of the comparison. null is consideredto be the least possible value. A shorter array is consideredless than a longer array. |
compare | final public static int compare(List left, List right)(Code) | | Compares two lists -- account for null . The lists must
contain comparable objects.
Parameters: left - The left list to compare; may be null . Thislist must only contain instances of Comparable . Parameters: right - The right list to compare; may be null . Thislist must only contain instances of Comparable . The result of the comparison. null is consideredto be the least possible value. A shorter list is considered lessthan a longer list. |
endsWith | final public static boolean endsWith(Object[] left, Object[] right, boolean equals)(Code) | | Tests whether the first array ends with the second array.
Parameters: left - The array to check (larger); may be null . Parameters: right - The array that should be a subsequence (smaller); may benull . Parameters: equals - Whether the two array are allowed to be equal. true if the second array is a subsequence of thearray list, and they share end elements. |
equals | final public static boolean equals(Object left, Object right)(Code) | | Checks whether the two objects are null -- allowing for
null .
Parameters: left - The left object to compare; may be null . Parameters: right - The right object to compare; may be null . true if the two objects are equivalent;false otherwise. |
equals | final public static boolean equals(Object[] leftArray, Object[] rightArray)(Code) | | Tests whether two arrays of objects are equal to each other. The arrays
must not be null , but their elements may be
null .
Parameters: leftArray - The left array to compare; may be null , andmay be empty and may contain null elements. Parameters: rightArray - The right array to compare; may be null , andmay be empty and may contain null elements. true if the arrays are equal length and theelements at the same position are equal; false otherwise. |
hashCode | final public static int hashCode(int i)(Code) | | Provides a hash code based on the given integer value.
Parameters: i - The integer value i |
hashCode | final public static int hashCode(Object object)(Code) | | Provides a hash code for the object -- defending against
null .
Parameters: object - The object for which a hash code is required. object.hashCode or 0 ifobject if null . |
hashCode | final public static int hashCode(Object[] objects)(Code) | | Computes the hash code for an array of objects, but with defense against
null .
Parameters: objects - The array of objects for which a hash code is needed; may benull . The hash code for objects ; or 0 ifobjects is null . |
startsWith | final public static boolean startsWith(Object[] left, Object[] right, boolean equals)(Code) | | Checks whether the second array is a subsequence of the first array, and
that they share common starting elements.
Parameters: left - The first array to compare (large); may be null . Parameters: right - The second array to compare (small); may be null . Parameters: equals - Whether it is allowed for the two arrays to be equivalent. true if the first arrays starts with the secondlist; false otherwise. |
toString | final public static String toString(Object[] array)(Code) | | Converts an array into a string representation that is suitable for
debugging.
Parameters: array - The array to convert; may be null . The string representation of the array; never null . |
translateString | final public static String translateString(ResourceBundle resourceBundle, String key, String defaultString)(Code) | | Provides a translation of a particular key from the resource bundle.
Parameters: resourceBundle - The key to look up in the resource bundle; should not benull . Parameters: key - The key to look up in the resource bundle; should not benull . Parameters: defaultString - The value to return if the resource cannot be found; may benull . The value of the translated resource at key . Ifthe key cannot be found, then it is simply thedefaultString . |
|
|