Class FileConfigurationOptions

Direct Known Subclasses:
YamlConfigurationOptions

public class FileConfigurationOptions extends MemoryConfigurationOptions
Represents the various settings for controlling the input and output of a file configuration.

Synchronized with the commit on 24-November-2024.

  • Field Details

    • DEFAULT_HEADER

      public static final List<String> DEFAULT_HEADER
    • DEFAULT_PARSE_COMMENTS

      public static final boolean DEFAULT_PARSE_COMMENTS
      See Also:
  • Constructor Details

  • Method Details

    • getConfiguration

      @NotNull public @NotNull FileConfiguration getConfiguration()
      Gets the configuration that these options controls.
      Overrides:
      getConfiguration in class MemoryConfigurationOptions
      Returns:
      The configuration that these options controls.
    • setPathSeparator

      @NotNull public @NotNull FileConfigurationOptions setPathSeparator(char pathSeparator)
      Sets the char that 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:
      setPathSeparator in class MemoryConfigurationOptions
      Parameters:
      pathSeparator - The char used to separate configuration sections.
      Returns:
      These options, for chaining.
    • setCopyDefaults

      @NotNull public @NotNull FileConfigurationOptions setCopyDefaults(boolean copyDefaults)
      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 as ConfigurationSection.isSet(String).

      The default value is false.

      Overrides:
      setCopyDefaults in class MemoryConfigurationOptions
      Parameters:
      copyDefaults - true if the default values should be copied, false otherwise.
      Returns:
      These options, for chaining.
    • getHeader

      @NotNull public final @NotNull @UnmodifiableView List<String> getHeader()
      Gets the header comments that will be saved at the top of the output file configuration. If no header comments exist, an empty list will be returned.

      For the individual string entries in the list; a null entry 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 list cannot be modified. The returned list represents a snapshot of the header comments at the time the list was returned; any changes to the actual header comments will not be reflected in this list.

      Returns:
      The header comments for the file configuration controlled by this file configuration options.
    • setHeader

      @NotNull public @NotNull FileConfigurationOptions setHeader(@Nullable @Nullable List<String> header)
      Assigns the given header comments to these file configuration options. If the given list is null, an empty list will be assigned.

      For the individual string entries in the list; a null entry 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.

      Parameters:
      header - The header comments to assign to these file configuration options.
      Returns:
      These file configuration options, for chaining.
    • getFooter

      @NotNull public final @NotNull @UnmodifiableView List<String> getFooter()
      Gets the footer comments that will be saved at the top of the output file configuration. If no footer comments exist, an empty list will be returned.

      For the individual string entries in the list; a null entry represents an empty line, whereas an empty string entry represents an empty footer comment line (# and nothing else). Each entry in the list represents 1 line of footer comments.

      The list cannot be modified. The returned list represents a snapshot of the footer comments at the time the list was returned; any changes to the actual footer comments will not be reflected in this list.

      Returns:
      The footer comments for the file configuration controlled by this file configuration options.
    • setFooter

      @NotNull public @NotNull FileConfigurationOptions setFooter(@Nullable @Nullable List<String> footer)
      Assigns the given footer comments to these file configuration options. If the given list is null, an empty list will be assigned.

      For the individual string entries in the list; a null entry represents an empty line, whereas an empty string entry represents an empty footer comment line (# and nothing else). Each entry in the list represents 1 line of footer 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 footer comments will be replaced, regardless of their value(s) compared to the new footer comments.

      Parameters:
      footer - The footer comments to assign to these file configuration options.
      Returns:
      These file configuration options, for chaining.
    • getParseComments

      public final boolean getParseComments()
      Gets whether the comments (header, block, inline, and/or footer) in a file configuration should be loaded and saved.

      If this returns true, and if a default file configuration is passed to Configuration.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.

      Returns:
      true if the comments are to be parsed, false otherwise.
    • setParseComments

      @NotNull public @NotNull FileConfigurationOptions setParseComments(boolean parseComments)
      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 to Configuration.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.

      Parameters:
      parseComments - true if the comments are to be parsed, false otherwise.
      Returns:
      This file configuration options, for chaining.