Module bus.setting

Class PropertyFormatter

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

public class PropertyFormatter extends AbstractFormatter<IniProperty>
A formatter that parses a string value into an IniProperty object (a key-value pair).
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • PropertyFormatter

      public PropertyFormatter(CommentFormatter commentElementFormatter)
      Constructs a PropertyFormatter with a specific comment formatter and default split character ('=').
      Parameters:
      commentElementFormatter - The formatter for parsing comments.
    • PropertyFormatter

      public PropertyFormatter()
      Constructs a PropertyFormatter with a default comment formatter and split character ('=').
    • PropertyFormatter

      public PropertyFormatter(char split, CommentFormatter commentElementFormatter)
      Constructs a PropertyFormatter with a specific split character and comment formatter.
      Parameters:
      split - The character separating key and value.
      commentElementFormatter - The formatter for parsing comments.
    • PropertyFormatter

      public PropertyFormatter(char split)
      Constructs a PropertyFormatter with a specific split character and a default comment formatter.
      Parameters:
      split - The character separating key and value.
  • Method Details

    • check

      public boolean check(String value)
      Checks if the given string value represents a property.
      Parameters:
      value - The string to check.
      Returns:
      true if the string contains the split character.
    • format

      public IniProperty format(String value, int line)
      Formats the string value into an IniProperty. This method assumes that check(String) has already returned true.
      Parameters:
      value - A string value in "key=value" format.
      line - The line number where the value originated.
      Returns:
      The parsed IniProperty, which cannot be null.