/** * Put a key/boolean pair in the JSONObject.<p> * * @param key a key string * @param value a boolean which is the value * @return this * @throws JSONException if the key is null */ public JSONObject put(String key, boolean value) throws JSONException { put(key, value ? Boolean.TRUE : Boolean.FALSE); return this; }
/** * Put a key/boolean pair in the JSONObject.<p> * * @param key a key string * @param value a boolean which is the value * @return this * @throws JSONException if the key is null */ public JSONObject put(String key, boolean value) throws JSONException { put(key, value ? Boolean.TRUE : Boolean.FALSE); return this; }
/** * Put a key/value pair in the JSONObject, but only if the * key and the value are both non-null.<p> * * @param key a key string * @param value an object which is the value. It should be of one of these * types: Boolean, Double, Integer, JSONArray, JSONObject, Long, String, * or the JSONObject.NULL object * @return this * @throws JSONException if the value is a non-finite number. */ public JSONObject putOpt(String key, Object value) throws JSONException { if (key != null && value != null) { put(key, value); } return this; }
/** * Put a key/value pair in the JSONObject, but only if the * key and the value are both non-null.<p> * * @param key a key string * @param value an object which is the value. It should be of one of these * types: Boolean, Double, Integer, JSONArray, JSONObject, Long, String, * or the JSONObject.NULL object * @return this * @throws JSONException if the value is a non-finite number. */ public JSONObject putOpt(String key, Object value) throws JSONException { if ((key != null) && (value != null)) { put(key, value); } return this; }
/** * Put a key/int pair in the JSONObject.<p> * * @param key a key string * @param value an int which is the value * @return this * @throws JSONException if the key is null */ public JSONObject put(String key, int value) throws JSONException { put(key, new Integer(value)); return this; }
/** * Put a key/double pair in the JSONObject.<p> * * @param key a key string * @param value a double which is the value * @return this * @throws JSONException if the key is null or if the number is invalid. */ public JSONObject put(String key, double value) throws JSONException { put(key, new Double(value)); return this; }
/** * Put a key/double pair in the JSONObject.<p> * * @param key a key string * @param value a double which is the value * @return this * @throws JSONException if the key is null or if the number is invalid. */ public JSONObject put(String key, double value) throws JSONException { put(key, new Double(value)); return this; }
/** * Put a key/int pair in the JSONObject.<p> * * @param key a key string * @param value an int which is the value * @return this * @throws JSONException if the key is null */ public JSONObject put(String key, int value) throws JSONException { put(key, new Integer(value)); return this; }
/** * Put a key/long pair in the JSONObject.<p> * * @param key a key string * @param value a long which is the value * @return this * @throws JSONException If the key is null */ public JSONObject put(String key, long value) throws JSONException { put(key, new Long(value)); return this; }
/** * Put a key/long pair in the JSONObject.<p> * * @param key a key string * @param value a long which is the value * @return this * @throws JSONException If the key is null */ public JSONObject put(String key, long value) throws JSONException { put(key, new Long(value)); return this; }
/** * @see org.opencms.ui.apps.I_CmsAppSettings#getSettingsString() */ public String getSettingsString() { JSONObject json = new JSONObject(); try { json.put(BRACKETS, m_closeBrackets); json.put(HIGHLIGHTING, m_highlighting); json.put(WRAPPING, m_lineWrapping); json.put(FONTSIZE, m_fontSize); json.put(TABS, m_tabsVisible); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } return json.toString(); }
/** * Put a key/value pair in the JSONObject, where the value will be a * JSONObject which is produced from a Map.<p> * * @param key a key string * @param value a Map value * @return this * @throws JSONException if something goes wrong */ public JSONObject put(String key, Map<String, Object> value) throws JSONException { put(key, new JSONObject(value)); return this; }
/** * Put a key/value pair in the JSONObject, where the value will be a * JSONObject which is produced from a Map.<p> * * @param key a key string * @param value a Map value * @return this * @throws JSONException if something goes wrong */ public JSONObject put(String key, Map value) throws JSONException { put(key, new JSONObject(value)); return this; }
/** * Put a key/value pair in the JSONObject, where the value will be a * JSONArray which is produced from a Collection.<p> * * @param key a key string * @param value a Collection value * @return this * @throws JSONException if something goes wrong */ public JSONObject put(String key, Collection<Object> value) throws JSONException { put(key, new JSONArray(value)); return this; }
/** * @see org.opencms.widgets.CmsAdeImageGalleryWidget#getAdditionalGalleryInfo(org.opencms.file.CmsObject, java.lang.String, org.opencms.i18n.CmsMessages, org.opencms.widgets.I_CmsWidgetParameter) */ @Override protected JSONObject getAdditionalGalleryInfo( CmsObject cms, String resource, CmsMessages messages, I_CmsWidgetParameter param) throws JSONException { JSONObject result = super.getAdditionalGalleryInfo(cms, resource, messages, param); result.put("isAdvancedWidget", true); return result; }
/** * Put a key/value pair in the JSONObject, where the value will be a * JSONArray which is produced from a Collection.<p> * * @param key a key string * @param value a Collection value * @return this * @throws JSONException if something goes wrong */ public JSONObject put(String key, Collection value) throws JSONException { put(key, new JSONArray(value)); return this; }
/** * Encodes a map with string keys and values as a JSON string with the same keys/values.<p> * * @param map the input map * @return the JSON data containing the map entries */ public static String mapAsJson(Map<String, String> map) { JSONObject obj = new JSONObject(); for (Map.Entry<String, String> entry : map.entrySet()) { try { obj.put(entry.getKey(), entry.getValue()); } catch (JSONException e) { LOG.error(e.getLocalizedMessage(), e); } } return obj.toString(); }
/** * Opens the gallery dialog for the given gallery folder.<p> * * @param resource the gallery folder resource */ public void openGalleryDialog(CmsResource resource) { try { CmsObject cms = A_CmsUI.getCmsObject(); JSONObject conf = new JSONObject(); conf.put(I_CmsGalleryProviderConstants.CONFIG_GALLERY_MODE, GalleryMode.view.name()); conf.put(I_CmsGalleryProviderConstants.CONFIG_GALLERY_PATH, cms.getSitePath(resource)); conf.put(I_CmsGalleryProviderConstants.CONFIG_GALLERY_STORAGE_PREFIX, ""); conf.put(I_CmsGalleryProviderConstants.CONFIG_TAB_CONFIG, CmsGalleryTabConfiguration.TC_SELECT_ALL); getRpcProxy(I_CmsGwtDialogClientRpc.class).openGalleryDialog(conf.toString()); } catch (JSONException e) { CmsErrorDialog.showErrorDialog(e); } }
/** * @see org.opencms.widgets.I_CmsComplexWidget#getWidgetData(org.opencms.file.CmsObject) */ public CmsComplexWidgetData getWidgetData(CmsObject cms) { String configToUse = m_config; try { JSONObject json = new JSONObject(m_config); String icon = json.optString(CmsDataViewConstants.CONFIG_ICON); if (icon != null) { String iconLink = OpenCms.getLinkManager().substituteLinkForUnknownTarget(cms, icon); json.put(CmsDataViewConstants.CONFIG_ICON, iconLink); configToUse = json.toString(); } } catch (Exception e) { LOG.error(e.getLocalizedMessage(), e); } return new CmsComplexWidgetData(CmsDataViewConstants.RENDERER_ID, configToUse, null); }
/** * Stores the folder filters for the current site.<p> * * @param folders the folder filters */ private void storeFolderFilter(Set<String> folders) { JSONObject storedFilters = readUserFolderFilters(); try { storedFilters.put(getCmsObject().getRequestContext().getSiteRoot(), folders); CmsUser user = getCmsObject().getRequestContext().getCurrentUser(); user.setAdditionalInfo(FOLDER_FILTER_ADD_INFO_KEY, storedFilters.toString()); getCmsObject().writeUser(user); } catch (Exception e) { LOG.error(e.getLocalizedMessage(), e); } }