/** * Returns the new value for the modified variable cast as a double. * <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 double. */ public double getDoubleValue() { return ConfigurationSection.getDoubleValue(value); }
/** * Returns the value of the specified variable as a double. * @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 double. * @see #setVariable(String,double) * @see #getVariable(String,double) */ public double getDoubleVariable(String name) { return ConfigurationSection.getDoubleValue(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 double removeDoubleVariable(String name) { return ConfigurationSection.getDoubleValue(removeVariable(name)); }
/** * Returns the next value in the iterator as a double. * @return the next value in the iterator as a double. * @throws NoSuchElementException if the iteration has no more elements. * @throws NumberFormatException if the value cannot be cast to a double. */ public double nextDoubleValue() { return ConfigurationSection.getDoubleValue(nextValue()); }
/** * Returns the value found at the specified index of the list as a double. * @param index index of the value to retrieve. * @return the value found at the specified index of the list as a double. * @throws NumberFormatException if the value cannot be cast to a double. */ public double doubleValueAt(int index) { return ConfigurationSection.getDoubleValue(valueAt(index)); }
/** * Tests the double value helpers. */ @Test public void testDoubles() { for(int i = 0; i < 10; i++) { assert ConfigurationSection.getDoubleValue(i + ".5") == (i + 0.5d); assert ConfigurationSection.getValue((i + 0.5d)).equals(i + ".5"); } assert ConfigurationSection.getDoubleValue(null) == 0f; }
/** * Retrieves the value of the specified variable as a double. * <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 double. * @see #setVariable(String,double) * @see #getDoubleVariable(String) */ public double getVariable(String name, double defaultValue) { return ConfigurationSection.getDoubleValue(getVariable(name, ConfigurationSection.getValue(defaultValue))); }