List of usage examples for com.google.gwt.json.client JSONString JSONString
public JSONString(String value)
From source file:annis.gui.widgets.gwt.client.ui.JITConf.java
License:Apache License
public void setProperty(String key, String value) { this.put(key, new JSONString(value)); }
From source file:anzsoft.xmpp4gwt.client.User.java
License:Open Source License
public boolean suspend() { JSONObject jUser = new JSONObject(); if (domainname == null || username == null) return false; jUser.put(STORAGE_DOMAIN, new JSONString(domainname)); //jUser.put("password", new JSONString(password)); //It's uneeded, and not safe String strPriority = String.valueOf(priority); if (strPriority != null) jUser.put(STORAGE_PRIORITY, new JSONString(String.valueOf(priority))); jUser.put(STORAGE_RESOURCE, new JSONString(resource)); jUser.put(STORAGE_USERNAME, new JSONString(username)); Cookies.setCookie(COOKIENAME, jUser.toString(), null, null, "/", false); return true;/*from w ww . j a v a 2 s . c o m*/ }
From source file:anzsoft.xmpp4gwt.client.xmpp.presence.PresencePlugin.java
License:Open Source License
public void saveStatus() { List<Presence> presences = this.getAllPresenceItems(); final String prefix = Session.instance().getUser().getStorageID(); Storage storage = Storage.createStorage(STORAGEKEY, prefix); JSONArray jPresences = new JSONArray(); for (int index = 0; index < presences.size(); index++) { jPresences.set(index, new JSONString(presences.get(index).toString())); }//w ww. j av a 2 s.c o m storage.set("data", jPresences.toString()); //save current self presence status storage.set(STORAGE_CURRENTSHOW, currentShow != null ? currentShow.toString() : ""); storage.set(STORAGE_PRIORITY, String.valueOf(priority)); storage.set(STORAGE_INIT_PRESENCE, String.valueOf(initialPresenceSended)); }
From source file:anzsoft.xmpp4gwt.client.xmpp.roster.RosterItem.java
License:Open Source License
public JSONObject toJsonObject() { JSONObject object = new JSONObject(); try {//from ww w. j a va 2 s .c o m object.put("jid", new JSONString(this.jid)); if (this.name != null) object.put("name", new JSONString(this.name)); else object.put("name", new JSONString("")); if (this.subscription.toString() != null) object.put("subscription", new JSONString(this.subscription.toString())); else object.put("subscription", new JSONString("")); if (ask) object.put("ask", new JSONString("true")); else object.put("ask", new JSONString("false")); JSONArray jGroup = new JSONArray(); if (this.groups.length > 0) { for (int index = 0; index < this.groups.length; index++) { jGroup.set(index, new JSONString(this.groups[index])); } } object.put("groups", jGroup); if (this.order != null) object.put("order", new JSONString(this.order)); else object.put("order", new JSONString("")); } catch (Exception e) { System.out.println(e.toString()); return null; } return object; }
From source file:anzsoft.xmpp4gwt.client.xmpp.roster.RosterPlugin.java
License:Open Source License
public void saveStatus() { try {/*from w w w. j av a2 s . co m*/ JSONArray jRoster = new JSONArray(); Iterator<RosterItem> iterator = this.rosterItemsByBareJid.values().iterator(); int index = 0; final String prefix = Session.instance().getUser().getStorageID(); Storage storage = Storage.createStorage(STORAGEKEY, prefix); while (iterator.hasNext()) { RosterItem ri = iterator.next(); jRoster.set(index, new JSONString(ri.getJid())); storage.set(ri.getJid(), ri.toJsonObject().toString()); } storage.set("index", jRoster.toString()); } catch (Exception e) { System.out.println(e.toString()); } }
From source file:br.com.pegasus.solutions.smartgwt.lib.client.view.impl.advanced.bar.infra.ExportUtil.java
License:Apache License
public static String getDataAsJson(ListGrid listGrid) { JSONObject jsonObj = new JSONObject(); ListGridRecord[] records = listGrid.getRecords(); for (int i = 0; i < records.length; i++) { ListGridRecord listGridRecord = records[i]; ListGridField[] listGridFields = listGrid.getFields(); JSONObject json = new JSONObject(); for (int j = 0; j < listGridFields.length; j++) { ListGridField listGridField = listGridFields[j]; String name = listGridField.getName(); if (name.contains(FIELD_NAME_CLASS_SEPARATOR)) { name = name.split(FIELD_NAME_CLASS_SEPARATOR)[0]; }/*from ww w . jav a 2 s . c o m*/ String value = listGridRecord.getAttribute(listGridField.getName()); if (value != null) { try { BigInteger number = new BigInteger(value); json.put(name, new JSONNumber(number.intValue())); } catch (Exception e) { try { BigDecimal decimal = new BigDecimal(value); decimal.setScale(2, RoundingMode.HALF_UP); json.put(name, new JSONNumber(decimal.doubleValue())); } catch (Exception e2) { json.put(name, new JSONString(value)); } } } else { json.put(name, new JSONString("")); } } jsonObj.put("jsonRecord" + (i + 1), json); } return jsonObj.toString(); }
From source file:ca.nanometrics.gflot.client.util.JSONArrayWrapper.java
License:Open Source License
protected void set(int index, String value) { JSONValue val = JSONNull.getInstance(); if (value != null) { val = new JSONString(value); }/*from ww w. jav a2 s . c o m*/ set(index, val); }
From source file:ca.nanometrics.gflot.client.util.JSONArrayWrapper.java
License:Open Source License
protected void push(String value) { JSONValue val = JSONNull.getInstance(); if (value != null) { val = new JSONString(value); }/*from ww w . j a va 2 s .co m*/ set(++currentIndex, val); }
From source file:ca.nanometrics.gflot.client.util.JSONObjectWrapper.java
License:Open Source License
protected void put(String key, String value) { JSONValue val = JSONNull.getInstance(); if (value != null) { val = new JSONString(value); }// w w w. ja v a 2s. c o m jsonObj.put(key, val); }
From source file:ca.upei.ic.timetable.client.CourseViewController.java
License:Apache License
public void search() { JSONObject department = new JSONObject(); for (String d : departmentCriteria_.keySet()) { if (departmentCriteria_.get(d)) { department.put(d, JSONBoolean.getInstance(true)); }/* ww w. j av a 2s. c om*/ } JSONObject level = new JSONObject(); for (String l : levelCriteria_.keySet()) { if (levelCriteria_.get(l)) { level.put(l, JSONBoolean.getInstance(true)); } } JSONObject semester = new JSONObject(); for (String s : semesterCriteria_.keySet()) { if (semesterCriteria_.get(s)) semester.put(s, JSONBoolean.getInstance(true)); } JSONObject value = new JSONObject(); value.put("department", department); value.put("level", level); value.put("semester", semester); value.put("day", new JSONString(courseDay_)); value.put("startTime", new JSONString(courseStartTime_)); Service.defaultInstance().askCourses(value.toString(), new RequestCallback() { public void onError(Request request, Throwable exception) { app_.error(ApplicationController.OOPS, exception); } public void onResponseReceived(Request request, Response response) { try { JSONArray parsedArray = (JSONArray) JSONParser.parse(response.getText()); // remove the selected courses // filtered array JSONArray filteredArray = new JSONArray(); int filtered_index = 0; for (int i = 0; i < parsedArray.size(); i++) { JSONObject o = (JSONObject) parsedArray.get(i); int id = (int) ((JSONNumber) o.get("id")).doubleValue(); if (!isSelected(id)) { filteredArray.set(filtered_index++, o); } } // clear out the view so we can add courses view_.clear(); // add the selected values first for (int index : selectionIndexes_) { view_.addCourse(index, selectionValues_.get(index), true); } // add the remaining courses view_.loadJSON(filteredArray); } catch (Throwable e) { app_.error("Error: " + response.getText(), e); } } }); }