01: /*
02: * MyGWT Widget Library
03: * Copyright(c) 2007, MyGWT.
04: * licensing@mygwt.net
05: *
06: * http://mygwt.net/license
07: */
08: package net.mygwt.ui.client.util;
09:
10: import java.util.List;
11:
12: import net.mygwt.ui.client.widget.Component;
13:
14: /**
15: * Various utility funcitons.
16: */
17: public class Util {
18:
19: /**
20: * Creates a Component[] from a list of Component's.
21: *
22: * @param list the list
23: * @return the array
24: */
25: public static Component[] createArray(List list) {
26: int size = list.size();
27: Component[] components = new Component[size];
28: for (int i = 0; i < components.length; i++) {
29: components[i] = (Component) list.get(i);
30: }
31: return components;
32: }
33:
34: /**
35: * Populates a list with an array of elements.
36: *
37: * @param list the list
38: * @param elements the elements to be added to the list
39: */
40: public static void fill(List list, Object[] elements) {
41: for (int i = 0; i < elements.length; i++) {
42: list.add(elements[i]);
43: }
44: }
45:
46: /**
47: * Tests if the value is an integer.
48: *
49: * @param value the value to test
50: * @return the integer state
51: */
52: public static boolean isInteger(String value) {
53: try {
54: Integer.parseInt(value);
55: return true;
56: } catch (Exception e) {
57: return false;
58: }
59: }
60:
61: }
|