List of usage examples for com.google.gwt.json.client JSONArray toString
@Override
public String toString()
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())); }//ww w. j a v a 2s. 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.RosterPlugin.java
License:Open Source License
public void saveStatus() { try {//from w ww.jav a 2 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: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))); }/*w w w . j a v a 2 s . c om*/ s().setItem(FILE_LIST, a.toString()); fListCache = fileList(); }
From source file:client.serializers.JSONSeriesSerializer.java
License:Open Source License
/** * Serialize to JSON.// w w w. j av a2 s. c o m */ @Override public String serialize(SortedSet<Integer> years, List<SeriesManager.Row> rows) { JSONArray array = new JSONArray(); int arrayIndex = 0; for (SeriesManager.Row row : rows) { JSONObject rowObject = new JSONObject(); Series series = row.getSeries(); Country country = series.getCountry(); if (country != null) { rowObject.put(COUNTRY_NAME, new JSONString(country.getName())); rowObject.put(COUNTRY_ISO, new JSONString(country.getISO())); } List<Point> points = series.getPoints(); if (points != null) { for (Point point : points) { rowObject.put(point.getYear() + "", new JSONNumber(((int) (point.getValue() * RES)) / RES)); } } array.set(arrayIndex, rowObject); arrayIndex++; } return array.toString(); }
From source file:com.audata.client.json.JSONCall.java
License:Open Source License
public String getJSONMsg(String method, JSONArray params) { String msg = ""; JSONCall.count++;//w w w . ja v a 2 s . com int id = JSONCall.count; msg = "{\"method\":\"" + method + "\",\"id\":\"" + id + "\",\"params\":" + params.toString() + "}"; return msg; }
From source file:com.data2semantics.yasgui.client.View.java
License:Open Source License
/** * For a given endpoint, check whether it is defined in our endpoints datasource. * If it isnt, add it /*from w w w .ja v a 2s . com*/ * * @param endpoint */ public void checkAndAddEndpointToDs(String endpoint) { if (!getSettings().inSingleEndpointMode()) { Record[] records = endpointDataSource.getCacheData(); boolean exists = false; for (Record record : records) { String recordEndpoint = record.getAttribute(Endpoints.KEY_ENDPOINT); if (recordEndpoint != null && recordEndpoint.equals(endpoint)) { exists = true; break; } } if (!exists) { //Ok, so endpoint is not in our datasource. let's add it ListGridRecord listGridRecord = new ListGridRecord(); listGridRecord.setAttribute(Endpoints.KEY_ENDPOINT, endpoint); Record[] newRecords = new Record[records.length + 1]; newRecords[0] = listGridRecord; System.arraycopy(records, 0, newRecords, 1, records.length); endpointDataSource = new EndpointDataSource(this, newRecords); if (Storage.isSupported()) { //we have html5. add it to local storage as well so we keep it persistent between sessions String endpointsJsonString = LocalStorageHelper.getEndpointsFromLocalStorage(); if (endpointsJsonString == null) { //There are no endpoints in our storage. //This is kinda strange, but lets create a json array with this new endpoint anyway JSONArray jsonArray = new JSONArray(); JSONObject newEndpointObject = new JSONObject(); newEndpointObject.put(Endpoints.KEY_ENDPOINT, new JSONString(endpoint)); jsonArray.set(0, newEndpointObject); LocalStorageHelper.setEndpoints(jsonArray.toString()); } else { //Prepend the new endpoint to the array in our json object JSONValue jsonVal = JSONParser.parseStrict(endpointsJsonString); if (jsonVal != null) { JSONArray endpoints = jsonVal.isArray(); JSONArray newEndpointsArray = new JSONArray(); JSONObject newEndpointObject = new JSONObject(); newEndpointObject.put(Endpoints.KEY_ENDPOINT, new JSONString(endpoint)); newEndpointsArray.set(0, newEndpointObject); if (endpoints != null) { for (int i = 0; i < endpoints.size(); i++) { newEndpointsArray.set(newEndpointsArray.size(), endpoints.get(i)); } } LocalStorageHelper.setEndpoints(newEndpointsArray.toString()); } } } } } }
From source file:de.catma.ui.client.ui.tagger.ClientTagInstanceJSONSerializer.java
License:Open Source License
public String toJSONArray(List<String> tagInstanceIDs) { int i = 0;//from w w w. j av a 2 s. co m JSONArray result = new JSONArray(); for (String tagInstanceID : tagInstanceIDs) { JSONObject instanceJSON = new JSONObject(); instanceJSON.put(SerializationField.instanceID.name(), new JSONString(tagInstanceID)); result.set(i, instanceJSON); i++; } return result.toString(); }
From source file:de.kp.ames.web.client.fnc.access.widget.AccessorFormImpl.java
License:Open Source License
public String getFormData() { JSONObject jForm = new JSONObject(); /*/*from w w w. ja va 2 s .c o m*/ * Name & description */ String name = ""; String desc = ""; String id = null; FormItem[] items = scForm.getFields(); for (FormItem item : items) { if (JaxrConstants.RIM_NAME.equals(item.getName())) { name = (String) item.getValue(); } else if (JaxrConstants.RIM_DESC.equals(item.getName())) { desc = (String) item.getValue(); } else if (JaxrConstants.RIM_ID.equals(item.getName())) { id = (String) item.getValue(); } } jForm.put(JaxrConstants.RIM_NAME, new JSONString(name)); jForm.put(JaxrConstants.RIM_DESC, new JSONString(desc)); /* * RIM-Id */ if (id != null) jForm.put(JaxrConstants.RIM_ID, new JSONString(id)); /* * Slots */ JSONObject jSlot = new SlotObject().toJObject(slotGrid.getRecords()); jForm.put(JaxrConstants.RIM_SLOT, new JSONString(jSlot.toString())); /* * Classification */ JSONArray jClas = new ConceptObject().toJArray(clasGrid.getRecords()); /* * force add mandatory classification */ jClas.set(jClas.size(), new JSONString(ClassificationConstants.FNC_ID_Accessor)); jForm.put(JaxrConstants.RIM_CLAS, new JSONString(jClas.toString())); /* * Specifications */ JSONArray jSpecs = new SpecObject().toJArray(specGrid.getRecords()); jForm.put(JaxrConstants.RIM_SPEC, new JSONString(jSpecs.toString())); return jForm.toString(); }
From source file:de.kp.ames.web.client.fnc.role.widget.ResponsibilityCreateDialog.java
License:Open Source License
public void doSend() { JSONArray jNamespaces = new JSONArray(); Record[] selected = this.grid.getSelectedRecords(); if (selected.length == 0) { String message = FncGlobals.RESPONSIBILITY_ERROR; SC.say(GuiConstants.APP_TITLE + ": Responsibility Error", message); this.setAutoClose(false); return;/*from ww w .j av a 2s.c o m*/ } this.setAutoClose(true); /* * Retrieve namespaces */ for (Record record : selected) { String namespace = record.getAttributeAsString(JaxrConstants.RIM_ID); jNamespaces.set(jNamespaces.size(), new JSONString(namespace)); } JSONObject jData = new JSONObject(); jData.put(JaxrConstants.RIM_NAMESPACE, new JSONString(jNamespaces.toString())); String data = jData.toString(); HashMap<String, String> attributes = new HashMap<String, String>(); attributes.putAll(this.getParams()); RoleService service = new RoleService(); service.doSubmit(attributes, data, this.sendActivity); }
From source file:de.kp.ames.web.client.fnc.transform.widget.TransformFormImpl.java
License:Open Source License
public String getFormData() { JSONObject jForm = new JSONObject(); /*// ww w .j av a2 s .c o m * Key from cache entry */ if (transformRecord == null) return null; String key = transformRecord.getAttributeAsString(JsonConstants.J_KEY); jForm.put(JsonConstants.J_KEY, new JSONString(key)); /* * Name & description */ String name = ""; String desc = ""; FormItem[] items = scForm.getFields(); for (FormItem item : items) { if (JaxrConstants.RIM_NAME.equals(item.getName())) { name = (String) item.getValue(); } else if (JaxrConstants.RIM_DESC.equals(item.getName())) { desc = (String) item.getValue(); } } jForm.put(JaxrConstants.RIM_NAME, new JSONString(name)); jForm.put(JaxrConstants.RIM_DESC, new JSONString(desc)); /* * Classification */ JSONArray jClas = new JSONArray(); jClas.set(0, new JSONString(ClassificationConstants.FNC_ID_Transformator)); jForm.put(JaxrConstants.RIM_CLAS, new JSONString(jClas.toString())); return jForm.toString(); }