diff options
author | Ray Cromwell <cromwellian@gmail.com> | 2008-06-03 07:18:45 +0000 |
---|---|---|
committer | Ray Cromwell <cromwellian@gmail.com> | 2008-06-03 07:18:45 +0000 |
commit | e706b8b5da89557e0476b8e43300a59eeb98954d (patch) | |
tree | 43dbc4621950be87aefa69a941c8598b9f901a0f /gwtquery-core/src/main/java/gwtquery/client/JSArray.java | |
parent | 135769dca69b8664006e76f6b8f039dfb59cf009 (diff) | |
download | gwtquery-e706b8b5da89557e0476b8e43300a59eeb98954d.tar.gz gwtquery-e706b8b5da89557e0476b8e43300a59eeb98954d.zip |
Refactoring for 0.2 release
Diffstat (limited to 'gwtquery-core/src/main/java/gwtquery/client/JSArray.java')
-rw-r--r-- | gwtquery-core/src/main/java/gwtquery/client/JSArray.java | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/gwtquery-core/src/main/java/gwtquery/client/JSArray.java b/gwtquery-core/src/main/java/gwtquery/client/JSArray.java new file mode 100644 index 00000000..a8049347 --- /dev/null +++ b/gwtquery-core/src/main/java/gwtquery/client/JSArray.java @@ -0,0 +1,72 @@ +package gwtquery.client;
+
+import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.dom.client.Node;
+import com.google.gwt.dom.client.NodeList;
+
+/**
+ */
+public class JSArray extends NodeList<Element> {
+
+ public static JSArray create() {
+ return (JSArray) JavaScriptObject.createArray();
+ }
+
+ public static native JSArray create(Node node) /*-{
+ return [node];
+ }-*/;
+
+ public static native JSArray create(NodeList nl) /*-{
+ var r = [], len=nl.length;
+ for(var i=0; i<len; i++) {
+ r.push(nl[i]);
+ }
+ return r;
+ }-*/;
+
+ protected JSArray() {
+ }
+
+ public final native void addInt(int i) /*-{
+ this[this.length]=i;
+ }-*/;
+
+ public final native void addNode(Node n) /*-{
+ this[this.length]=n;
+ }-*/;
+
+ public final native void addNode(Node ci, int i) /*-{
+ this[i]=ci;
+ }-*/;
+
+ public final native void concat(JSArray ary) /*-{
+ this.concat(ary);
+ }-*/;
+
+ public final native Element getElement(int i) /*-{
+ return this[i];
+ }-*/;
+
+ public final native int getInt(int i) /*-{
+ return this[i] || 0;
+ }-*/;
+
+ public final native Node getNode(int i) /*-{
+ return this[i];
+ }-*/;
+
+ public final native String getStr(int i) /*-{
+ return this[i] || null;
+ }-*/;
+
+ public final void pushAll(JSArray prevElem) {
+ for (int i = 0, ilen = prevElem.size(); i < ilen; i++) {
+ addNode(prevElem.getNode(i));
+ }
+ }
+
+ public final native int size() /*-{
+ return this.length;
+ }-*/;
+}
|