Example usage for com.google.gwt.json.client JSONValue isNumber

List of usage examples for com.google.gwt.json.client JSONValue isNumber

Introduction

In this page you can find the example usage for com.google.gwt.json.client JSONValue isNumber.

Prototype

public JSONNumber isNumber() 

Source Link

Document

Returns a non-null reference if this JSONValue is really a JSONNumber.

Usage

From source file:ca.nanometrics.gflot.client.options.LegendOptions.java

License:Open Source License

/**
 * @return the distance to the plot edge. The array can contains one value if the margin is applied to both x and y
 * axis or 2 values if the first one is applied to x axis and the second one to y axis.
 *///from  w w w .j  av a2  s.  co  m
public Double[] getMargin() {
    JSONValue value = get(MARGIN_KEY);
    if (value == null) {
        return null;
    }
    JSONNumber number = value.isNumber();
    if (null != number) {
        return new Double[] { number.doubleValue() };
    }
    JSONArray array = value.isArray();
    if (null != array) {
        return new Double[] { array.get(0).isNumber().doubleValue(), array.get(1).isNumber().doubleValue() };
    }
    return null;
}

From source file:ca.nanometrics.gflot.client.Series.java

License:Open Source License

/**
 * @return the auto-generated color to select
 *///from w  ww. java2 s .c om
public Integer getAutoGeneratedColor() {
    JSONValue value = get(COLOR_KEY);
    if (value == null) {
        return null;
    }
    JSONString str = value.isString();
    if (str != null) {
        return null;
    }
    JSONNumber number = value.isNumber();
    if (number != null) {
        return new Integer((int) number.doubleValue());
    }
    return null;
}

From source file:ca.nanometrics.gflot.client.Series.java

License:Open Source License

/**
 * Provides the identifier of another series which is used to fill the area
 * between these two series. If this identifier was given as a number that
 * doesn't appear as an id in the series, it is interpreted as the index in
 * the array instead (so fillBetween: 0 can also mean the first series).
 * Only for the fillbetween plugin!/*from   w  ww.j  a v a 2  s  .c  om*/
 * 
 * @return an identifier of another series (a string, integer or null).
 */
public Object getFillBetween() {
    JSONValue value = get(FILL_BETWEEN_KEY);
    if (value == null) {
        return null;
    }
    JSONString str = value.isString();
    if (str != null) {
        return str.stringValue();
    }
    JSONNumber number = value.isNumber();
    if (number != null) {
        return new Integer((int) number.doubleValue());
    }
    return null;

}

From source file:ca.nanometrics.gflot.client.util.JSONArrayWrapper.java

License:Open Source License

protected JSONNumber getNumber(int index) {
    JSONValue val = get(index);
    if (val == null) {
        return null;
    }/* w  w w . jav  a 2s .  co  m*/
    return val.isNumber();
}

From source file:ca.nanometrics.gflot.client.util.JSONObjectWrapper.java

License:Open Source License

protected JSONNumber getNumber(String key) {
    JSONValue val = get(key);
    if (val == null) {
        return null;
    }//from   w  ww. j a va2 s  . c om
    return val.isNumber();
}

From source file:ccc.client.gwt.core.GWTJson.java

License:Open Source License

/** {@inheritDoc} */
@Override/*  ww w.j a  va  2 s. c  om*/
public Date getDate(final String key) {
    final JSONValue value = _delegate.get(key);
    if (null == value) {
        throw new S11nException("Missing key: " + key);
    } else if (null != value.isNull()) {
        return null;
    }
    // TODO: Handle non integers
    return new Date((long) value.isNumber().doubleValue());
}

From source file:ccc.client.gwt.core.GWTJson.java

License:Open Source License

/** {@inheritDoc} */
@Override/*from   www  .j  a v a2s.c o  m*/
public Integer getInt(final String key) {
    final JSONValue value = _delegate.get(key);
    if (null == value) {
        throw new S11nException("Missing key: " + key);
    } else if (null != value.isNull()) {
        return null;
    }
    // TODO: Handle non integers; handle values larger than maxInt, etc.
    return Integer.valueOf((int) value.isNumber().doubleValue());
}

From source file:ccc.client.gwt.core.GWTJson.java

License:Open Source License

/** {@inheritDoc} */
@Override//from  www .  j  a  v a  2s .c  o m
public Long getLong(final String key) {
    final JSONValue value = _delegate.get(key);
    if (null == value) {
        throw new S11nException("Missing key: " + key);
    } else if (null != value.isNull()) {
        return null;
    }
    // TODO: Handle non integers; handle values larger than maxLong, etc.
    return Long.valueOf((long) value.isNumber().doubleValue());
}

From source file:colt.json.gwt.client.UJsonClient.java

License:Apache License

static public long getLong(JSONObject _o, String _key, long _default) {
    JSONValue v = _o.get(_key);
    if (v.isNumber() == null)
        return _default;
    return (long) v.isNumber().doubleValue();
}

From source file:colt.json.gwt.client.UJsonClient.java

License:Apache License

static public double getDouble(JSONObject _o, String _key, double _default) {
    JSONValue v = _o.get(_key);
    if (v.isNumber() == null)
        return _default;
    return v.isNumber().doubleValue();
}