Class FileConfiguration
- All Implemented Interfaces:
Configuration,ConfigurationSection
- Direct Known Subclasses:
YamlConfiguration
Synchronized with the commit on 07-June-2022.
-
Field Summary
Fields inherited from class org.bspfsystems.yamlconfiguration.configuration.MemoryConfiguration
defs, options -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructs an empty file configuration with no default values.protectedFileConfiguration(@Nullable Configuration defs) Constructs an empty file configuration using the given configuration as a source for all default values. -
Method Summary
Modifier and TypeMethodDescription@NotNull FileConfigurationOptionsGets the options for this configuration.final voidLoads this file configuration from the given file.final voidLoads this file configuration from the given reader.final voidLoads this file configuration from the file at the given path.abstract voidloadFromString(@NotNull String data) Loads this file configuration from the given string.final voidSaves this file configuration to the given file.final voidSaves this file configuration to the given file.abstract @NotNull StringConverts this file configuration to a string.Methods inherited from class org.bspfsystems.yamlconfiguration.configuration.MemoryConfiguration
addDefault, addDefaults, addDefaults, getDefaults, getParent, setDefaultsMethods inherited from class org.bspfsystems.yamlconfiguration.configuration.MemorySection
clear, contains, contains, createPath, createPath, createSection, createSection, get, get, getBoolean, getBoolean, getBooleanList, getByte, getByte, getByteList, getChar, getChar, getCharList, getComments, getConfigurationSection, getCurrentPath, getDefaultSection, getDouble, getDouble, getDoubleList, getFloat, getFloat, getFloatList, getInlineComments, getInt, getInt, getIntList, getKeys, getList, getList, getLong, getLong, getLongList, getMapList, getName, getObject, getObject, getRoot, getSerializable, getSerializable, getShort, getShort, getShortList, getString, getString, getStringList, getValues, isBoolean, isByte, isChar, isConfigurationSection, isDouble, isFloat, isInt, isList, isLong, isNumber, isSet, isShort, isString, set, setComments, setInlineComments, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.bspfsystems.yamlconfiguration.configuration.ConfigurationSection
contains, contains, createSection, createSection, get, get, getBoolean, getBoolean, getBooleanList, getByte, getByte, getByteList, getChar, getChar, getCharList, getComments, getConfigurationSection, getCurrentPath, getDefaultSection, getDouble, getDouble, getDoubleList, getFloat, getFloat, getFloatList, getInlineComments, getInt, getInt, getIntList, getKeys, getList, getList, getLong, getLong, getLongList, getMapList, getName, getObject, getObject, getRoot, getSerializable, getSerializable, getShort, getShort, getShortList, getString, getString, getStringList, getValues, isBoolean, isByte, isChar, isConfigurationSection, isDouble, isFloat, isInt, isList, isLong, isNumber, isSet, isShort, isString, set, setComments, setInlineComments
-
Constructor Details
-
FileConfiguration
protected FileConfiguration()Constructs an empty file configuration with no default values.- See Also:
-
FileConfiguration
Constructs an empty file configuration using the given configuration as a source for all default values.- Parameters:
defs- The default value provider configuration.- See Also:
-
-
Method Details
-
save
Saves this file configuration to the given file.If the given file does not exist, it will attempt to be created. If it already exists, any contents will be overwritten, regardless of the old or new contents. If it cannot be created or overwritten, an I/O exception will be thrown.
This method will save using the UTF-8 charset.
- Parameters:
file- The file to save to.- Throws:
IOException- If this file configuration cannot be written.- See Also:
-
save
Saves this file configuration to the given file.If the file at the given path does not exist, it will attempt to be created. If it already exists, any contents will be overwritten, regardless of the old or new contents. If it cannot be created or overwritten, an I/O exception will be thrown.
This method will save using the UTF-8 charset.
- Parameters:
path- The path of the file to save to.- Throws:
IOException- If this file configuration cannot be written.- See Also:
-
saveToString
Converts this file configuration to a string.- Returns:
- A string representing this file configuration.
-
load
public final void load(@NotNull @NotNull Reader reader) throws IOException, InvalidConfigurationException Loads this file configuration from the given reader.All values contained in-memory in this file configuration will be removed, leaving only the file configuration options as well as any defaults. The new values will be loaded into memory from the given reader.
- Parameters:
reader- The reader used to load this file configuration.- Throws:
IOException- If the given reader encounters an error.InvalidConfigurationException- If the data in the reader cannot be parsed as a file configuration.- See Also:
-
load
public final void load(@NotNull @NotNull File file) throws IOException, InvalidConfigurationException Loads this file configuration from the given file.All values contained in-memory in this file configuration will be removed, leaving only the file configuration options as well as any defaults. The new values will be loaded into memory from the given file.
- Parameters:
file- The file used to load this file configuration.- Throws:
IOException- If the given file cannot be read.InvalidConfigurationException- If the data in the file cannot be parsed as a file configuration.- See Also:
-
load
public final void load(@NotNull @NotNull String path) throws IOException, InvalidConfigurationException Loads this file configuration from the file at the given path.All values contained in-memory in this file configuration will be removed, leaving only the file configuration options as well as any defaults. The new values will be loaded into memory from the file at the given path.
- Parameters:
path- The path of the file to load from.- Throws:
IOException- If the file cannot be read.InvalidConfigurationException- If the data in the file cannot be parsed as a file configuration.- See Also:
-
loadFromString
public abstract void loadFromString(@NotNull @NotNull String data) throws InvalidConfigurationException Loads this file configuration from the given string.All values contained in-memory in this file configuration will be removed, leaving only the file configuration options as well as any defaults. The new values will be loaded into memory from the given string.
- Parameters:
data- The string representation of the file configuration data to load.- Throws:
InvalidConfigurationException- If the given string cannot be parsed as a file configuration.
-
getOptions
Gets the options for this configuration.All setters through this method are chainable.
- Specified by:
getOptionsin interfaceConfiguration- Overrides:
getOptionsin classMemoryConfiguration- Returns:
- The options for this configuration.
-