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