public final class Props extends Properties implements BasicType<String>, OptBasicType<String>
defaults| Constructor and Description |
|---|
Props()
构造
|
Props(File propertiesFile)
构造
|
Props(File propertiesFile,
Charset charset)
构造
|
Props(File propertiesFile,
String charsetName)
构造
|
Props(Properties properties)
构造,使用URL读取
|
Props(String path)
构造,使用相对于Class文件根目录的相对路径
|
Props(String path,
Charset charset)
构造,使用相对于Class文件根目录的相对路径
|
Props(String path,
Class<?> clazz)
构造,相对于classes读取文件
|
Props(String path,
Class<?> clazz,
Charset charset)
构造,相对于classes读取文件
|
Props(String path,
Class<?> clazz,
String charsetName)
构造,相对于classes读取文件
|
Props(String path,
String charsetName)
构造,使用相对于Class文件根目录的相对路径
|
Props(URL propertiesUrl)
构造,使用URL读取
|
Props(URL propertiesUrl,
Charset charset)
构造,使用URL读取
|
Props(URL propertiesUrl,
String charsetName)
构造,使用URL读取
|
| Modifier and Type | Method and Description |
|---|---|
void |
autoLoad(boolean autoReload)
在配置文件变更时自动加载
|
String |
getAndRemoveStr(String... keys)
获取并删除键值对,当指定键对应值非空时,返回并删除这个值,后边的键对应的值不再查找
|
BigDecimal |
getBigDecimal(String key)
获取BigDecimal型属性值
|
BigDecimal |
getBigDecimal(String key,
BigDecimal defaultValue)
获取BigDecimal型属性值
若获得的值为不可见字符,使用默认值
|
BigInteger |
getBigInteger(String key)
获取BigInteger型属性值
|
BigInteger |
getBigInteger(String key,
BigInteger defaultValue)
获取BigInteger型属性值
若获得的值为不可见字符,使用默认值
|
Boolean |
getBool(String key)
获取boolean型属性值
|
Boolean |
getBool(String key,
Boolean defaultValue)
获取boolean型属性值
若获得的值为不可见字符,使用默认值
|
Byte |
getByte(String key)
获取byte型属性值
|
Byte |
getByte(String key,
Byte defaultValue)
获取byte型属性值
若获得的值为不可见字符,使用默认值
|
Character |
getChar(String key)
获取char型属性值
|
Character |
getChar(String key,
Character defaultValue)
获取char型属性值
若获得的值为不可见字符,使用默认值
|
Date |
getDate(String key)
获取Date类型值
|
Date |
getDate(String key,
Date defaultValue)
获取Date类型值
|
Double |
getDouble(String key)
获取double型属性值
|
Double |
getDouble(String key,
Double defaultValue)
获取double型属性值
若获得的值为不可见字符,使用默认值
|
<E extends Enum<E>> |
getEnum(Class<E> clazz,
String key)
获得Enum类型的值
|
<E extends Enum<E>> |
getEnum(Class<E> clazz,
String key,
E defaultValue)
获得Enum类型的值
|
Float |
getFloat(String key)
获取float型属性值
|
Float |
getFloat(String key,
Float defaultValue)
获取float型属性值
若获得的值为不可见字符,使用默认值
|
Integer |
getInt(String key)
获取int型属性值
|
Integer |
getInt(String key,
Integer defaultValue)
获取int型属性值
若获得的值为不可见字符,使用默认值
|
Long |
getLong(String key)
获取long型属性值
|
Long |
getLong(String key,
Long defaultValue)
获取Long型属性值
若获得的值为不可见字符,使用默认值
|
Object |
getObj(String key)
获取Object属性值
|
Object |
getObj(String key,
Object defaultValue)
获取Object属性值
|
static Properties |
getProp(String resource)
获得Classpath下的Properties文件
|
static Properties |
getProp(String resource,
Charset charset)
获得Classpath下的Properties文件
|
static Properties |
getProp(String resource,
String charsetName)
获得Classpath下的Properties文件
|
Short |
getShort(String key)
获取short型属性值
|
Short |
getShort(String key,
Short defaultValue)
获取short型属性值
若获得的值为不可见字符,使用默认值
|
String |
getStr(String key)
获取字符串型属性值
|
String |
getStr(String key,
String defaultValue)
获取字符串型属性值
若获得的值为不可见字符,使用默认值
|
void |
load()
重新加载配置文件
|
void |
load(Resource urlResource)
初始化配置文件
|
void |
setProperty(String key,
Object value)
设置值,无给定键创建之 设置后未持久化
|
void |
store(String absolutePath)
持久化当前设置,会覆盖掉之前的设置
|
void |
store(String path,
Class<?> clazz)
存储当前设置,会覆盖掉以前的设置
|
getProperty, getProperty, list, list, load, load, loadFromXML, propertyNames, save, setProperty, store, store, storeToXML, storeToXML, stringPropertyNamesclear, clone, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keys, keySet, merge, put, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, size, toString, valuespublic Props()
public Props(String path)
path - 路径public Props(String path, String charsetName)
path - 相对或绝对路径charsetName - 字符集public Props(String path, Charset charset)
path - 相对或绝对路径charset - 字符集public Props(File propertiesFile)
propertiesFile - 配置文件对象public Props(File propertiesFile, String charsetName)
propertiesFile - 配置文件对象charsetName - 字符集public Props(File propertiesFile, Charset charset)
propertiesFile - 配置文件对象charset - 字符集public Props(String path, Class<?> clazz)
path - 相对路径clazz - 基准类public Props(String path, Class<?> clazz, String charsetName)
path - 相对路径clazz - 基准类charsetName - 字符集public Props(String path, Class<?> clazz, Charset charset)
path - 相对路径clazz - 基准类charset - 字符集public Props(URL propertiesUrl)
propertiesUrl - 属性文件路径public Props(URL propertiesUrl, String charsetName)
propertiesUrl - 属性文件路径charsetName - 字符集public Props(URL propertiesUrl, Charset charset)
propertiesUrl - 属性文件路径charset - 字符集public Props(Properties properties)
properties - 属性文件路径public static Properties getProp(String resource)
resource - 资源(相对Classpath的路径)public static Properties getProp(String resource, String charsetName)
resource - 资源(相对Classpath的路径)charsetName - 字符集public static Properties getProp(String resource, Charset charset)
resource - 资源(相对Classpath的路径)charset - 字符集public void load(Resource urlResource)
urlResource - UriResourcepublic void load()
public void autoLoad(boolean autoReload)
autoReload - 是否自动加载public Object getObj(String key, Object defaultValue)
OptBasicTypegetObj in interface OptBasicType<String>key - 属性名defaultValue - 默认值public String getStr(String key, String defaultValue)
OptBasicTypegetStr in interface OptBasicType<String>key - 属性名defaultValue - 默认值public Integer getInt(String key, Integer defaultValue)
OptBasicTypegetInt in interface OptBasicType<String>key - 属性名defaultValue - 默认值public Boolean getBool(String key, Boolean defaultValue)
OptBasicTypegetBool in interface OptBasicType<String>key - 属性名defaultValue - 默认值public Boolean getBool(String key)
BasicTypepublic Long getLong(String key, Long defaultValue)
OptBasicTypegetLong in interface OptBasicType<String>key - 属性名defaultValue - 默认值public Character getChar(String key, Character defaultValue)
OptBasicTypegetChar in interface OptBasicType<String>key - 属性名defaultValue - 默认值public Character getChar(String key)
BasicTypepublic Float getFloat(String key, Float defaultValue)
OptBasicTypegetFloat in interface OptBasicType<String>key - 属性名defaultValue - 默认值public Double getDouble(String key, Double defaultValue) throws NumberFormatException
OptBasicTypegetDouble in interface OptBasicType<String>key - 属性名defaultValue - 默认值NumberFormatExceptionpublic Double getDouble(String key) throws NumberFormatException
BasicTypegetDouble in interface BasicType<String>key - 属性名NumberFormatExceptionpublic Short getShort(String key, Short defaultValue)
OptBasicTypegetShort in interface OptBasicType<String>key - 属性名defaultValue - 默认值public Byte getByte(String key, Byte defaultValue)
OptBasicTypegetByte in interface OptBasicType<String>key - 属性名defaultValue - 默认值public BigDecimal getBigDecimal(String key, BigDecimal defaultValue)
OptBasicTypegetBigDecimal in interface OptBasicType<String>key - 属性名defaultValue - 默认值public BigDecimal getBigDecimal(String key)
BasicTypegetBigDecimal in interface BasicType<String>key - 属性名public BigInteger getBigInteger(String key, BigInteger defaultValue)
OptBasicTypegetBigInteger in interface OptBasicType<String>key - 属性名defaultValue - 默认值public BigInteger getBigInteger(String key)
BasicTypegetBigInteger in interface BasicType<String>key - 属性名public <E extends Enum<E>> E getEnum(Class<E> clazz, String key, E defaultValue)
OptBasicTypegetEnum in interface OptBasicType<String>E - 枚举类型clazz - Enum的Classkey - KEYdefaultValue - 默认值public <E extends Enum<E>> E getEnum(Class<E> clazz, String key)
BasicTypepublic Date getDate(String key, Date defaultValue)
OptBasicTypegetDate in interface OptBasicType<String>key - 属性名defaultValue - 默认值public String getAndRemoveStr(String... keys)
keys - 键列表,常用于别名public void setProperty(String key, Object value)
key - 属性键value - 属性值public void store(String absolutePath) throws InstrumentException
absolutePath - 设置文件的绝对路径InstrumentException - IO异常,可能为文件未找到Copyright © 2020. All rights reserved.