|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.jface.util.Util
public final class Util
A static class providing utility methods to all of JFace.
Field Summary | |
---|---|
static java.util.SortedSet |
EMPTY_SORTED_SET
An unmodifiable, empty, sorted set. |
static java.lang.String |
ZERO_LENGTH_STRING
A common zero-length string. |
Method Summary | |
---|---|
static void |
assertInstance(java.lang.Object object,
java.lang.Class c)
Verifies that the given object is an instance of the given class. |
static int |
compare(boolean left,
boolean right)
Compares two boolean values. |
static int |
compare(java.lang.Comparable[] left,
java.lang.Comparable[] right)
Compares two arrays of comparable objects -- accounting for null . |
static int |
compare(java.lang.Comparable left,
java.lang.Comparable right)
Compares to comparable objects -- defending against null . |
static int |
compare(int left,
int right)
Compares two integer values. |
static int |
compare(java.util.List left,
java.util.List right)
Compares two lists -- account for null . |
static boolean |
endsWith(java.lang.Object[] left,
java.lang.Object[] right,
boolean equals)
Tests whether the first array ends with the second array. |
static boolean |
equals(java.lang.Object[] leftArray,
java.lang.Object[] rightArray)
Tests whether two arrays of objects are equal to each other. |
static boolean |
equals(java.lang.Object left,
java.lang.Object right)
Checks whether the two objects are null -- allowing for
null . |
static int |
hashCode(int i)
Provides a hash code based on the given integer value. |
static int |
hashCode(java.lang.Object object)
Provides a hash code for the object -- defending against null . |
static int |
hashCode(java.lang.Object[] objects)
Computes the hash code for an array of objects, but with defense against null . |
static boolean |
startsWith(java.lang.Object[] left,
java.lang.Object[] right,
boolean equals)
Checks whether the second array is a subsequence of the first array, and that they share common starting elements. |
static java.lang.String |
translateString(java.util.ResourceBundle resourceBundle,
java.lang.String key,
java.lang.String defaultString)
Provides a translation of a particular key from the resource bundle. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.util.SortedSet EMPTY_SORTED_SET
null
.
public static final java.lang.String ZERO_LENGTH_STRING
NON-NLS
next to code fragments. It's also a bit clearer to read.
Method Detail |
---|
public static final void assertInstance(java.lang.Object object, java.lang.Class c)
object
- The object to check; may be null
.c
- The class which the object should be; must not be
null
.public static final int compare(boolean left, boolean right)
false
is considered to be
"less than" true
.
left
- The left value to compareright
- The right value to compare
-1
if the left is false
and the
right is true
. 1
if the opposite
is true. If they are equal, then it returns 0
.public static final int compare(int left, int right)
left
- The left value to compareright
- The right value to compare
left - right
public static final int compare(java.lang.Comparable left, java.lang.Comparable right)
null
.
left
- The left object to compare; may be null
.right
- The right object to compare; may be null
.
null
is considered
to be the least possible value.public static final int compare(java.lang.Comparable[] left, java.lang.Comparable[] right)
null
.
left
- The left array to be compared; may be null
.right
- The right array to be compared; may be null
.
null
is considered
to be the least possible value. A shorter array is considered
less than a longer array.public static final int compare(java.util.List left, java.util.List right)
null
. The lists must
contain comparable objects.
left
- The left list to compare; may be null
. This
list must only contain instances of Comparable
.right
- The right list to compare; may be null
. This
list must only contain instances of Comparable
.
null
is considered
to be the least possible value. A shorter list is considered less
than a longer list.public static final boolean endsWith(java.lang.Object[] left, java.lang.Object[] right, boolean equals)
left
- The array to check (larger); may be null
.right
- The array that should be a subsequence (smaller); may be
null
.equals
- Whether the two array are allowed to be equal.
true
if the second array is a subsequence of the
array list, and they share end elements.public static final boolean equals(java.lang.Object left, java.lang.Object right)
null
-- allowing for
null
.
left
- The left object to compare; may be null
.right
- The right object to compare; may be null
.
true
if the two objects are equivalent;
false
otherwise.public static final boolean equals(java.lang.Object[] leftArray, java.lang.Object[] rightArray)
null
, but their elements may be
null
.
leftArray
- The left array to compare; may be null
, and
may be empty and may contain null
elements.rightArray
- The right array to compare; may be null
, and
may be empty and may contain null
elements.
true
if the arrays are equal length and the
elements at the same position are equal; false
otherwise.public static final int hashCode(int i)
i
- The integer value
i
public static final int hashCode(java.lang.Object object)
null
.
object
- The object for which a hash code is required.
object.hashCode
or 0
if
object
if null
.public static final int hashCode(java.lang.Object[] objects)
null
.
objects
- The array of objects for which a hash code is needed; may be
null
.
objects
; or 0
if
objects
is null
.public static final boolean startsWith(java.lang.Object[] left, java.lang.Object[] right, boolean equals)
left
- The first array to compare (large); may be null
.right
- The second array to compare (small); may be null
.equals
- Whether it is allowed for the two arrays to be equivalent.
true
if the first arrays starts with the second
list; false
otherwise.public static final java.lang.String translateString(java.util.ResourceBundle resourceBundle, java.lang.String key, java.lang.String defaultString)
resourceBundle
- The key to look up in the resource bundle; should not be
null
.key
- The key to look up in the resource bundle; should not be
null
.defaultString
- The value to return if the resource cannot be found; may be
null
.
key
. If
the key cannot be found, then it is simply the
defaultString
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |