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

xapi.gwt.collect.JsStringDictionary Maven / Gradle / Ivy

Go to download

Everything needed to run a comprehensive dev environment. Just type X_ and pick a service from autocomplete; new dev modules will be added as they are built. The only dev service not included in the uber jar is xapi-dev-maven, as it includes all runtime dependencies of maven, adding ~4 seconds to build time, and 6 megabytes to the final output jar size (without xapi-dev-maven, it's ~1MB).

The newest version!
package xapi.gwt.collect;

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

import xapi.collect.api.StringDictionary;
import xapi.util.api.ReceivesValue;

public class JsStringDictionary  extends JavaScriptObject implements StringDictionary{

  protected JsStringDictionary() {
  }

  public static native  JsStringDictionary create()
  /*-{
    return {};
  }-*/;

  public final native  Unsafe getUnsafe(String key)
  /*-{
    return this[key];
  }-*/;

  public final native int getInt(String key)
  /*-{
    return this[key];
  }-*/;

  public final native double getDouble(String key)
  /*-{
    return this[key];
  }-*/;

  public final native double getBoolean(String key)
  /*-{
    return !!this[key];
  }-*/;

  @Override
  public final native V getValue(String key)
  /*-{
    return this[key];
  }-*/;

  @Override
  public final native boolean hasKey(String key)
  /*-{
    return this[key] != undefined;
  }-*/;

  @Override
  public final native V setValue(String key, V value)
  /*-{
    var r = this[key];
    this[key] = value;
    return r;
  }-*/;

  @Override
  public final native V removeValue(String key)
  /*-{
    var r = this[key];
    delete this[key];
    return r;
  }-*/;

  @Override
  public final native void clearValues()
  /*-{
     for (var i in this) {
       if (Object.prototype.hasOwnProperty.apply(this, i))
         delete this[i];
     }
  }-*/;

  @Override
  public final native void forKeys(ReceivesValue receiver)
  /*-{
    for (var i in this) {
      if (Object.prototype.hasOwnProperty.call(this, i))
        [email protected]::set(Ljava/lang/Object;)(i);
    }
  }-*/;

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy