public class YamlDocument extends Section
| Modifier | Constructor and Description |
|---|---|
protected |
YamlDocument(File document,
InputStream defaults,
Settings... settings)
Creates and loads a YAML document from the given file and loads the defaults (another YAML document, later
accessible via
getDefaults()) from the defaults stream, if provided. |
protected |
YamlDocument(InputStream document,
InputStream defaults,
Settings... settings)
Creates and loads a YAML document from the given stream and loads the defaults (another YAML document, later
accessible via
getDefaults()) from the defaults stream, if provided. |
| Modifier and Type | Method and Description |
|---|---|
static YamlDocument |
create(File document,
InputStream defaults,
Settings... settings)
Creates and loads a YAML document from the given file and loads the defaults (another YAML document, later
accessible via
getDefaults()) from the defaults stream. |
static YamlDocument |
create(File document,
Settings... settings)
Creates and loads a YAML document from the given file.
|
static YamlDocument |
create(InputStream document,
InputStream defaults,
Settings... settings)
Creates and loads a YAML document from the given stream and loads the defaults (another YAML document, later
accessible via
getDefaults()) from the defaults stream. |
static YamlDocument |
create(InputStream document,
Settings... settings)
Creates and loads a YAML document from the given stream.
|
String |
dump()
|
String |
dump(DumperSettings dumperSettings)
Dumps the contents to a string using the given dumper and associated
general
settings. |
YamlDocument |
getDefaults()
Returns the defaults associated with the document, if any were given to
YamlDocument.create()
method. |
DumperSettings |
getDumperSettings()
Returns the dumper settings associated with the file.
|
File |
getFile()
Returns the file associated with this document, if any were given to
YamlDocument.create() method. |
GeneralSettings |
getGeneralSettings()
Returns the general settings associated with the file.
|
LoaderSettings |
getLoaderSettings()
Returns the loader settings associated with the file.
|
UpdaterSettings |
getUpdaterSettings()
Returns the updater settings associated with the file.
|
boolean |
isRoot()
Returns whether this section is simultaneously the root section (file).
|
boolean |
reload()
|
void |
reload(InputStream inputStream)
|
void |
reload(InputStream inputStream,
LoaderSettings loaderSettings)
Reloads the contents from the given stream using the given loader and associated
general settings. |
boolean |
save()
Saves the contents to the
associated file using the associated
dumper and general settings, in
UTF-8 charset. |
void |
save(File file)
|
void |
save(OutputStream stream,
Charset charset)
|
void |
save(OutputStreamWriter writer)
|
void |
setDumperSettings(DumperSettings dumperSettings)
Deprecated.
replaced by
setSettings(Settings...) and subject for removal |
void |
setGeneralSettings(GeneralSettings generalSettings)
Deprecated.
replaced by
setSettings(Settings...) and subject for removal |
void |
setLoaderSettings(LoaderSettings loaderSettings)
Deprecated.
replaced by
setSettings(Settings...) and subject for removal |
void |
setSettings(Settings... settings)
Sets new settings to be used by this document, overwriting the previous settings associated with this document.
|
void |
setUpdaterSettings(UpdaterSettings updaterSettings)
Deprecated.
replaced by
setSettings(Settings...) and subject for removal |
boolean |
update()
Updates the contents against the
associated defaults using the associated
updater and general settings. |
void |
update(InputStream defaults)
|
void |
update(InputStream defaults,
UpdaterSettings updaterSettings)
Updates the contents against the given defaults using the given updater and associated
general settings. |
boolean |
update(UpdaterSettings updaterSettings)
Updates the contents against the
associated defaults using the given updater and
associated general settings. |
adaptKey, clear, contains, contains, createSection, createSection, get, get, get, get, getAs, getAs, getAs, getAs, getAsOptional, getAsOptional, getBigInt, getBigInt, getBigInt, getBigInt, getBigIntList, getBigIntList, getBigIntList, getBigIntList, getBlock, getBlock, getBoolean, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getByte, getByteList, getByteList, getByteList, getByteList, getDouble, getDouble, getDouble, getDouble, getDoubleList, getDoubleList, getDoubleList, getDoubleList, getEnum, getEnum, getEnum, getEnum, getFloat, getFloat, getFloat, getFloat, getFloatList, getFloatList, getFloatList, getFloatList, getChar, getChar, getChar, getChar, getInt, getInt, getInt, getInt, getIntList, getIntList, getIntList, getIntList, getKeys, getList, getList, getList, getList, getLong, getLong, getLong, getLong, getLongList, getLongList, getLongList, getLongList, getMapList, getMapList, getMapList, getMapList, getName, getNameAsRoute, getNameAsString, getNumber, getNumber, getNumber, getNumber, getOptional, getOptional, getOptionalBigInt, getOptionalBigInt, getOptionalBigIntList, getOptionalBigIntList, getOptionalBlock, getOptionalBlock, getOptionalBoolean, getOptionalBoolean, getOptionalByte, getOptionalByte, getOptionalByteList, getOptionalByteList, getOptionalDouble, getOptionalDouble, getOptionalDoubleList, getOptionalDoubleList, getOptionalEnum, getOptionalEnum, getOptionalFloat, getOptionalFloat, getOptionalFloatList, getOptionalFloatList, getOptionalChar, getOptionalChar, getOptionalInt, getOptionalInt, getOptionalIntList, getOptionalIntList, getOptionalList, getOptionalList, getOptionalLong, getOptionalLong, getOptionalLongList, getOptionalLongList, getOptionalMapList, getOptionalMapList, getOptionalNumber, getOptionalNumber, getOptionalSection, getOptionalSection, getOptionalShort, getOptionalShort, getOptionalShortList, getOptionalShortList, getOptionalString, getOptionalString, getOptionalStringList, getOptionalStringList, getParent, getParent, getParent, getRoot, getRoute, getRouteAsString, getRouteMappedBlocks, getRouteMappedValues, getRoutes, getRoutesAsStrings, getSection, getSection, getSection, getSection, getShort, getShort, getShort, getShort, getShortList, getShortList, getShortList, getShortList, getString, getString, getString, getString, getStringList, getStringList, getStringList, getStringList, getStringRouteMappedBlocks, getStringRouteMappedValues, getSubRoute, hasDefaults, init, initEmpty, is, is, isBigInt, isBigInt, isBoolean, isBoolean, isByte, isByte, isDecimal, isDecimal, isDouble, isDouble, isEmpty, isEnum, isEnum, isFloat, isFloat, isChar, isChar, isInt, isInt, isList, isList, isLong, isLong, isNumber, isNumber, isSection, isSection, isSection, isShort, isShort, isString, isString, move, move, remove, remove, repopulate, set, set, setAlladdComment, addComments, getComments, getStoredValue, init, isIgnored, removeComments, setComments, setIgnored, setValueprotected YamlDocument(@NotNull
InputStream document,
@Nullable
InputStream defaults,
@NotNull
Settings... settings)
throws IOException
getDefaults()) from the defaults stream, if provided.
The provided settings will be stored and used by this document and the defaults. You can overwrite them using
setSettings(Settings...)). If settings of any type are not provided, their defaults (e.g.
GeneralSettings.DEFAULT) are used.
If any of the given objects is not an instance of GeneralSettings, LoaderSettings,
DumperSettings nor UpdaterSettings, an IllegalArgumentException will be thrown. If there
are multiple instances of the same settings type, the last one will take effect.
Please note that methods without an I/O parameter will not be usable. Refer to the method documentation for more information.
document - documentdefaults - defaultssettings - settingsIOException - an IO errorprotected YamlDocument(@NotNull
File document,
@Nullable
InputStream defaults,
@NotNull
Settings... settings)
throws IOException
getDefaults()) from the defaults stream, if provided.
The provided settings will be stored and used by this document and the defaults. You can overwrite them using
setSettings(Settings...)). If settings of any type are not provided, their defaults (e.g.
GeneralSettings.DEFAULT) are used.
If any of the given objects is not an instance of GeneralSettings, LoaderSettings,
DumperSettings nor UpdaterSettings, an IllegalArgumentException will be thrown. If there
are multiple instances of the same settings type, the last one will take effect.
If the given File does not exist, the document will be loaded from a copy of the defaults. If
enabled, the file will automatically be created.
document - document (does not need to exist)defaults - defaultssettings - settingsIOException - an IO errorpublic boolean reload()
throws IOException
associated file using the associated
loader and general settings.
Returns if the operation was successful - false if there is no associated file, true
otherwise.
If the file does not exist, the document will be reloaded from a copy of the defaults (or empty if there
are not any). Unless disabled, the file will
automatically be created and saved.
getFile())IOException - an IO errorpublic void reload(@NotNull
InputStream inputStream)
throws IOException
loader and
general settings.
If there is any associated file and it does not exist, unless
disabled, the file will automatically be created
and saved.
inputStream - file to reload fromIOException - an IO errorpublic void reload(@NotNull
InputStream inputStream,
@NotNull
LoaderSettings loaderSettings)
throws IOException
general settings.
If there is any associated file and it does not exist, unless
disabled, the file will automatically be created
and saved.
inputStream - file to reload fromloaderSettings - loader settings to useIOException - an IO errorpublic boolean update()
throws IOException
associated defaults using the associated
updater and general settings.
Returns if the operation was successful - false if there are no defaults, true
otherwise.
getDefaults())IOException - an IO errorpublic boolean update(@NotNull
UpdaterSettings updaterSettings)
throws IOException
associated defaults using the given updater and
associated general settings.
Returns if the operation was successful - false if there are no defaults, true
otherwise.
updaterSettings - updater settings to usegetDefaults())IOException - an IO errorpublic void update(@NotNull
InputStream defaults)
throws IOException
updater and
general settings.
Please note that this involves loading a YAML document from the given stream. If you'd like to update, but
don't want the defaults to be used in any other means, you can disable use of them via
GeneralSettings.Builder#setUseDefaults(boolean) and provide the defaults right to the
YamlDocument.create() method.
defaults - defaults to load and update againstIOException - an IO errorpublic void update(@NotNull
InputStream defaults,
@NotNull
UpdaterSettings updaterSettings)
throws IOException
general settings.
Please note that this involves loading a YAML document from the given stream. If you'd like to update, but
don't want the defaults to be used in any other means, you can disable use of them via
GeneralSettings.Builder#setUseDefaults(boolean) and provide the defaults right to the
YamlDocument.create() method.
defaults - defaults to load and update againstupdaterSettings - updater settings to useIOException - an IO errorpublic boolean save()
throws IOException
associated file using the associated
dumper and general settings, in
UTF-8 charset.
Returns if the operation was successful - false if there is no associated file, true
otherwise.
getFile())IOException - an IO errorpublic void save(@NotNull
File file)
throws IOException
dumper and
general settings, in UTF-8 charset.file - file to save toIOException - an IO errorpublic void save(@NotNull
OutputStream stream,
Charset charset)
throws IOException
dumper and
general settings, in the given charset.stream - stream to save tocharset - charset to useIOException - an IO errorpublic void save(@NotNull
OutputStreamWriter writer)
throws IOException
writer - writer to save toIOException - an IO errorpublic String dump()
public String dump(@NotNull DumperSettings dumperSettings)
general
settings.dumperSettings - dumper settings to usepublic void setSettings(@NotNull
Settings... settings)
If you are changing GeneralSettings:
GeneralSettings.getKeyFormat() is the same as the one defined by
getGeneralSettings() (settings currently in use by the document). Such attempt will result in an
IllegalArgumentException; to update the key format, recreate the document.list,
map or set suppliers will
only affect collections created from now on.GeneralSettings, LoaderSettings,
DumperSettings nor UpdaterSettings, an IllegalArgumentException will be thrown. If there
are multiple instances of the same settings type, the last one will take effect.settings - the new settings@Deprecated public void setLoaderSettings(@NotNull LoaderSettings loaderSettings)
setSettings(Settings...) and subject for removalloaderSettings - the new loader settingspublic void setDumperSettings(@NotNull
DumperSettings dumperSettings)
setSettings(Settings...) and subject for removaldumperSettings - the new dumper settingspublic void setGeneralSettings(@NotNull
GeneralSettings generalSettings)
setSettings(Settings...) and subject for removalWARNING!
IllegalArgumentException.list, map
or set was changed, already existing instances will not be changed.
Reload to take effect.generalSettings - the new general settingspublic void setUpdaterSettings(@NotNull
UpdaterSettings updaterSettings)
setSettings(Settings...) and subject for removalupdaterSettings - the new updater settings@Nullable public YamlDocument getDefaults()
YamlDocument.create()
method.
If there are no defaults, returns null.
getDefaults in class SectionSection.hasDefaults()@NotNull public GeneralSettings getGeneralSettings()
@NotNull public DumperSettings getDumperSettings()
@NotNull public UpdaterSettings getUpdaterSettings()
@NotNull public LoaderSettings getLoaderSettings()
@Nullable public File getFile()
YamlDocument.create() method.
If there are no defaults, returns null.
public boolean isRoot()
Sectionpublic static YamlDocument create(@NotNull File document, @NotNull InputStream defaults, @NotNull Settings... settings) throws IOException
getDefaults()) from the defaults stream.
The provided settings will be stored and used by this document and the defaults. You can overwrite them using
setSettings(Settings...)). If settings of any type are not provided, their defaults (e.g.
GeneralSettings.DEFAULT) are used.
If any of the given objects is not an instance of GeneralSettings, LoaderSettings,
DumperSettings nor UpdaterSettings, an IllegalArgumentException will be thrown. If there
are multiple instances of the same settings type, the last one will take effect.
If the given File does not exist, the document will be loaded from a copy of the defaults. If
enabled, the file will automatically be created.
document - document (does not need to exist)defaults - defaultssettings - settingsIOException - an IO errorpublic static YamlDocument create(@NotNull InputStream document, @NotNull InputStream defaults, @NotNull Settings... settings) throws IOException
getDefaults()) from the defaults stream.
The provided settings will be stored and used by this document and the defaults. You can overwrite them using
setSettings(Settings...)). If settings of any type are not provided, their defaults (e.g.
GeneralSettings.DEFAULT) are used.
If any of the given objects is not an instance of GeneralSettings, LoaderSettings,
DumperSettings nor UpdaterSettings, an IllegalArgumentException will be thrown. If there
are multiple instances of the same settings type, the last one will take effect.
Please note that methods without an I/O parameter will not be usable. Refer to the method documentation for more information.
document - documentdefaults - defaultssettings - settingsIOException - an IO errorpublic static YamlDocument create(@NotNull File document, @NotNull Settings... settings) throws IOException
The provided settings will be stored and used by this document and the defaults. You can overwrite them using
setSettings(Settings...)). If settings of any type are not provided, their defaults (e.g.
GeneralSettings.DEFAULT) are used.
If any of the given objects is not an instance of GeneralSettings, LoaderSettings,
DumperSettings nor UpdaterSettings, an IllegalArgumentException will be thrown. If there
are multiple instances of the same settings type, the last one will take effect.
If the given File does not exist, the document will be loaded from a copy of the defaults. If
enabled, the file will automatically be created.
document - document (does not need to exist)settings - settingsIOException - an IO errorpublic static YamlDocument create(@NotNull InputStream document, @NotNull Settings... settings) throws IOException
The provided settings will be stored and used by this document and the defaults. You can overwrite them using
setSettings(Settings...)). If settings of any type are not provided, their defaults (e.g.
GeneralSettings.DEFAULT) are used.
If any of the given objects is not an instance of GeneralSettings, LoaderSettings,
DumperSettings nor UpdaterSettings, an IllegalArgumentException will be thrown. If there
are multiple instances of the same settings type, the last one will take effect.
Please note that methods without an I/O parameter will not be usable. Refer to the method documentation for more information.
document - documentsettings - settingsIOException - an IO errorCopyright © 2024. All rights reserved.