/** * Returns the new value for the modified variable as a long. * <p> * If the variable has been deleted, this method will return 0. * </p> * @return the new value for the modified variable. * @throws NumberFormatException if {@link #getValue()} cannot be cast as a long. */ public long getLongValue() throws NumberFormatException { return ConfigurationSection.getLongValue(value); }
/** * Returns the value of the specified variable as a long. * @param name fully qualified name of the variable whose value should be retrieved. * @return the variable's value if set, <code>0</code> otherwise. * @throws NumberFormatException if the variable's value cannot be cast to a long. * @see #setVariable(String,long) * @see #getVariable(String,long) */ public long getLongVariable(String name) { return ConfigurationSection.getLongValue(getVariable(name)); }
/** * Deletes the specified variable from the configuration. * <p> * If the variable was set, a configuration {@link ConfigurationEvent event} will be passed to * all registered LISTENERS. * </p> * @param name name of the variable to remove. * @return the variable's old value, or <code>0</code> if it wasn't set. */ public long removeLongVariable(String name) { return ConfigurationSection.getLongValue(removeVariable(name)); }
/** * Returns the next value in the iterator as a long. * @return the next value in the iterator as a long. * @throws NoSuchElementException if the iteration has no more elements. * @throws NumberFormatException if the value cannot be cast to a long. */ public long nextLongValue() { return ConfigurationSection.getLongValue(nextValue()); }
/** * Returns the value found at the specified index of the list as a long. * @param index index of the value to retrieve. * @return the value found at the specified index of the list as a long. * @throws NumberFormatException if the value cannot be cast to a long. */ public long longValueAt(int index) { return ConfigurationSection.getLongValue(valueAt(index)); }
/** * Retrieves the value of the specified variable as a long. * <p> * If the variable isn't set, this method will set it to <code>defaultValue</code> before * returning it. If this happens, a configuration {@link ConfigurationEvent event} will * be sent to all registered LISTENERS. * </p> * @param name name of the variable to retrieve. * @param defaultValue value to use if <code>name</code> is not set. * @return the specified variable's value. * @throws NumberFormatException if the variable's value cannot be cast to a long. * @see #setVariable(String,long) * @see #getLongVariable(String) */ public long getVariable(String name, long defaultValue) { return ConfigurationSection.getLongValue(getVariable(name, ConfigurationSection.getValue(defaultValue))); }
/** * Tests the long value helpers. */ @Test public void testLongs() { for(long i = 0; i < 10; i++) { assert ConfigurationSection.getLongValue(Long.toString(i)) == i; assert ConfigurationSection.getValue(i).equals(Long.toString(i)); } assert ConfigurationSection.getLongValue(null) == 0; }