public class SI extends Object
| 限定符和类型 | 类 | 说明 |
|---|---|---|
(专用程序包) static class |
SI.LRUCache<K,V> |
Simple LRU Cache, this implementation is not synchronized and not thread-safe.
|
| 限定符和类型 | 字段 | 说明 |
|---|---|---|
private static int |
CACHE_SIZE |
|
private static Map<String,String> |
KEY_CACHE |
|
private static int |
KEY_CACHE_SIZE |
|
private static String |
MSG_UNEXPECTED_PARAM |
|
private static Map<String,List<StringToken>> |
TEMPLATE_CACHE |
|
private Map<String,Object> |
valueMap |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
String |
$(CharSequence source) |
Interpolating for strings.
执行插值程序,解析字符串 |
String |
$(CharSequence source,
boolean enableNestedParse) |
Interpolating for strings.
执行插值程序,解析字符串 |
static String |
$(CharSequence source,
Object... arguments) |
Interpolating for strings.
字符串插值 |
SI |
add(Tuple... tuples) |
|
SI |
add(Object... kvs) |
Add key-value pairs to this SI object.
|
SI |
add(Map<String,?> valueMap) |
|
private void |
checkCyclic(String property,
List<String> propertiesStack,
List<String> sourceList) |
Check for circular references when inspecting string interpolation.
|
SI |
del(String... keys) |
|
SI |
fill(Object... kvs) |
Fill key-value pairs to this SI object.
|
private static 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,?> map) |
|
SI |
set(Tuple... tuples) |
|
SI |
set(Object... kvs) |
Reset this SI object with key-value pairs.
|
SI |
set(Map<String,?> valueMap) |
|
private void |
splitTokenAndCheckCyclic(List<StringToken> tokens,
List<String> propertiesStack,
List<String> sourceList) |
分割token及检查是否循环引用
|
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 int CACHE_SIZE
private static final int KEY_CACHE_SIZE
private static final Map<String,List<StringToken>> TEMPLATE_CACHE
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 $(CharSequence source)
source - source stringpublic String $(CharSequence source, boolean enableNestedParse)
source - source stringenableNestedParse - enable nested parsing or notCircularReferencesException - when the circular reference occursprivate void splitTokenAndCheckCyclic(List<StringToken> tokens, List<String> propertiesStack, List<String> sourceList)
tokens - 字符串分割的tokenpropertiesStack - 属性栈sourceList - 原始字符串多次插值后的数组private void checkCyclic(String property, List<String> propertiesStack, List<String> sourceList)
property - 当前检查的属性propertiesStack - 属性栈sourceList - 原始字符串多次插值后的数组public static String $(CharSequence source, Object... arguments)
source - source stringarguments - argumentsprivate static List<StringToken> getTokens(String source)
private static void verifyPairWithStringKey(Object... kvs)
Copyright © 2023 io-fairy. All rights reserved.