public final class Util extends Object
A static class providing utility methods to all of JFace.
| Modifier and Type | Field and Description |
|---|---|
static SortedSet<?> |
EMPTY_SORTED_SET
An unmodifiable, empty, sorted set.
|
static String |
WS_CARBON
Windowing system constant.
|
static String |
WS_COCOA
Windowing system constant.
|
static String |
WS_GTK
Windowing system constant.
|
static String |
WS_MOTIF
Windowing system constant.
|
static String |
WS_PHOTON
Windowing system constant.
|
static String |
WS_UNKNOWN
Windowing system constant.
|
static String |
WS_WIN32
Windowing system constant.
|
static String |
WS_WPF
Windowing system constant.
|
static String |
ZERO_LENGTH_STRING
A common zero-length string.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
assertInstance(Object object,
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(int left,
int right)
Compares two integer values.
|
static <T extends Comparable<? super T>> |
compare(List<T> left,
List<T> right)
Compares two lists -- account for
null. |
static <T extends Comparable<? super T>> |
compare(T[] left,
T[] right)
Compares two arrays of comparable objects -- accounting for
null. |
static <T extends Comparable<? super T>> |
compare(T left,
T right)
Compares to comparable objects -- defending against
null. |
static boolean |
endsWith(Object[] left,
Object[] right,
boolean equals)
Tests whether the first array ends with the second array.
|
static boolean |
equals(Object[] leftArray,
Object[] rightArray)
Tests whether two arrays of objects are equal to each other.
|
static boolean |
equals(Object left,
Object right)
Checks whether the two objects are
null -- allowing for
null. |
static String |
getWS()
Common WS query helper method.
|
static int |
hashCode(int i)
Provides a hash code based on the given integer value.
|
static int |
hashCode(Object object)
Provides a hash code for the object -- defending against
null. |
static int |
hashCode(Object[] objects)
Computes the hash code for an array of objects, but with defense against
null. |
static boolean |
isCarbon()
Common WS query helper method.
|
static boolean |
isCocoa()
Common WS query helper method.
|
static boolean |
isGtk()
Common WS query helper method.
|
static boolean |
isLinux()
Common WS query helper method.
|
static boolean |
isMac()
Common WS query helper method.
|
static boolean |
isMotif()
Common WS query helper method.
|
static boolean |
isPhoton()
Common WS query helper method.
|
static boolean |
isWin32()
Common WS query helper method.
|
static boolean |
isWindows()
Common WS query helper method.
|
static boolean |
isWpf()
Common WS query helper method.
|
static String |
replaceAll(String src,
String find,
String replacement)
Foundation replacement for
String#replaceAll(String,
String), but without support for regular
expressions. |
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.
|
static String |
toString(Object[] array)
Converts an array into a string representation that is suitable for
debugging.
|
static String |
translateString(ResourceBundle resourceBundle,
String key,
String defaultString)
Provides a translation of a particular key from the resource bundle.
|
public static final SortedSet<?> EMPTY_SORTED_SET
null.public static final String ZERO_LENGTH_STRING
NON-NLS
next to code fragments. It's also a bit clearer to read.public static final String WS_WIN32
public static final String WS_MOTIF
public static final String WS_GTK
public static final String WS_PHOTON
public static final String WS_CARBON
public static final String WS_COCOA
public static final String WS_WPF
public static final String WS_UNKNOWN
public static final void assertInstance(Object object, 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 compareleft - rightpublic static final <T extends Comparable<? super T>> int compare(T left, T 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 <T extends Comparable<? super T>> int compare(T[] left, T[] 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 <T extends Comparable<? super T>> int compare(List<T> left, List<T> 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(Object[] left, 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(Object left, 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(Object[] leftArray, 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 valueipublic static final int hashCode(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(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(Object[] left, 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 String toString(Object[] array)
array - The array to convert; may be null.null.public static final String translateString(ResourceBundle resourceBundle, String key, 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.public static final String replaceAll(String src, String find, String replacement)
String#replaceAll(String,
String), but without support for regular
expressions.src - the original stringfind - the string to findreplacement - the replacement stringfind
replaced by replacement (not using regular
expressions)public static final boolean isWindows()
true for windows platformspublic static final boolean isMac()
true for mac platformspublic static final boolean isLinux()
true for linux platformpublic static final boolean isGtk()
true for gtk platformspublic static final boolean isMotif()
true for motif platformspublic static final boolean isPhoton()
true for photon platformspublic static final boolean isCarbon()
true for carbon platformspublic static final boolean isCocoa()
true for the cocoa platform.public static final boolean isWpf()
true for WPFpublic static final boolean isWin32()
true for win32public static final String getWS()
SWT.getPlatform()
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.