com.extjs.gxt.ui.client.util
Class Util

java.lang.Object
  extended by com.extjs.gxt.ui.client.util.Util

public class Util
extends java.lang.Object

Various utility functions.


Constructor Summary
Util()
           
 
Method Summary
static int constrain(int value, int min, int max)
          Constrains the value by a minimum and max value.
static Component[] createArray(java.util.List<Component> list)
          Creates a Component[] from a list of Component's.
static java.util.List createList(java.util.Collection collection)
          Creates a new list from the given collection.
static java.util.List createList(java.lang.Object... element)
          Creates a new list and adds the element(s).
static boolean equalWithNull(java.lang.Object obj1, java.lang.Object obj2)
           
static void fill(java.util.List list, java.lang.Object[] elements)
          Populates a list with an array of elements.
static com.google.gwt.core.client.JavaScriptObject getJsObject(ModelData model)
          Returns the model's data as a javascript object.
static com.google.gwt.core.client.JavaScriptObject getJsObject(ModelData model, int maxDepth)
          Returns the model's data as a javascript object.
static com.google.gwt.core.client.JavaScriptObject getJsObjects(java.util.List<? extends ModelData> models, int maxDepth)
          Returns the list of models as a javascript array.
static int indexOf(java.lang.Object[] elements, java.lang.Object elem)
          Returns the index of a object in an array.
static boolean isEmptyString(java.lang.String string)
          Returns true if the string is null or equals to the empty string.
static boolean isImagePath(java.lang.String style)
          Returns true if the style ends with .jpg, .gif, or .png.
static boolean isInteger(java.lang.String value)
          Tests if the value is an integer.
static
<E> E
or(E s1, E s2)
           
static int parseInt(java.lang.String value, int defaultValue)
           
static java.util.List subList(java.util.List list, int start, int end)
           
static com.google.gwt.user.client.Element[] toElementArray(com.google.gwt.dom.client.NodeList<com.google.gwt.user.client.Element> nodes)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

public Util()
Method Detail

subList

public static java.util.List subList(java.util.List list,
                                     int start,
                                     int end)

or

public static <E> E or(E s1,
                       E s2)

constrain

public static int constrain(int value,
                            int min,
                            int max)
Constrains the value by a minimum and max value.

Parameters:
value - the value
min - the minimum
max - the maximum
Returns:
the adjusted value

createArray

public static Component[] createArray(java.util.List<Component> list)
Creates a Component[] from a list of Component's.

Parameters:
list - the list
Returns:
the array

createList

public static java.util.List createList(java.util.Collection collection)
Creates a new list from the given collection.

Parameters:
collection - the collection
Returns:
the list

createList

public static java.util.List createList(java.lang.Object... element)
Creates a new list and adds the element(s).

Parameters:
element - the item to add to the list
Returns:
the new list

equalWithNull

public static boolean equalWithNull(java.lang.Object obj1,
                                    java.lang.Object obj2)

fill

public static void fill(java.util.List list,
                        java.lang.Object[] elements)
Populates a list with an array of elements.

Parameters:
list - the list
elements - the elements to be added to the list

getJsObject

public static com.google.gwt.core.client.JavaScriptObject getJsObject(ModelData model)
Returns the model's data as a javascript object.

Parameters:
model - the model
Returns:
the javascript object

getJsObject

public static com.google.gwt.core.client.JavaScriptObject getJsObject(ModelData model,
                                                                      int maxDepth)
Returns the model's data as a javascript object.

Parameters:
model - the model
maxDepth - the maximum number of sub models to process
Returns:
the javascript object

getJsObjects

public static com.google.gwt.core.client.JavaScriptObject getJsObjects(java.util.List<? extends ModelData> models,
                                                                       int maxDepth)
Returns the list of models as a javascript array.

Parameters:
models - the list of models
maxDepth - the maximum number of sub models to process
Returns:
the javascript array object

indexOf

public static int indexOf(java.lang.Object[] elements,
                          java.lang.Object elem)
Returns the index of a object in an array.

Parameters:
elements - the array
elem - the element
Returns:
the index or -1 if elem not in the array

isEmptyString

public static boolean isEmptyString(java.lang.String string)
Returns true if the string is null or equals to the empty string.

Parameters:
string - the string to test
Returns:
true if the string is empty

isImagePath

public static boolean isImagePath(java.lang.String style)
Returns true if the style ends with .jpg, .gif, or .png.

Parameters:
style - the style
Returns:
true for an image path

isInteger

public static boolean isInteger(java.lang.String value)
Tests if the value is an integer.

Parameters:
value - the value to test
Returns:
the integer state

parseInt

public static int parseInt(java.lang.String value,
                           int defaultValue)

toElementArray

public static com.google.gwt.user.client.Element[] toElementArray(com.google.gwt.dom.client.NodeList<com.google.gwt.user.client.Element> nodes)