com.aliyun.oss.common.utils

## 类 IniEditor.Section

- java.lang.Object
- - com.aliyun.oss.common.utils.IniEditor.Section

- 封闭类:
    IniEditor

      public static class IniEditor.Section
      extends Object

  Loads, edits and saves a section of an INI-style configuration file. This class does actually belong to the internals of `IniEditor` and should rarely ever be used directly. It's exposed because it can be useful for plain, section-less configuration files (Java-style properties, for example).

- - ### 字段概要

    字段
    限定符和类型 | 字段和说明
    --- | ---
    `static String` | `DEFAULT_OPTION_FORMAT`
    `static char` | `HEADER_END`
    `static char` | `HEADER_START`

  - ### 构造器概要

    构造器
    构造器和说明
    `IniEditor.Section(String name)` Constructs a new section.
    `IniEditor.Section(String name, boolean isCaseSensitive)` Constructs a new section, specifying case-sensitivity.
    `IniEditor.Section(String name, char[] delims)` Constructs a new section, defining comment delimiters.
    `IniEditor.Section(String name, char[] delims, boolean isCaseSensitive)` Constructs a new section, defining comment delimiters.

  - ### 方法概要

    方法
    限定符和类型 | 方法和说明
    --- | ---
    `void` | `addBlankLine()` Adds a blank line to the end of this section.
    `void` | `addComment(String comment)` Adds a comment line to the end of this section.
    `void` | `addComment(String comment, char delim)` Adds a comment line to the end of this section.
    `String` | `get(String option)` Returns an option's value.
    `boolean` | `hasOption(String name)` Checks whether a given option exists in this section.
    `void` | `load(BufferedReader reader)` Loads options from a reader into this instance.
    `List<String>` | `optionNames()` Returns the names of all options in this section.
    `boolean` | `remove(String option)` Removes an option if it exists.
    `void` | `save(PrintWriter writer)` Prints this section to a print writer.
    `void` | `set(String option, String value)` Sets an option's value and creates the option if it doesn't exist.
    `void` | `set(String option, String value, char delim)` Sets an option's value and creates the option if it doesn't exist.
    `void` | `setOptionFormat(com.aliyun.oss.common.utils.IniEditor.OptionFormat format)` Sets the option format for this section.
    `void` | `setOptionFormatString(String formatString)` Sets the option format for this section to the given string.

    - ### 从类继承的方法 java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 字段详细资料

    - #### DEFAULT_OPTION_FORMAT

          public static final String DEFAULT_OPTION_FORMAT

      另请参阅:
        常量字段值

    - #### HEADER_START

          public static final char HEADER_START

      另请参阅:
        常量字段值

    - #### HEADER_END

          public static final char HEADER_END

      另请参阅:
        常量字段值

  - ### 构造器详细资料

    - #### IniEditor.Section

          public IniEditor.Section(String name)

      Constructs a new section.
      参数:
        `name` - the section's name
      抛出:
        `IllegalArgumentException` - the section's name is illegal

    - #### IniEditor.Section

          public IniEditor.Section(String name,
                           boolean isCaseSensitive)

      Constructs a new section, specifying case-sensitivity.
      参数:
        `name` - the section's name
        `isCaseSensitive` - option names are case-sensitive if this is true
      抛出:
        `IllegalArgumentException` - the section's name is illegal

    - #### IniEditor.Section

          public IniEditor.Section(String name,
                           char[] delims)

      Constructs a new section, defining comment delimiters.
      参数:
        `name` - the section's name
        `delims` - an array of characters to be recognized as starters of comment lines; the first of them will be used for newly created comments
      抛出:
        `IllegalArgumentException` - the section's name is illegal

    - #### IniEditor.Section

          public IniEditor.Section(String name,
                           char[] delims,
                           boolean isCaseSensitive)

      Constructs a new section, defining comment delimiters.
      参数:
        `name` - the section's name
        `delims` - an array of characters to be recognized as starters of comment lines; the first of them will be used for newly created comments
        `isCaseSensitive` - option names are case-sensitive if this is true
      抛出:
        `IllegalArgumentException` - the section's name is illegal

  - ### 方法详细资料

    - #### setOptionFormatString

          public void setOptionFormatString(String formatString)

      Sets the option format for this section to the given string. Options in this section will be rendered according to the given format string. The string must contain `%s` three times, these will be replaced with the option name, the option separator and the option value in this order. Literal percentage signs must be escaped by preceding them with another percentage sign (i.e., `%%` corresponds to one percentage sign). The default format string is `"%s %s %s"`. Option formats may look like format strings as supported by Java 1.5, but the string is in fact parsed in a custom fashion to guarantee backwards compatibility. So don't try clever stuff like using format conversion types other than `%s`.
      参数:
        `formatString` - a format string, containing `%s` exactly three times
      抛出:
        `IllegalArgumentException` - if the format string is illegal

    - #### setOptionFormat

          public void setOptionFormat(com.aliyun.oss.common.utils.IniEditor.OptionFormat format)

      Sets the option format for this section. Options will be rendered according to the given format when printed.
      参数:
        `format` - a compiled option format

    - #### optionNames

          public List<String> optionNames()

      Returns the names of all options in this section.
      返回:
        list of names of this section's options in original/insertion order

    - #### hasOption

          public boolean hasOption(String name)

      Checks whether a given option exists in this section.
      参数:
        `name` - the name of the option to test for
      返回:
        true if the option exists in this section

    - #### get

          public String get(String option)

      Returns an option's value.
      参数:
        `option` - the name of the option
      返回:
        the requested option's value or `null` if no option with the specified name exists

    - #### set

          public void set(String option,
                 String value)

      Sets an option's value and creates the option if it doesn't exist.
      参数:
        `option` - the option's name
        `value` - the option's value
      抛出:
        `IllegalArgumentException` - the option name is illegal, ie contains a '=' character or consists only of white space

    - #### set

          public void set(String option,
                 String value,
                 char delim)

      Sets an option's value and creates the option if it doesn't exist.
      参数:
        `option` - the option's name
        `value` - the option's value
        `delim` - the delimiter between name and value for this option
      抛出:
        `IllegalArgumentException` - the option name is illegal, ie contains a '=' character or consists only of white space

    - #### remove

          public boolean remove(String option)

      Removes an option if it exists.
      参数:
        `option` - the name of the option
      返回:
        `true` if the option was actually removed

    - #### addComment

          public void addComment(String comment)

      Adds a comment line to the end of this section. A comment spanning several lines (ie with line breaks) will be split up, one comment line for each line.
      参数:
        `comment` - the comment

    - #### addComment

          public void addComment(String comment,
                        char delim)

      Adds a comment line to the end of this section. A comment spanning several lines (ie with line breaks) will be split up, one comment line for each line.
      参数:
        `comment` - the comment
        `delim` - the delimiter used to mark the start of this comment

    - #### addBlankLine

          public void addBlankLine()

      Adds a blank line to the end of this section.

    - #### load

          public void load(BufferedReader reader)
                    throws IOException

      Loads options from a reader into this instance. Will read from the stream until it hits a section header, ie a '[' character, and resets the reader to point to this character.
      参数:
        `reader` - where to read from
      抛出:
        `IOException` - at an I/O problem

    - #### save

          public void save(PrintWriter writer)
                    throws IOException

      Prints this section to a print writer.
      参数:
        `writer` - where to write
      抛出:
        `IOException` - at an I/O problem

Copyright © 2020. All Rights Reserved.