All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.extjs.gxt.ui.client.js.JsArray Maven / Gradle / Ivy

There is a newer version: 2.3.1-gwt22
Show newest version
/*
 * Ext GWT - Ext for GWT
 * Copyright(c) 2007, 2008, Ext JS, LLC.
 * [email protected]
 * 
 * http://extjs.com/license
 */
package com.extjs.gxt.ui.client.js;

import com.google.gwt.core.client.JavaScriptObject;

/**
 * Wraps a native javascript array.
 */
public class JsArray implements JsWrapper {

  /**
   * The wrapped javascript object.
   */
  protected JavaScriptObject jsArray;

  /**
   * Creates a new instance.
   */
  public JsArray() {
    jsArray = create();
  }
 
  public JavaScriptObject getJsObject() {
    return jsArray;
  }

  /**
   * Adds a string value to the array.
   * @param value the value to add
   */
  public native void add(String value) /*-{
    var js = [email protected]::jsArray;
    js[js.length] = value;
  }-*/;
  
  /**
   * Adds a object to the array.
   * @param value the object to add
   */
  public native void add(Object value) /*-{
    var js = [email protected]::jsArray;
    js[js.length] = value;
  }-*/;

  /**
   * Adds a native javascript object to the array.
   * 
   * @param object the object to add
   */
  public native void add(JavaScriptObject object) /*-{
     var js = [email protected]::jsArray;
     js[js.length] = object;
   }-*/;

  /**
   * Returns the size of the array.
   * @return the size
   */
  public native int size() /*-{
     var js = [email protected]::jsArray;
     return js.length;
   }-*/;

  protected native JavaScriptObject create() /*-{
   return new Array();
   }-*/;

  public static native JavaScriptObject eval(String code) /*-{
   var x = eval(code);
   return x[0];
   }-*/;

}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy