public class YamlDocument extends Section
Modifier and Type | Method and Description |
---|---|
static YamlDocument |
create(File document)
Creates and initially loads YAML document from the given file using default settings (
GeneralSettings.DEFAULT ...). |
static YamlDocument |
create(File document,
GeneralSettings generalSettings,
LoaderSettings loaderSettings,
DumperSettings dumperSettings,
UpdaterSettings updaterSettings)
Creates and initially loads YAML document from the given file using the given settings.
|
static YamlDocument |
create(File document,
InputStream defaults)
Creates and initially loads YAML document from the given file using default settings (
GeneralSettings.DEFAULT ...). |
static YamlDocument |
create(File document,
InputStream defaults,
GeneralSettings generalSettings,
LoaderSettings loaderSettings,
DumperSettings dumperSettings,
UpdaterSettings updaterSettings)
Creates and initially loads YAML document from the given file using the given settings.
|
static YamlDocument |
create(InputStream document)
Creates and initially loads YAML document from the given stream using default settings (
GeneralSettings.DEFAULT ...). |
static YamlDocument |
create(InputStream document,
GeneralSettings generalSettings,
LoaderSettings loaderSettings,
DumperSettings dumperSettings,
UpdaterSettings updaterSettings)
Creates and initially loads YAML document from the given stream using the given settings.
|
static YamlDocument |
create(InputStream document,
InputStream defaults)
Creates and initially loads YAML document from the given file using default settings (
GeneralSettings.DEFAULT ...). |
static YamlDocument |
create(InputStream document,
InputStream defaults,
GeneralSettings generalSettings,
LoaderSettings loaderSettings,
DumperSettings dumperSettings,
UpdaterSettings updaterSettings)
Creates and initially loads YAML document from the given stream using the given settings.
|
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)
Associates new dumper settings.
|
void |
setGeneralSettings(GeneralSettings generalSettings)
Associates new general settings.
|
void |
setLoaderSettings(LoaderSettings loaderSettings)
Associates new loader settings.
|
void |
setUpdaterSettings(UpdaterSettings updaterSettings)
Associates new updater settings.
|
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, 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, 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, isFloat, isFloat, isChar, isChar, isInt, isInt, isList, isList, isLong, isLong, isNumber, isNumber, isSection, isSection, isSection, isShort, isShort, isString, isString, remove, remove, set, set, setInternal
addComment, addComments, getComments, getStoredValue, init, isIgnored, removeComments, setComments, setIgnored
public 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
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
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(DumperSettings dumperSettings)
general
settings.dumperSettings
- dumper settings to usepublic void setLoaderSettings(@NotNull LoaderSettings loaderSettings)
loaderSettings
- the new loader settingspublic void setDumperSettings(@NotNull DumperSettings dumperSettings)
dumperSettings
- the new dumper settingspublic void setGeneralSettings(@NotNull GeneralSettings generalSettings)
WARNING!
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)
updaterSettings
- the new updater settings@Nullable public YamlDocument getDefaults()
YamlDocument.create()
method.
If there are no defaults, returns null
.
getDefaults
in class Section
Section.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()
Section
public static YamlDocument create(@NotNull File document, @NotNull InputStream defaults, @NotNull GeneralSettings generalSettings, @NotNull LoaderSettings loaderSettings, @NotNull DumperSettings dumperSettings, @NotNull UpdaterSettings updaterSettings) throws IOException
The given settings will now be associated with the created document and loaded defaults. You will be able to use
save()
and reload()
.
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 and
saved.
document
- document (does not need to exist
)defaults
- defaultsgeneralSettings
- general settingsloaderSettings
- loader settingsdumperSettings
- dumper settingsupdaterSettings
- updater settingsIOException
- an IO errorpublic static YamlDocument create(@NotNull File document, @NotNull InputStream defaults) throws IOException
GeneralSettings.DEFAULT
...). The defaults will also be loaded using the default settings.
The default settings will now be associated with the created document and loaded defaults. You will be able to
use save()
and reload()
.
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 and
saved.
document
- document (does not need to exist
)defaults
- defaultsIOException
- an IO errorpublic static YamlDocument create(@NotNull InputStream document, @NotNull InputStream defaults, @NotNull GeneralSettings generalSettings, @NotNull LoaderSettings loaderSettings, @NotNull DumperSettings dumperSettings, @NotNull UpdaterSettings updaterSettings) throws IOException
The given settings will now be associated with the created document and loaded defaults. As you are not providing
a File
, you will need to provide data input/output each time you're reloading/saving.
document
- documentdefaults
- defaultsgeneralSettings
- general settingsloaderSettings
- loader settingsdumperSettings
- dumper settingsupdaterSettings
- updater settingsIOException
- an IO errorpublic static YamlDocument create(@NotNull InputStream document, @NotNull InputStream defaults) throws IOException
GeneralSettings.DEFAULT
...). The defaults will also be loaded using the default settings.
The default settings will now be associated with the created document and loaded defaults. As you are not
providing a File
, you will need to provide data input/output each time you're reloading/saving.
document
- documentdefaults
- defaultsIOException
- an IO errorpublic static YamlDocument create(@NotNull File document, @NotNull GeneralSettings generalSettings, @NotNull LoaderSettings loaderSettings, @NotNull DumperSettings dumperSettings, @NotNull UpdaterSettings updaterSettings) throws IOException
The given settings will now be associated with the created document. You will be able to use save()
and
reload()
. As you are not providing any defaults, you will need to provide them each time you're
updating.
If the given File
does not exist, the document will be empty. Unless disabled
, the file will automatically be created and
saved.
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
and provide the defaults right here.
document
- document (does not need to exist
)generalSettings
- general settingsloaderSettings
- loader settingsdumperSettings
- dumper settingsupdaterSettings
- updater settingsIOException
- an IO errorpublic static YamlDocument create(@NotNull File document) throws IOException
GeneralSettings.DEFAULT
...).
The default settings will now be associated with the created document. You will be able to use save()
and reload()
. As you are not providing any defaults, you will need to provide them each time you're
updating.
If the given File
does not exist, the document will be empty. Unless disabled
, the file will automatically be created and
saved.
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
and provide the defaults right here.
document
- document (does not need to exist
)IOException
- an IO errorpublic static YamlDocument create(@NotNull InputStream document, @NotNull GeneralSettings generalSettings, @NotNull LoaderSettings loaderSettings, @NotNull DumperSettings dumperSettings, @NotNull UpdaterSettings updaterSettings) throws IOException
The given settings will now be associated with the created document. As you are not providing a File
, you
will need to provide data input/output each time you're reloading/saving. As you are not providing any defaults,
you will need to provide them each time you're updating.
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
and provide the defaults right here.
document
- documentgeneralSettings
- general settingsloaderSettings
- loader settingsdumperSettings
- dumper settingsupdaterSettings
- updater settingsIOException
- an IO errorpublic static YamlDocument create(@NotNull InputStream document) throws IOException
GeneralSettings.DEFAULT
...).
The default settings will now be associated with the created document. As you are not providing a File
,
you will need to provide data input/output each time you're reloading/saving. As you are not providing any
defaults, you will need to provide them each time you're updating.
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
and provide the defaults right here.
document
- documentIOException
- an IO errorCopyright © 2022. All rights reserved.