Class FileConfiguration
- All Implemented Interfaces:
Configuration
,ConfigurationSection
- Direct Known Subclasses:
YamlConfiguration
public abstract class FileConfiguration extends MemoryConfiguration
Configuration
-
Field Summary
Fields Modifier and Type Field Description static boolean
SYSTEM_UTF
Deprecated.temporary compatibility measurestatic boolean
UTF_BIG
Deprecated.temporary compatibility measurestatic boolean
UTF8_OVERRIDE
Deprecated.temporary compatibility measure -
Constructor Summary
Constructors Constructor Description FileConfiguration()
Creates an emptyFileConfiguration
with no default values.FileConfiguration(Configuration defaults)
Creates an emptyFileConfiguration
using the specifiedConfiguration
as a source for all default values. -
Method Summary
Modifier and Type Method Description protected abstract java.lang.String
buildHeader()
Compiles the header for thisFileConfiguration
and returns the result.void
load(java.io.File file)
Loads thisFileConfiguration
from the specified location.void
load(java.io.InputStream stream)
Deprecated.This does not consider encodingvoid
load(java.io.Reader reader)
Loads thisFileConfiguration
from the specified reader.void
load(java.lang.String file)
Loads thisFileConfiguration
from the specified location.abstract void
loadFromString(java.lang.String contents)
Loads thisFileConfiguration
from the specified string, as opposed to from file.FileConfigurationOptions
options()
Gets theConfigurationOptions
for thisConfiguration
.void
save(java.io.File file)
Saves thisFileConfiguration
to the specified location.void
save(java.lang.String file)
Saves thisFileConfiguration
to the specified location.abstract java.lang.String
saveToString()
Saves thisFileConfiguration
to a string, and returns it.Methods inherited from class org.bukkit.configuration.MemoryConfiguration
addDefault, addDefaults, addDefaults, getDefaults, getParent, setDefaults
Methods inherited from class org.bukkit.configuration.MemorySection
contains, createPath, createPath, createSection, createSection, get, get, getBoolean, getBoolean, getBooleanList, getByteList, getCharacterList, getColor, getColor, getConfigurationSection, getCurrentPath, getDefault, getDefaultSection, getDouble, getDouble, getDoubleList, getFloatList, getInt, getInt, getIntegerList, getItemStack, getItemStack, getKeys, getList, getList, getLong, getLong, getLongList, getMapList, getName, getOfflinePlayer, getOfflinePlayer, getRoot, getShortList, getString, getString, getStringList, getValues, getVector, getVector, isBoolean, isColor, isConfigurationSection, isDouble, isInt, isItemStack, isList, isLong, isOfflinePlayer, isPrimitiveWrapper, isSet, isString, isVector, mapChildrenKeys, mapChildrenValues, set, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.bukkit.configuration.ConfigurationSection
contains, createSection, createSection, get, get, getBoolean, getBoolean, getBooleanList, getByteList, getCharacterList, getColor, getColor, getConfigurationSection, getCurrentPath, getDefaultSection, getDouble, getDouble, getDoubleList, getFloatList, getInt, getInt, getIntegerList, getItemStack, getItemStack, getKeys, getList, getList, getLong, getLong, getLongList, getMapList, getName, getOfflinePlayer, getOfflinePlayer, getRoot, getShortList, getString, getString, getStringList, getValues, getVector, getVector, isBoolean, isColor, isConfigurationSection, isDouble, isInt, isItemStack, isList, isLong, isOfflinePlayer, isSet, isString, isVector, set
-
Field Details
-
UTF8_OVERRIDE
@Deprecated public static final boolean UTF8_OVERRIDEDeprecated.temporary compatibility measureThis value specified that the system default encoding should be completely ignored, as it cannot handle the ASCII character set, or it is a strict-subset of UTF8 already (plain ASCII). -
UTF_BIG
@Deprecated public static final boolean UTF_BIGDeprecated.temporary compatibility measureThis value specifies if the system default encoding is unicode, but cannot parse standard ASCII. -
SYSTEM_UTF
@Deprecated public static final boolean SYSTEM_UTFDeprecated.temporary compatibility measureThis value specifies if the system supports unicode.
-
-
Constructor Details
-
FileConfiguration
public FileConfiguration()Creates an emptyFileConfiguration
with no default values. -
FileConfiguration
Creates an emptyFileConfiguration
using the specifiedConfiguration
as a source for all default values.- Parameters:
defaults
- Default value provider
-
-
Method Details
-
save
public void save(java.io.File file) throws java.io.IOExceptionSaves thisFileConfiguration
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:
java.io.IOException
- Thrown when the given file cannot be written to for any reason.java.lang.IllegalArgumentException
- Thrown when file is null.
-
save
public void save(java.lang.String file) throws java.io.IOExceptionSaves thisFileConfiguration
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:
java.io.IOException
- Thrown when the given file cannot be written to for any reason.java.lang.IllegalArgumentException
- Thrown when file is null.
-
saveToString
public abstract java.lang.String saveToString()Saves thisFileConfiguration
to a string, and returns it.- Returns:
- String containing this configuration.
-
load
public void load(java.io.File file) throws java.io.FileNotFoundException, java.io.IOException, InvalidConfigurationExceptionLoads thisFileConfiguration
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.
This will attempt to use the
Charset.defaultCharset()
for files, unlessUTF8_OVERRIDE
but notUTF_BIG
is specified.- Parameters:
file
- File to load from.- Throws:
java.io.FileNotFoundException
- Thrown when the given file cannot be opened.java.io.IOException
- Thrown when the given file cannot be read.InvalidConfigurationException
- Thrown when the given file is not a valid Configuration.java.lang.IllegalArgumentException
- Thrown when file is null.
-
load
@Deprecated public void load(java.io.InputStream stream) throws java.io.IOException, InvalidConfigurationExceptionDeprecated.This does not consider encodingLoads thisFileConfiguration
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.
This will attempt to use the
Charset.defaultCharset()
, unlessUTF8_OVERRIDE
orUTF_BIG
is specified.- Parameters:
stream
- Stream to load from- Throws:
java.io.IOException
- Thrown when the given file cannot be read.InvalidConfigurationException
- Thrown when the given file is not a valid Configuration.java.lang.IllegalArgumentException
- Thrown when stream is null.- See Also:
load(Reader)
-
load
Loads thisFileConfiguration
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:
java.io.IOException
- thrown when underlying reader throws an IOExceptionInvalidConfigurationException
- thrown when the reader does not represent a valid Configurationjava.lang.IllegalArgumentException
- thrown when reader is null
-
load
public void load(java.lang.String file) throws java.io.FileNotFoundException, java.io.IOException, InvalidConfigurationExceptionLoads thisFileConfiguration
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:
java.io.FileNotFoundException
- Thrown when the given file cannot be opened.java.io.IOException
- Thrown when the given file cannot be read.InvalidConfigurationException
- Thrown when the given file is not a valid Configuration.java.lang.IllegalArgumentException
- Thrown when file is null.
-
loadFromString
public abstract void loadFromString(java.lang.String contents) throws InvalidConfigurationExceptionLoads thisFileConfiguration
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.java.lang.IllegalArgumentException
- Thrown if contents is null.
-
buildHeader
protected abstract java.lang.String buildHeader()Compiles the header for thisFileConfiguration
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:Configuration
Gets theConfigurationOptions
for thisConfiguration
.All setters through this method are chainable.
- Specified by:
options
in interfaceConfiguration
- Overrides:
options
in classMemoryConfiguration
- Returns:
- Options for this configuration
-