/** * Get an optional int value associated with a key, * or the default if there is no such key or if the value is not a number.<p> * * If the value is a string, an attempt will be made to evaluate it as * a number.<p> * * @param key a key string * @param defaultValue the default * @return an object which is the value */ public int optInt(String key, int defaultValue) { try { return getInt(key); } catch (Exception e) { return defaultValue; } }
/** * Get an optional int value associated with a key, * or the default if there is no such key or if the value is not a number.<p> * * If the value is a string, an attempt will be made to evaluate it as * a number.<p> * * @param key a key string * @param defaultValue the default * @return an object which is the value */ public int optInt(String key, int defaultValue) { try { return getInt(key); } catch (Exception e) { return defaultValue; } }
/** Returns the configured page size, or the default page size if no core is configured. * @return The configured page size, or the default page size if no core is configured. */ private Integer getPageSize() { try { return Integer.valueOf(m_configObject.getInt(JSON_KEY_PAGESIZE)); } catch (final JSONException e) { LOG.info(Messages.get().getBundle().key(Messages.LOG_NO_PAGESIZE_SPECIFIED_0), e); return DEFAULT_PAGE_SIZE; } }
/** Helper for reading an optional Integer 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 Integer. */ protected Integer parseOptionalIntValue(final JSONObject json, final String key) { try { return Integer.valueOf(json.getInt(key)); } catch (final JSONException e) { LOG.info(Messages.get().getBundle().key(Messages.LOG_OPTIONAL_INTEGER_MISSING_1, key), e); return null; } }
/** * Initializes the 'accepted' data from the current user.<p> * Returns the absolute path in the OpenCms VFS to the user agreement configuration file.<p> */ protected void initAcceptData() { // read the current users agreement values CmsUser user = getCms().getRequestContext().getCurrentUser(); String result = (String)user.getAdditionalInfo(CmsUserSettings.LOGIN_USERAGREEMENT_ACCEPTED); if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(result)) { // read JSON data structure that is stored in the user additional info try { JSONObject jsonData = new JSONObject(result); m_acceptedVersion = jsonData.getDouble(KEY_ACCEPTED_VERSION); m_acceptedCount = jsonData.getInt(KEY_ACCEPTED_COUNT); } catch (JSONException e) { LOG.error(e); } } }
String containerName = contextInfo.getString(CmsCntPageData.JSONKEY_NAME); String containerType = contextInfo.getString(CmsCntPageData.JSONKEY_TYPE); 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(