java.lang.Object
org.miaixz.bus.setting.Loader
Setting文件加载器
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface值编辑器,用于在加载配置文件时对值进行编辑,例如解密等 此接口用于在加载配置文件时,编辑值,例如解密等,从而加载出明文的配置值 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected IniSettingdefaultFormat(Reader reader) format reader to ini beanprotected IniSettingdefaultFormat(Reader reader, int builderCapacity) format reader to ini beanprotected Formatget a default formatter by factoryload(InputStream inputStream) 加载设置文件。load(org.miaixz.bus.core.io.resource.Resource resource) 加载设置文件read ini file to beanread(InputStream in) read ini data from an inputStreamto buffered and readread ini file to beansetAssignFlag(char assignFlag) 赋值分隔符(用于分隔键值对)voidsetCommentElementFormatterSupplier(Supplier<ElementFormatter<IniComment>> commentElementFormatterSupplier) voidsetPropertyElementFormatterSupplier(Supplier<ElementFormatter<IniProperty>> propertyElementFormatterSupplier) voidsetSectionElementFormatterSupplier(Supplier<ElementFormatter<IniSection>> sectionElementFormatterSupplier) setValueEditor(Loader.ValueEditor valueEditor) 设置值编辑器,用于在获取值后编辑返回值,例如解密等 编辑器函数接受一个参数,此参数为待编辑的值,函数返回编辑后的值 注意:此函数调用在变量替换前setVarRegex(String regex) 设置变量的正则 正则只能有一个group表示变量本身,剩余为字符 例如 \$\{(name)\}表示${name}变量名为name的一个变量表示voidstore(GroupedMap groupedMap, File file) 持久化当前设置,会覆盖掉之前的设置 持久化会不会保留之前的分组voidstore(GroupedMap groupedMap, String absolutePath) 持久化当前设置,会覆盖掉之前的设置 持久化会不会保留之前的分组
-
Constructor Details
-
Loader
public Loader() -
Loader
-
Loader
构造- Parameters:
charset- 编码isUseVariable- 是否使用变量
-
-
Method Details
-
load
public GroupedMap load(org.miaixz.bus.core.io.resource.Resource resource) throws org.miaixz.bus.core.lang.exception.NotFoundException 加载设置文件- Parameters:
resource- 配置文件URL- Returns:
- 加载是否成功
- Throws:
org.miaixz.bus.core.lang.exception.NotFoundException- 如果资源不存在,抛出此异常
-
load
加载设置文件。 此方法不会关闭流对象- Parameters:
inputStream- 文件流- Returns:
GroupedMap- Throws:
IOException- IO异常
-
store
持久化当前设置,会覆盖掉之前的设置 持久化会不会保留之前的分组- Parameters:
groupedMap- 分组mapabsolutePath- 设置文件的绝对路径
-
store
持久化当前设置,会覆盖掉之前的设置 持久化会不会保留之前的分组- Parameters:
groupedMap- 分组mapfile- 设置文件
-
setVarRegex
设置变量的正则 正则只能有一个group表示变量本身,剩余为字符 例如 \$\{(name)\}表示${name}变量名为name的一个变量表示- Parameters:
regex- 正则- Returns:
- this
-
setAssignFlag
赋值分隔符(用于分隔键值对)- Parameters:
assignFlag- 正则- Returns:
- this
-
setValueEditor
设置值编辑器,用于在获取值后编辑返回值,例如解密等 编辑器函数接受一个参数,此参数为待编辑的值,函数返回编辑后的值 注意:此函数调用在变量替换前- Parameters:
valueEditor- 编辑器函数- Returns:
- this
-
getFormatter
get a default formatter by factory- Returns:
Format
-
read
read ini data from an inputStream- Parameters:
in- an ini data inputStream- Returns:
- ini bean
- Throws:
IOException- io exception- See Also:
-
read
read ini file to bean- Parameters:
file- ini file- Returns:
- ini bean
- Throws:
IOException- io exception- See Also:
-
read
read ini file to bean- Parameters:
path- ini path(file)- Returns:
- ini bean
- Throws:
IOException- io exception- See Also:
-
read
to buffered and read- Parameters:
reader- ini data reader- Returns:
- the object
- Throws:
IOException- io exception
-
defaultFormat
format reader to ini bean- Parameters:
reader- reader- Returns:
IniSettingbean- Throws:
IOException- io exception- See Also:
-
defaultFormat
format reader to ini bean- Parameters:
reader- readerbuilderCapacity-StringBuilderinit param- Returns:
IniSettingbean- Throws:
IOException- io exception
-
getCommentElementFormatterSupplier
-
setCommentElementFormatterSupplier
public void setCommentElementFormatterSupplier(Supplier<ElementFormatter<IniComment>> commentElementFormatterSupplier) -
getSectionElementFormatterSupplier
-
setSectionElementFormatterSupplier
public void setSectionElementFormatterSupplier(Supplier<ElementFormatter<IniSection>> sectionElementFormatterSupplier) -
getPropertyElementFormatterSupplier
-
setPropertyElementFormatterSupplier
public void setPropertyElementFormatterSupplier(Supplier<ElementFormatter<IniProperty>> propertyElementFormatterSupplier)
-