Class FileConfiguration
- All Implemented Interfaces:
Configuration,ConfigurationSection,LoadableConfiguration
- Direct Known Subclasses:
YamlConfiguration
Configuration- Author:
- Bukkit, Carleslc
- See Also:
-
Field Summary
Fields inherited from class org.simpleyaml.configuration.MemoryConfiguration
defaults, optionsFields inherited from class org.simpleyaml.configuration.MemorySection
map -
Constructor Summary
ConstructorsConstructorDescriptionCreates an emptyFileConfigurationwith no default values.FileConfiguration(Configuration defaults) Creates an emptyFileConfigurationusing the specifiedConfigurationas a source for all default values. -
Method Summary
Modifier and TypeMethodDescriptionCompiles the header for thisFileConfigurationand returns the result.voidLoads this configuration from the specified file.voidload(InputStream stream) Loads this configuration from the specified stream.voidLoads this configuration from the specified reader.voidLoads this configuration from the specified file path.options()Gets theConfigurationOptionsfor thisConfiguration.voidSaves thisFileConfigurationto the specified location.voidSaves this configuration to a writer.voidSaves thisFileConfigurationto the specified location.Methods inherited from class org.simpleyaml.configuration.MemoryConfiguration
addDefault, addDefaults, addDefaults, getDefaults, getParent, setDefaultsMethods inherited from class org.simpleyaml.configuration.MemorySection
contains, createPath, createPath, createSection, createSection, get, get, getBoolean, getBoolean, getBooleanList, getByte, getByte, getByteList, getCharacter, getCharacter, getCharacterList, getConfigurationSection, getCurrentPath, getDefault, getDefaultSection, getDouble, getDouble, getDoubleList, getFloat, getFloat, getFloatList, getInt, getInt, getIntegerList, getKeys, getList, getList, getLong, getLong, getLongList, getMapList, getMapValues, getName, getRoot, getShort, getShort, getShortList, getString, getString, getStringList, getValues, isBoolean, isByte, isCharacter, isConfigurationSection, isDouble, isEmpty, isFloat, isInt, isList, isLong, isPrimitiveWrapper, isSet, isShort, isString, mapChildrenKeys, mapChildrenValues, set, size, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.simpleyaml.configuration.ConfigurationSection
contains, createSection, createSection, get, get, getBoolean, getBoolean, getBooleanList, getByte, getByte, getByteList, getCharacter, getCharacter, getCharacterList, getConfigurationSection, getCurrentPath, getDefaultSection, getDouble, getDouble, getDoubleList, getFloat, getFloat, getFloatList, getInt, getInt, getIntegerList, getKeys, getList, getList, getLong, getLong, getLongList, getMapList, getMapValues, getName, getRoot, getShort, getShort, getShortList, getString, getString, getStringList, getValues, isBoolean, isByte, isCharacter, isConfigurationSection, isDouble, isEmpty, isFloat, isInt, isList, isLong, isSet, isShort, isString, remove, set, sizeMethods inherited from interface org.simpleyaml.configuration.LoadableConfiguration
loadFromString, saveToString
-
Constructor Details
-
FileConfiguration
public FileConfiguration()Creates an emptyFileConfigurationwith no default values. -
FileConfiguration
Creates an emptyFileConfigurationusing the specifiedConfigurationas a source for all default values.- Parameters:
defaults- Default value provider
-
-
Method Details
-
save
Saves thisFileConfigurationto 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 use the
options()charsetencoding, which defaults to UTF8.- Parameters:
file- File to save to.- Throws:
IOException- Thrown when the given file cannot be written to for any reason.IllegalArgumentException- Thrown when file is null.
-
save
Saves thisFileConfigurationto 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 use the
options()charsetencoding, which defaults to UTF8.- Parameters:
file- File to save to.- Throws:
IOException- Thrown when the given file cannot be written to for any reason.IllegalArgumentException- Thrown when file is null.
-
save
Description copied from interface:LoadableConfigurationSaves this configuration to a writer.- Specified by:
savein interfaceLoadableConfiguration- Parameters:
writer- where to save this configuration- Throws:
IOException- when the contents cannot be written for any reason.
-
load
public void load(String file) throws FileNotFoundException, IOException, InvalidConfigurationException Loads this configuration from the specified file path.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.
This method will use the
options()charsetencoding, which defaults to UTF8.- 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
public void load(File file) throws FileNotFoundException, IOException, InvalidConfigurationException Loads this configuration from the specified 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 file.
If the file cannot be loaded for any reason, an exception will be thrown.
This method will use the
options()charsetencoding, which defaults to UTF8.- 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 configuration from the specified stream.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.
If the file cannot be loaded for any reason, an exception will be thrown.
This method will use the
options()charsetencoding, which defaults to UTF8.- Parameters:
stream- Stream to load from- Throws:
IOException- Thrown when the given file cannot be read.InvalidConfigurationException- Thrown when the given file is not a valid Configuration.IllegalArgumentException- Thrown when stream is null.- See Also:
-
load
Loads this configuration 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.
If the file cannot be loaded for any reason, an exception will be thrown.
- Specified by:
loadin interfaceLoadableConfiguration- Parameters:
reader- the reader to load from- Throws:
IOException- Thrown when underlying reader throws an IOException.InvalidConfigurationException- Thrown when the reader does not represent a valid Configuration.IllegalArgumentException- Thrown when reader is null.
-
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
-
buildHeader
Compiles the header for thisFileConfigurationand returns the result.This will use the header from
options()FileConfigurationOptions.header(), respecting the rules ofFileConfigurationOptions.copyHeader()andFileConfigurationOptions.headerFormatter()if set.- Returns:
- Compiled header
-