Class FileConfiguration
- All Implemented Interfaces:
Configuration,ConfigurationSection
- Direct Known Subclasses:
YamlConfiguration
Configuration.-
Field Summary
Fields inherited from class com.plotsquared.core.configuration.MemoryConfiguration
defaults, optionsFields inherited from class com.plotsquared.core.configuration.MemorySection
map -
Constructor Summary
ConstructorsConstructorDescriptionFileConfiguration(Configuration defaults)Creates an empty FileConfiguration using the specifiedConfigurationas a source for all default values. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract StringCompiles the header for this FileConfiguration and returns the result.voidLoads this FileConfiguration from the specified location.voidLoads this FileConfiguration from the specified reader.abstract voidloadFromString(String contents)Loads this FileConfiguration from the specified string, as opposed to from file.options()Gets theConfigurationOptionsfor thisConfiguration.voidSaves this FileConfiguration to the specified location.abstract StringSaves this FileConfiguration to a string, and returns it.Methods inherited from class com.plotsquared.core.configuration.MemoryConfiguration
addDefault, addDefaults, addDefaults, getDefaults, getParent, setDefaultsMethods inherited from class com.plotsquared.core.configuration.MemorySection
contains, createPath, createPath, createSection, createSection, get, get, getBoolean, getBoolean, getBooleanList, getByteList, getCharacterList, getConfigurationSection, getCurrentPath, getDefault, getDefaultSection, getDouble, getDouble, getDoubleList, getFloatList, getInt, getInt, getIntegerList, getKeys, getList, getList, getLong, getLong, getLongList, getMapList, getName, getRoot, getShortList, getString, getString, getStringList, getValues, isBoolean, isConfigurationSection, isDouble, isInt, isList, isLong, isPrimitiveWrapper, isSet, isString, mapChildrenKeys, mapChildrenValues, set, toDouble, toInt, toLong, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.plotsquared.core.configuration.ConfigurationSection
contains, createSection, createSection, get, get, getBoolean, getBoolean, getBooleanList, getByteList, getCharacterList, getConfigurationSection, getCurrentPath, getDefaultSection, getDouble, getDouble, getDoubleList, getFloatList, getInt, getInt, getIntegerList, getKeys, getList, getList, getLong, getLong, getLongList, getMapList, getName, getRoot, getShortList, getString, getString, getStringList, getValues, isBoolean, isConfigurationSection, isDouble, isInt, isList, isLong, isSet, isString, set
-
Constructor Details
-
FileConfiguration
Creates an empty FileConfiguration using the specifiedConfigurationas a source for all default values.- Parameters:
defaults- Default value provider
-
-
Method Details
-
save
Saves this FileConfiguration to the specified location.If the file does not exist, it will be created. If already exists, it will be overwritten. If it cannot be overwritten or created, an exception will be thrown.
This method will save using the system default encoding, or possibly using UTF8.
- Parameters:
file- File to save to.- Throws:
IOException- Thrown when the given file cannot be written to for any reason.
-
saveToString
Saves this FileConfiguration to a string, and returns it.- Returns:
- String containing this configuration.
-
load
Loads this FileConfiguration from the specified location.All the values contained within this configuration will be removed, leaving only settings and defaults, and the new values will be loaded from the given file.
If the file cannot be loaded for any reason, an exception will be thrown.
- Parameters:
file- File to load from.- Throws:
FileNotFoundException- Thrown when the given file cannot be opened.IOException- Thrown when the given file cannot be read.InvalidConfigurationException- Thrown when the given file is not a valid Configuration.IllegalArgumentException- Thrown when file is null.
-
load
Loads this FileConfiguration from the specified reader.All the values contained within this configuration will be removed, leaving only settings and defaults, and the new values will be loaded from the given stream.
- Parameters:
reader- the reader to load from- Throws:
IOException- thrown when underlying reader throws an IOExceptionInvalidConfigurationException- thrown when the reader does not represent a valid Configuration
-
loadFromString
Loads this FileConfiguration from the specified string, as opposed to from file.All the values contained within this configuration will be removed, leaving only settings and defaults, and the new values will be loaded from the given string.
If the string is invalid in any way, an exception will be thrown.
- Parameters:
contents- Contents of a Configuration to load.- Throws:
InvalidConfigurationException- Thrown if the specified string is invalid.
-
buildHeader
Compiles the header for this FileConfiguration and returns the result.This will use the header from
options()->FileConfigurationOptions.header(), respecting the rules ofFileConfigurationOptions.copyHeader()if set.- Returns:
- Compiled header
-
options
Description copied from interface:ConfigurationGets theConfigurationOptionsfor thisConfiguration.All setters through this method are chainable.
- Specified by:
optionsin interfaceConfiguration- Overrides:
optionsin classMemoryConfiguration- Returns:
- Options for this configuration
-