Class YamlConfigurationOptions
Synchronized with the commit on 07-June-2022.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intFields inherited from class org.bspfsystems.yamlconfiguration.file.FileConfigurationOptions
DEFAULT_FOOTER, DEFAULT_HEADER, DEFAULT_PARSE_COMMENTSFields inherited from class org.bspfsystems.yamlconfiguration.configuration.ConfigurationOptions
DEFAULT_COPY_DEFAULTS, DEFAULT_PATH_SEPARATOR -
Method Summary
Modifier and TypeMethodDescriptionintGets the maximum number of code points that can be loaded in at one time.@NotNull YamlConfigurationGets the configuration that these options controls.intGets the number of spaces used to represent an indent.intGets the maximum number of aliases for collections.intgetWidth()Gets how long a line can be before it gets split.@NotNull YamlConfigurationOptionssetCodePointLimit(int codePointLimit) Sets the maximum number of code points that can be loaded in at one time.@NotNull YamlConfigurationOptionssetCopyDefaults(boolean copyDefaults) Sets if the configuration should copy values from its default configuration directly.@NotNull YamlConfigurationOptionsAssigns the given footer comments to these file configuration options.@NotNull YamlConfigurationOptionsAssigns the given header comments to these file configuration options.@NotNull YamlConfigurationOptionssetIndent(int indent) Sets the number of spaces used to represent an indent.@NotNull YamlConfigurationOptionssetMaxAliases(int maxAliases) Sets the maximum number of aliases for collections.@NotNull YamlConfigurationOptionssetParseComments(boolean parseComments) Sets whether the comments (header, block, inline, and/or footer) in a file configuration should be loaded and saved.@NotNull YamlConfigurationOptionssetPathSeparator(char pathSeparator) Sets thecharthat will be used to separate configuration sections.@NotNull YamlConfigurationOptionssetWidth(int width) Sets how long a line can be before it gets split.Methods inherited from class org.bspfsystems.yamlconfiguration.file.FileConfigurationOptions
getFooter, getHeader, getParseCommentsMethods inherited from class org.bspfsystems.yamlconfiguration.configuration.ConfigurationOptions
getCopyDefaults, getPathSeparator
-
Field Details
-
DEFAULT_INDENT
public static final int DEFAULT_INDENT- See Also:
-
DEFAULT_WIDTH
public static final int DEFAULT_WIDTH- See Also:
-
DEFAULT_MAX_ALIASES
public static final int DEFAULT_MAX_ALIASES- See Also:
-
DEFAULT_CODE_POINT_LIMIT
public static final int DEFAULT_CODE_POINT_LIMIT- See Also:
-
-
Method Details
-
getConfiguration
Gets the configuration that these options controls.- Overrides:
getConfigurationin classFileConfigurationOptions- Returns:
- The configuration that these options controls.
-
setPathSeparator
Sets thecharthat will be used to separate configuration sections.This value does not affect how the configuration is stored, only in how you access the data.
The default value is
..- Overrides:
setPathSeparatorin classFileConfigurationOptions- Parameters:
pathSeparator- Thecharused to separate configuration sections.- Returns:
- These options, for chaining.
-
setCopyDefaults
Sets if the configuration should copy values from its default configuration directly.If this is
true, all values in the default configuration will be directly copied, making it impossible to distinguish between values that were set and values that are provided by default. As a result,ConfigurationSection.contains(String)will always return the same value asConfigurationSection.isSet(String).The default value is
false.- Overrides:
setCopyDefaultsin classFileConfigurationOptions- Parameters:
copyDefaults-trueif the default values should be copied,falseotherwise.- Returns:
- These options, for chaining.
-
setHeader
@NotNull public @NotNull YamlConfigurationOptions setHeader(@Nullable @Nullable List<String> header) Assigns the given header comments to these file configuration options. If the given list isnull, an empty list will be assigned.For the individual string entries in the list; a
nullentry represents an empty line, whereas an empty string entry represents an empty header comment line (#and nothing else). Each entry in the list represents 1 line of header comments.The given list will not be directly saved; instead, a snapshot will be taken and used to create an unmodifiable copy internally. Further updates to the given list will not result in changes to the inline comments stored in these file configuration options after this method completes.
Any existing header comments will be replaced, regardless of their value(s) compared to the new header comments.
- Overrides:
setHeaderin classFileConfigurationOptions- Parameters:
header- The header comments to assign to these file configuration options.- Returns:
- These file configuration options, for chaining.
-
setParseComments
Sets whether the comments (header, block, inline, and/or footer) in a file configuration should be loaded and saved.If this is
true, and if a default file configuration is passed toConfiguration.setDefaults(Configuration), then upon saving, the default comments will be parsed from the passed default file configuration, instead of the ones provided in here.If no default is set on the configuration, or the default is not a file configuration, or that configuration has no comments, then the comments specified in the original configuration will be used.
The default value is
true.- Overrides:
setParseCommentsin classFileConfigurationOptions- Parameters:
parseComments-trueif the comments are to be parsed,falseotherwise.- Returns:
- This file configuration options, for chaining.
-
getIndent
public int getIndent()Gets the number of spaces used to represent an indent.The minimum value this may be is
2, and the maximum is9.The default value is
2.- Returns:
- The number of spaces used to represent an indent.
-
setIndent
@NotNull public @NotNull YamlConfigurationOptions setIndent(int indent) throws IllegalArgumentException Sets the number of spaces used to represent an indent.The minimum value this may be is
2, and the maximum is9.The default value is
2.- Parameters:
indent- The number of spaces used to represent an indent.- Returns:
- These YAML configuration options, for chaining.
- Throws:
IllegalArgumentException- If the given value is less than2or greater than9.
-
getWidth
public int getWidth()Gets how long a line can be before it gets split.The minimum value this may be is
8, and the maximum is1000.The default value is
80.- Returns:
- The number of characters a line can be before it gets split.
-
setWidth
Sets how long a line can be before it gets split.The minimum value this may be is
8, and the maximum is1000.The default value is
80.- Parameters:
width- The number of characters a line can be before it gets split.- Returns:
- These YAML configuration options, for chaining.
- Throws:
IllegalArgumentException- If the given value is less than8or greater than1000.
-
getMaxAliases
public int getMaxAliases()Gets the maximum number of aliases for collections.The minimum value this may be is
10, and the maximum isInteger.MAX_VALUE.The default value is
50. It is recommended to keep this value as low as possible for your use case as to prevent a Denial-of-Service known Billion Laughs Attack.- Returns:
- The maximum number of aliases for collections.
-
setMaxAliases
@NotNull public @NotNull YamlConfigurationOptions setMaxAliases(int maxAliases) throws IllegalArgumentException Sets the maximum number of aliases for collections.The minimum value this may be is
10, and the maximum isInteger.MAX_VALUE(please use this wisely).A recommended value is
50. It is recommended to keep this value as low as possible for your use case as to prevent a Denial-of-Service known Billion Laughs Attack.- Parameters:
maxAliases- The maximum number of aliases for collections.- Returns:
- These YAML configuration options, for chaining.
- Throws:
IllegalArgumentException- If the given value is less than10.
-
getCodePointLimit
public int getCodePointLimit()Gets the maximum number of code points that can be loaded in at one time.The minimum is
1kB (1024), and the maximum isInteger.MAX_VALUE(please use this wisely).A recommended value is
3 MB (1024 * 1024 * 3).- Returns:
- The maximum number of code points.
-
setCodePointLimit
@NotNull public @NotNull YamlConfigurationOptions setCodePointLimit(int codePointLimit) throws IllegalArgumentException Sets the maximum number of code points that can be loaded in at one time.The minimum is
1kB (1024), and the maximum isInteger.MAX_VALUE(please use this wisely).A recommended value is
3 MB (1024 * 1024 * 3).- Parameters:
codePointLimit- The maximum number of code points for loading.- Returns:
- These YAML configuration options, for chaining.
- Throws:
IllegalArgumentException- If the given value is less than1kB (1024).
-