java.lang.Object
org.miaixz.bus.setting.format.AbstractFormatter<IniSection>
org.miaixz.bus.setting.format.SectionFormatter
- All Implemented Interfaces:
ElementFormatter<IniSection>
A formatter that parses a string value into an
IniSection object.- Since:
- Java 17+
- Author:
- Kimi Liu
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a SectionFormatter with default settings.SectionFormatter(char head, char end) Constructs a SectionFormatter with custom delimiters and a default comment formatter.SectionFormatter(char head, char end, CommentFormatter commentElementFormatter) Constructs a SectionFormatter with custom delimiters and a specific comment formatter.SectionFormatter(CommentFormatter commentElementFormatter) Constructs a SectionFormatter with a specific comment formatter and default section delimiters ('[' and ']'). -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if the given string value is a section header.Formats the string value into anIniSection.Methods inherited from class org.miaixz.bus.setting.format.AbstractFormatter
getCommentElementFormatter, setCommentElementFormatter
-
Constructor Details
-
SectionFormatter
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
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
Checks if the given string value is a section header.- Parameters:
value- The string to check.- Returns:
trueif the string starts with the configured 'head' character.
-
format
Formats the string value into anIniSection. This method assumes thatcheck(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.
-