List of usage examples for com.google.gwt.json.client JSONArray JSONArray
public JSONArray()
From source file:amdb.client.slider.Slider.java
License:Apache License
private static JSONArray intArrayToJSONArray(int[] values) { JSONArray vals = new JSONArray(); for (int i = 0, len = values.length; i < len; i++) { vals.set(i, new JSONNumber(values[i])); }//from w ww .java2s . co m return vals; }
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 a v a 2 s . c om 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 w ww . java 2 s . c om*/ 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 {/* w ww . java 2 s . c o 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:ca.nanometrics.gflot.client.util.JSONArrayWrapper.java
License:Open Source License
protected JSONArrayWrapper() { jsonArray = new JSONArray(); currentIndex = -1; }
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)); }/* w w w.j a v a 2s.c o m*/ } 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); } } }); }
From source file:ccc.client.gwt.core.GWTJson.java
License:Open Source License
/** {@inheritDoc} */ @Override// ww w . ja v a2 s .c o m public void setStrings(final String key, final Collection<String> values) { if (null == values) { _delegate.put(key, JSONNull.getInstance()); } else { final JSONArray strings = new JSONArray(); int i = 0; for (final String value : values) { strings.set(i, new JSONString(value)); i++; } _delegate.put(key, strings); } }
From source file:ccc.client.gwt.core.GWTJson.java
License:Open Source License
/** {@inheritDoc} */ @Override//from ww w . jav a 2s . co m public void setJsons(final String key, final Collection<? extends Json> values) { final JSONArray value = new JSONArray(); int i = 0; for (final Json j : values) { final GWTJson o = (GWTJson) j; value.set(i, o.getDelegate()); i++; } _delegate.put(key, value); }
From source file:ch.takoyaki.email.html.client.service.FileServiceImpl.java
License:Open Source License
private void updateFileList(List<String> fListCache2) { JSONArray a = new JSONArray(); for (int i = 0; i < fListCache2.size(); i++) { a.set(i, new JSONString(fListCache2.get(i))); }//from w w w . j a v a2 s . co m s().setItem(FILE_LIST, a.toString()); fListCache = fileList(); }
From source file:ch.unifr.pai.twice.comm.serverPush.client.RemoteEvent.java
License:Apache License
/** * Allows to define a list of receipients (UUIDs) to which the event shall be sent. If not defined, the events will go to all involved devices * // ww w.j a va2 s. co m * @param receipients */ public void setReceipients(String... receipients) { this.receipients = new JSONArray(); int i = 0; for (String s : receipients) { this.receipients.set(i++, new JSONString(s)); } }