/** * Get the int value associated with a key.<p> * * If the number value is too large for an int, it will be clipped.<p> * * @param key a key string * @return the integer value * @throws JSONException if the key is not found or if the value cannot * be converted to an integer */ public int getInt(String key) throws JSONException { Object o = get(key); return o instanceof Number ? ((Number)o).intValue() : (int)getDouble(key); }
/** * Get the long value associated with a key.<p> * * If the number value is too long for a long, it will be clipped.<p> * * @param key a key string * @return the long value. * @throws JSONException if the key is not found or if the value cannot * be converted to a long */ public long getLong(String key) throws JSONException { Object o = get(key); return o instanceof Number ? ((Number)o).longValue() : (long)getDouble(key); }
/** * Get the long value associated with a key.<p> * * If the number value is too long for a long, it will be clipped.<p> * * @param key a key string * @return the long value. * @throws JSONException if the key is not found or if the value cannot * be converted to a long */ public long getLong(String key) throws JSONException { Object o = get(key); return o instanceof Number ? ((Number)o).longValue() : (long)getDouble(key); }
/** * Get the int value associated with a key.<p> * * If the number value is too large for an int, it will be clipped.<p> * * @param key a key string * @return the integer value * @throws JSONException if the key is not found or if the value cannot * be converted to an integer */ public int getInt(String key) throws JSONException { Object o = get(key); return o instanceof Number ? ((Number)o).intValue() : (int)getDouble(key); }
/** * 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); } } }