Example usage for com.google.gwt.json.client JSONString stringValue

List of usage examples for com.google.gwt.json.client JSONString stringValue

Introduction

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

Prototype

public String stringValue() 

Source Link

Document

Returns the raw Java string value of this item.

Usage

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

License:Open Source License

/**
 * @return the background color inside the grid area. The array can contains one color or two colors if it's a
 * gradient/*from   w w w  .  j  av  a  2  s. c  om*/
 */
public String[] getBackgroundColor() {
    JSONValue value = get(BACKGROUND_COLOR_KEY);
    if (value == null) {
        return null;
    }
    JSONString str = value.isString();
    if (null != str) {
        return new String[] { str.stringValue() };
    }
    JSONObject obj = value.isObject();
    if (null != obj) {
        JSONValue colors = obj.get(BACKGROUND_COLORS_KEY);
        JSONArray array = colors.isArray();
        if (null != array) {
            return new String[] { array.get(0).isString().stringValue(),
                    array.get(1).isString().stringValue() };
        }
    }
    return null;
}

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

License:Open Source License

/**
 * @return the color//  w w  w. ja va 2 s.  c  o m
 */
public String getColor() {
    JSONValue value = get(COLOR_KEY);
    if (value == null) {
        return null;
    }
    JSONString str = value.isString();
    if (str != null) {
        return str.stringValue();
    }
    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!/* w  w  w . j a  v a2s  .co  m*/
 * 
 * @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 String getString(int index) {
    JSONValue value = get(index);//from  www  . ja v a  2  s  .c  o m
    if (value == null) {
        return null;
    }
    JSONString str = value.isString();
    return str == null ? null : str.stringValue();
}

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

License:Open Source License

protected String getString(String key) {
    JSONValue value = get(key);//from ww w .  j a  va  2  s  . c  o m
    if (value == null) {
        return null;
    }
    JSONString str = value.isString();
    return str == null ? null : str.stringValue();
}

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

License:Open Source License

protected String[] getStringArray(String key) {
    JSONArray array = getArray(key);//from w  w w . j av a2  s  .com
    if (array == null) {
        return null;
    }
    String[] result = new String[array.size()];
    for (int i = 0; i < array.size(); i++) {
        JSONString value = array.get(i).isString();
        if (null != value) {
            result[i] = value.stringValue();
        }
    }
    return result;
}

From source file:ca.upei.ic.timetable.client.DepartmentModelView.java

License:Apache License

public void loadJSON(JSONValue value) {
    JSONArray array = (JSONArray) value;

    // iterate all json results
    for (int i = 0; i < array.size(); i++) {
        JSONString s = (JSONString) array.get(i);
        CheckBox box = new CheckBox(s.stringValue());
        box.setName(s.stringValue());/*from  www  .j  av  a 2 s .  c  om*/
        // add the click listener
        box.addClickListener(new ClickListener() {

            public void onClick(Widget sender) {
                final CheckBox box = (CheckBox) sender;
                final String name = box.getName();
                controller_.setDepartmentCriteria(name, box.isChecked());
            }

        });
        panel_.add(box);
    }
}

From source file:ca.upei.ic.timetable.client.LevelModelView.java

License:Apache License

public void loadJSON(JSONValue value) {
    JSONArray array = (JSONArray) value;
    // load the values
    for (int i = 0; i < array.size(); i++) {
        // set value and name
        JSONString s = (JSONString) array.get(i);
        CheckBox box = new CheckBox("Level " + s.stringValue());
        box.setName(s.stringValue()); // to store the value
        box.setChecked(true);/*from w w  w .j  a v a  2s .co  m*/
        controller_.setLevelCriteria(s.stringValue(), true);

        // add click listener
        box.addClickListener(new ClickListener() {

            public void onClick(Widget sender) {
                final CheckBox box = (CheckBox) sender;
                final String name = box.getName();
                controller_.setLevelCriteria(name, box.isChecked());
            }

        });

        panel_.add(box);
    }
}

From source file:ca.upei.ic.timetable.client.SemesterModelView.java

License:Apache License

public void loadJSON(JSONValue value) {
    JSONArray array = (JSONArray) value;

    // get the current month
    int month = new Date().getMonth() + 1;

    // iterate all json results
    for (int i = 0; i < array.size(); i++) {
        JSONString s = (JSONString) array.get(i);
        String name = s.stringValue();

        CheckBox box = new CheckBox(name);
        box.setName(name);//  w w  w . j a  va2s  .  c  o m
        if (name.equals("First Semester") && month > 6 && month < 11) {
            box.setChecked(true);
            controller_.setSemesterCriteria(name, true);
        }
        if (name.equals("Second Semester") && (month > 10 || month < 4)) {
            box.setChecked(true);
            controller_.setSemesterCriteria(name, true);
        }
        // add the click listener
        box.addClickListener(new ClickListener() {

            public void onClick(Widget sender) {
                final CheckBox box = (CheckBox) sender;
                final String name = box.getName();
                controller_.setSemesterCriteria(name, box.isChecked());
            }

        });
        panel_.add(box);
    }
}

From source file:ch.unifr.pai.twice.comm.serverPush.client.RemoteEvent.java

License:Apache License

/**
 * Decrypts and deserializes the event data
 * /*from  w  ww.j  a  v a  2 s  . c o m*/
 * @param string
 * @param securityManager
 * @return
 * @throws MessagingException
 */
public RemoteEvent<H> deserialize(String string, TWICESecurityManager securityManager)
        throws MessagingException {
    root = (JSONObject) JSONParser.parseStrict(string);
    JSONString data = (JSONString) root.get("data");
    json = (JSONObject) JSONParser.parseStrict(securityManager.decryptMessage(data.stringValue()));
    return this;
}