Module bus.setting

Class SectionFormatter

java.lang.Object
org.miaixz.bus.setting.format.AbstractFormatter<IniSection>
org.miaixz.bus.setting.format.SectionFormatter
All Implemented Interfaces:
ElementFormatter<IniSection>

public class SectionFormatter extends AbstractFormatter<IniSection>
A formatter that parses a string value into an IniSection object.
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • SectionFormatter

      public SectionFormatter(CommentFormatter commentElementFormatter)
      Constructs a SectionFormatter with a specific comment formatter and default section delimiters ('[' and ']').
      Parameters:
      commentElementFormatter - The formatter for parsing comments.
    • SectionFormatter

      public SectionFormatter()
      Constructs a SectionFormatter with default settings.
    • SectionFormatter

      public SectionFormatter(char head, char end, CommentFormatter commentElementFormatter)
      Constructs a SectionFormatter with custom delimiters and a specific comment formatter.
      Parameters:
      head - The starting delimiter character.
      end - The ending delimiter character.
      commentElementFormatter - The formatter for parsing comments.
    • SectionFormatter

      public SectionFormatter(char head, char end)
      Constructs a SectionFormatter with custom delimiters and a default comment formatter.
      Parameters:
      head - The starting delimiter character.
      end - The ending delimiter character.
  • Method Details

    • check

      public boolean check(String value)
      Checks if the given string value is a section header.
      Parameters:
      value - The string to check.
      Returns:
      true if the string starts with the configured 'head' character.
    • format

      public IniSection format(String value, int line)
      Formats the string value into an IniSection. This method assumes that check(String) has already returned true.
      Parameters:
      value - A string value representing a section header (e.g., "[section_name]").
      line - The line number where the value originated.
      Returns:
      The parsed IniSection, which cannot be null.
      Throws:
      org.miaixz.bus.core.lang.exception.InternalException - if the section format is invalid.