/** * Get an optional boolean associated with a key.<p> * * It returns the defaultValue if there is no such key, or if it is not * a Boolean or the String "true" or "false" (case insensitive).<p> * * @param key a key string * @param defaultValue the default * @return the truth */ public boolean optBoolean(String key, boolean defaultValue) { try { return getBoolean(key); } catch (Exception e) { return defaultValue; } }
/** * Get an optional boolean associated with a key.<p> * * It returns the defaultValue if there is no such key, or if it is not * a Boolean or the String "true" or "false" (case insensitive).<p> * * @param key a key string * @param defaultValue the default * @return the truth */ public boolean optBoolean(String key, boolean defaultValue) { try { return getBoolean(key); } catch (Exception e) { return defaultValue; } }
/** Helper for reading an optional Boolean value - returning <code>null</code> if parsing fails. * @param json The JSON object where the value should be read from. * @param key The key of the value to read. * @return The value from the JSON, or <code>null</code> if the value does not exist, or is no Boolean. */ protected Boolean parseOptionalBooleanValue(final JSONObject json, final String key) { try { return Boolean.valueOf(json.getBoolean(key)); } catch (final JSONException e) { LOG.info(Messages.get().getBundle().key(Messages.LOG_OPTIONAL_BOOLEAN_MISSING_1, key), e); return null; } }
/** * @see org.opencms.ui.apps.I_CmsAppSettings#restoreSettings(java.lang.String) */ public void restoreSettings(String storedSettings) { try { JSONObject json = new JSONObject(storedSettings); if (json.has(BRACKETS)) { m_closeBrackets = json.getBoolean(BRACKETS); } if (json.has(HIGHLIGHTING)) { m_highlighting = json.getBoolean(HIGHLIGHTING); } if (json.has(WRAPPING)) { m_lineWrapping = json.getBoolean(WRAPPING); } if (json.has(TABS)) { m_tabsVisible = json.getBoolean(TABS); } if (json.has(FONTSIZE)) { m_fontSize = json.getString(FONTSIZE); } } catch (JSONException e) { // LOG.error("Failed to restore file explorer settings from '" + storedSettings + "'", e); } } }
/** * @see org.opencms.ui.apps.I_CmsAppSettings#restoreSettings(java.lang.String) */ public void restoreSettings(String storedSettings) { Map<String, CmsResourceTableProperty> columnMap = CmsResourceTableProperty.getDefaultColumnsByName(); try { JSONObject json = new JSONObject(storedSettings); if (json.has(SORT_ORDER_KEY)) { m_sortAscending = json.getBoolean(SORT_ORDER_KEY); } if (json.has(SORT_COLUMN_KEY)) { m_sortColumnId = columnMap.get(json.getString(SORT_COLUMN_KEY)); } if (json.has(COLLAPSED_COLUMNS_KEY)) { List<CmsResourceTableProperty> collapsed = new ArrayList<CmsResourceTableProperty>(); JSONArray array = json.getJSONArray(COLLAPSED_COLUMNS_KEY); for (int i = 0; i < array.length(); i++) { collapsed.add(columnMap.get(array.getString(i))); } m_collapsedColumns = collapsed; } } catch (JSONException e) { LOG.error("Failed to restore file explorer settings from '" + storedSettings + "'", e); } }
int containerWidth = contextInfo.getInt(CmsCntPageData.JSONKEY_WIDTH); int maxElements = contextInfo.getInt(CmsCntPageData.JSONKEY_MAXELEMENTS); boolean detailView = contextInfo.getBoolean(CmsCntPageData.JSONKEY_DETAILVIEW); CmsContainer container = new CmsContainer( containerName,