Class Readers

java.lang.Object
org.aoju.bus.setting.Readers

public class Readers extends Object
Setting文件加载器
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • Readers

      public Readers()
    • Readers

      public Readers(Factory formatterFactory)
    • Readers

      public Readers(GroupMap groupMap)
      构造
      Parameters:
      groupMap - GroupedMap
    • Readers

      public Readers(GroupMap groupMap, Charset charset, boolean isUseVariable)
      构造
      Parameters:
      groupMap - GroupedMap
      charset - 编码
      isUseVariable - 是否使用变量
  • Method Details

    • load

      public boolean load(org.aoju.bus.core.io.resource.Resource resource)
      加载设置文件
      Parameters:
      resource - 配置文件URL
      Returns:
      加载是否成功
    • load

      public boolean load(InputStream inputStream) throws IOException
      加载设置文件 此方法不会关闭流对象
      Parameters:
      inputStream - 文件流
      Returns:
      加载成功与否
      Throws:
      IOException - IO异常
    • setVarRegex

      public void setVarRegex(String regex)
      设置变量的正则 正则只能有一个group表示变量本身,剩余为字符 例如 \$\{(name)\}表示${name}变量名为name的一个变量表示
      Parameters:
      regex - 正则
    • store

      public void store(String absolutePath)
      持久化当前设置,会覆盖掉之前的设置 持久化会不会保留之前的分组
      Parameters:
      absolutePath - 设置文件的绝对路径
    • store

      public void store(File file)
      持久化当前设置,会覆盖掉之前的设置 持久化会不会保留之前的分组
      Parameters:
      file - 设置文件
    • getFormatter

      protected Format getFormatter()
      get a default formatter by factory
      Returns:
      Format
    • read

      public IniSetting read(InputStream in) throws IOException
      read ini data from an inputStream
      Parameters:
      in - an ini data inputStream
      Returns:
      ini bean
      Throws:
      IOException - io exception
      See Also:
    • read

      public IniSetting read(File file) throws IOException
      read ini file to bean
      Parameters:
      file - ini file
      Returns:
      ini bean
      Throws:
      IOException - io exception
      See Also:
    • read

      public IniSetting read(Path path) throws IOException
      read ini file to bean
      Parameters:
      path - ini path(file)
      Returns:
      ini bean
      Throws:
      IOException - io exception
      See Also:
    • read

      public IniSetting read(Reader reader) throws IOException
      to buffered and read
      Parameters:
      reader - ini data reader
      Returns:
      the object
      Throws:
      IOException - io exception
    • defaultFormat

      protected IniSetting defaultFormat(Reader reader) throws IOException
      format reader to ini bean
      Parameters:
      reader - reader
      Returns:
      IniSetting bean
      Throws:
      IOException - io exception
      See Also:
    • defaultFormat

      protected IniSetting defaultFormat(Reader reader, int builderCapacity) throws IOException
      format reader to ini bean
      Parameters:
      reader - reader
      builderCapacity - StringBuilder init param
      Returns:
      IniSetting bean
      Throws:
      IOException - io exception
    • getCommentElementFormatterSupplier

      public Supplier<ElementFormatter<IniComment>> getCommentElementFormatterSupplier()
    • setCommentElementFormatterSupplier

      public void setCommentElementFormatterSupplier(Supplier<ElementFormatter<IniComment>> commentElementFormatterSupplier)
    • getSectionElementFormatterSupplier

      public Supplier<ElementFormatter<IniSection>> getSectionElementFormatterSupplier()
    • setSectionElementFormatterSupplier

      public void setSectionElementFormatterSupplier(Supplier<ElementFormatter<IniSection>> sectionElementFormatterSupplier)
    • getPropertyElementFormatterSupplier

      public Supplier<ElementFormatter<IniProperty>> getPropertyElementFormatterSupplier()
    • setPropertyElementFormatterSupplier

      public void setPropertyElementFormatterSupplier(Supplier<ElementFormatter<IniProperty>> propertyElementFormatterSupplier)