Record Class Ini

java.lang.Object
java.lang.Record
com.yahoo.config.ini.Ini
Record Components:
entries - Entries of the INI file, grouped by section.

public record Ini(SortedMap<String,SortedMap<String,String>> entries) extends Record
Basic INI file parser.

Supported syntax:

  • Sections. Surrounded with '[' and ']'
  • Optional quoting of values. When quoted, the quote character '"' can be escaped with '\'
  • Comments, separate and in-line. Indicated with leading ';' or '#'

Behaviour:

  • Leading and trailing whitespace is always ignored if the value is unquoted
  • Sections are sorted in alphabetic order. The same goes for keys within a section
  • Empty string in the parsed Map holds section-less config keys
  • Duplicated keys within the same section is an error
  • Parsing discards comments
  • No limitations on section or key names
Author:
mpolden
  • Constructor Details

  • Method Details

    • write

      public void write(OutputStream output)
      Write the text representation of this to given output
    • parse

      public static Ini parse(InputStream input)
      Parse an INI configuration from given input
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • entries

      public SortedMap<String,SortedMap<String,String>> entries()
      Returns the value of the entries record component.
      Returns:
      the value of the entries record component