/** * Returns the new value for the modified variable cast as an integer. * <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 an integer. */ public int getIntegerValue() throws NumberFormatException { return ConfigurationSection.getIntegerValue(value); }
/** * Returns the value found at the specified index of the list as an integer. * @param index index of the value to retrieve. * @return the value found at the specified index of the list as an integer. * @throws NumberFormatException if the value cannot be cast to an integer. */ public int integerValueAt(int index) { return ConfigurationSection.getIntegerValue(valueAt(index)); }
/** * Returns the next value in the iterator as a integer. * @return the next value in the iterator as a integer. * @throws NoSuchElementException if the iteration has no more elements. * @throws NumberFormatException if the value cannot be cast to an integer. */ public int nextIntegerValue() { return ConfigurationSection.getIntegerValue(nextValue()); }
/** * Returns the value of the specified variable as an integer. * @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 an integer. * @see #setVariable(String,int) * @see #getVariable(String,int) */ public int getIntegerVariable(String name) { return ConfigurationSection.getIntegerValue(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 int removeIntegerVariable(String name) { return ConfigurationSection.getIntegerValue(removeVariable(name)); }
/** * Tests the integer value helpers. */ @Test public void testIntegers() { for(int i = 0; i < 10; i++) { assert ConfigurationSection.getIntegerValue(Integer.toString(i)) == i; assert ConfigurationSection.getValue(i).equals(Integer.toString(i)); } assert ConfigurationSection.getIntegerValue(null) == 0; }
/** * Retrieves the value of the specified variable as an integer. * <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 an integer. * @see #setVariable(String,int) * @see #getIntegerVariable(String) */ public int getVariable(String name, int defaultValue) { return ConfigurationSection.getIntegerValue(getVariable(name, ConfigurationSection.getValue(defaultValue))); }