public final class GwtUtils extends Object
These utility methods are copies of those defined in org.metawidget.util
, but they
either are 'GWT flavoured' (eg. they use com.google.gwt.xml
instead of
org.w3c.dom
) or they are free encumberances (eg. java.util.regex
) that
GWT doesn't support.
Modifier and Type | Method and Description |
---|---|
static void |
alert(Throwable caught) |
static List<String> |
fromString(String collection,
char separator)
GWT-ified
CollectionUtils.fromString . |
static String |
getActualClassOrType(Map<String,String> attributes)
Looks up the TYPE attribute, but first checks the ACTUAL_CLASS attribute.
|
static boolean |
isCollection(String className)
Whether the given class name is a Collection.
|
static boolean |
isIntegerPrimitive(String className)
Returns
true if the type is an integer primitive. |
static boolean |
isPrimitive(String className)
GWT-ified
Class.isPrimitive . |
static boolean |
isPrimitiveWrapper(String className)
GWT-ified
ClassUtils.isPrimitiveWrapper . |
static boolean |
isReadOnly(Map<String,String> attributes)
Returns whether the attributes have READ_ONLY or NO_SETTER set to TRUE.
|
static boolean |
needsEmptyLookupItem(Map<String,String> attributes)
Returns true if the lookup is nullable, not required, or has a forced empty choice.
|
static void |
setListBoxSelectedItem(com.google.gwt.user.client.ui.ListBox listBox,
String value) |
static String |
stripSection(Map<String,String> attributes) |
static String |
toString(Collection<?> collection,
char separator)
GWT-ified
CollectionUtils.toString . |
static String |
toString(String[] collection,
char separator)
GWT-ified
CollectionUtils.toString . |
public static boolean isPrimitive(String className)
Class.isPrimitive
.
This version takes a String argument, not a Class argument, because we won't have been able to use Class.forName to create a Class.
public static boolean isIntegerPrimitive(String className)
true
if the type is an integer primitive.
We mean 'integer' in the mathematical sense (ie. a whole number), not the Java sense, so
byte, short, int and long all return true
. Determining whether a type is 'whole
number compatible' is useful for widgets like sliders and spinners.
public static boolean isPrimitiveWrapper(String className)
ClassUtils.isPrimitiveWrapper
.
This version takes a String argument, not a Class argument, because we won't have been able to use Class.forName to create a Class.
public static boolean isCollection(String className)
Collection.class.isAssignableFrom( ... );
...subclasses may need to override this method if they introduce a new Collection subtype.
public static List<String> fromString(String collection, char separator)
CollectionUtils.fromString
.
This version does not use regular expressions.
public static String toString(String[] collection, char separator)
CollectionUtils.toString
.
This version does not use regular expressions.
public static String toString(Collection<?> collection, char separator)
CollectionUtils.toString
.
This version does not use regular expressions.
public static void setListBoxSelectedItem(com.google.gwt.user.client.ui.ListBox listBox, String value)
public static void alert(Throwable caught)
public static boolean isReadOnly(Map<String,String> attributes)
The latter case relies on complex attributes being rendered by nested Metawidgets: the nested Metawidgets will not have setReadOnly set on them, which gets us the desired result. Namely, primitive types without a setter are rendered as read-only, complex types without a setter are rendered as writeable (because their nested primitives are writeable).
Furthermore, what is considered 'primitive' is up to the platform. Some platforms may consider, say, an Address as 'primitive', using a dedicated Address widget. Other platforms may consider an Address as complex, using a nested Metawidget.
public static String getActualClassOrType(Map<String,String> attributes)
public static boolean needsEmptyLookupItem(Map<String,String> attributes)
Copyright © 2015. All Rights Reserved.