public class SI extends Object
| 限定符和类型 | 字段 | 说明 |
|---|---|---|
private static int |
CACHE_SIZE |
|
private static Map<String,String> |
KEY_CACHE |
|
private static int |
KEY_CACHE_SIZE |
|
private static Map<String,List<StringToken>> |
TEMPLATE_CACHE |
|
private Map<String,Object> |
valueMap |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
String |
$(String source) |
Interpolating for strings.
执行插值程序,解析字符串 |
String |
$(StringBuffer source) |
Interpolating for strings.
执行插值程序,解析字符串 |
SI |
add(Tuple... tuples) |
|
SI |
add(Object... kvs) |
Add key-value pairs to this SI object.
|
SI |
add(Map<String,Object> valueMap) |
|
SI |
del(String... keys) |
|
SI |
fill(Object... kvs) |
Fill key-value pairs to this SI object.
|
private List<StringToken> |
getTokens(String source) |
|
Map<String,Object> |
getValueMap() |
|
static SI |
init(Object... kvs) |
Instantiate an SI object by key-value pairs, and key must be end with " ->" or " >>>" or " >>",
and key will be removed leading and trailing whitespace.
|
static SI |
load(Object... kvs) |
Instantiate an SI object by key-value pairs, and key must be end with " ->" or " >>>" or " >>".
|
static SI |
of(Tuple... tuples) |
|
static SI |
of(Object... kvs) |
Instantiate an SI object by key-value pairs.
|
static SI |
of(Map<String,Object> map) |
|
SI |
set(Tuple... tuples) |
|
SI |
set(Object... kvs) |
Reset this SI object with key-value pairs.
|
SI |
set(Map<String,Object> valueMap) |
|
private static Map<String,Object> |
toMap(boolean withSuffix,
boolean needTrim,
Object... kvs) |
|
String |
toString() |
|
private void |
tuplesPutToMap(Tuple... tuples) |
|
private static void |
verifyPairWithStringKey(Object... kvs) |
private static final Map<String,List<StringToken>> TEMPLATE_CACHE
private static final int CACHE_SIZE
private static final int KEY_CACHE_SIZE
public static SI of(Object... kvs)
kvs - key-value pairsRuntimeException - if the kvs length not be even.NullPointerException - if the key is null.ClassCastException - if the key is not String.UnexpectedParameterException - if the key is not end with " ->" or " >>>" or " >>".public static SI init(Object... kvs)
String infoTemplate = "ip: ${ip}---port: ${port}---db: ${db}---otherInfo: ${other_info}";
SI si = SI.init(" ip ->", "127.0.0.1",
" db ->", "testdb",
" port ->", 3306,
" dbType ->", "mysql",
" other_info ->", Tuple.of("isCluster", true),
"description ->", new Object());
String dbInfo = si.$(infoTemplate);
kvs - key-value pairsRuntimeException - if the kvs length not be even.NullPointerException - if the key is null.ClassCastException - if the key is not String.UnexpectedParameterException - if the key is not end with " ->" or " >>>" or " >>".public static SI load(Object... kvs)
SI si = SI.load("ip ->", "127.0.0.1",
"port ->", 3306,
"db ->", "testdb",
"dbType ->", "mysql",
"other_info ->", Tuple.of("isCluster", true),
"description ->", new Object());
String dbInfo = si.$("ip: ${ip}---port: ${port}---db: ${db}---otherInfo: ${other_info}");
kvs - key-value pairsRuntimeException - if the kvs length not be even.NullPointerException - if the key is null.ClassCastException - if the key is not String.UnexpectedParameterException - if the key is not end with " ->" or " >>>" or " >>".public SI add(Object... kvs)
kvs - key-value pairsRuntimeException - if the kvs length not be even.NullPointerException - if the key is null.ClassCastException - if the key is not String.public SI fill(Object... kvs)
String infoTemplate = "ip: ${ip}---port: ${port}---db: ${db}---otherInfo: ${other_info}";
SI si = SI.of();
si.fill(" ip ->", "127.0.0.1",
" db ->", "testdb",
" port ->", 3306,
" dbType ->", "mysql",
" other_info ->", Tuple.of("isCluster", true),
"description ->", new Object());
String dbInfo = si.$(infoTemplate);
kvs - key-value pairsRuntimeException - if the kvs length not be even.NullPointerException - if the key is null.ClassCastException - if the key is not String.UnexpectedParameterException - if the key is not end with " ->" or " >>>" or " >>".public SI set(Object... kvs)
kvs - key-value pairsRuntimeException - if the kvs length not be even.NullPointerException - if the key is null.ClassCastException - if the key is not String.private void tuplesPutToMap(Tuple... tuples)
public String $(String source)
source - source stringprivate List<StringToken> getTokens(String source)
public String $(StringBuffer source)
source - source stringprivate static void verifyPairWithStringKey(Object... kvs)
Copyright © 2021. All rights reserved.