Class SingleStringTemplate
java.lang.Object
org.miaixz.bus.core.text.placeholder.StringTemplate
org.miaixz.bus.core.text.placeholder.template.SingleStringTemplate
单占位符字符串模板
例如,"?", "{}", "$$$"
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.miaixz.bus.core.text.placeholder.StringTemplate
StringTemplate.AbstractBuilder<BuilderChild extends StringTemplate.AbstractBuilder<BuilderChild,TemplateChild>, TemplateChild extends StringTemplate>, StringTemplate.Feature -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String默认的占位符protected String占位符,默认为:Symbol.DELIMFields inherited from class org.miaixz.bus.core.text.placeholder.StringTemplate
defaultValue, defaultValueHandler, escape, fixedTextTotalLength, globalDefaultValueHandler, globalFeatures, placeholderSegments, segments -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSingleStringTemplate(String template, int features, String placeholder, char escape, String defaultValue, UnaryOperator<String> defaultValueHandler) -
Method Summary
Modifier and TypeMethodDescriptionstatic SingleStringTemplate.Builder创建 builder按顺序使用 迭代器元素 替换 占位符按顺序使用 数组元素 替换 占位符formatArray(Object array) 按顺序使用 原始数组元素 替换 占位符formatArray(Object[] array) 按顺序使用 数组元素 替换 占位符将 占位符位置的值 按顺序解析为 字符串列表String[]matchesToArray(String text) 将 占位符位置的值 按顺序解析为 字符串数组protected List<StringSegment> parseSegments(String template) 将 模板 解析为 SectionBuffer 列表Methods inherited from class org.miaixz.bus.core.text.placeholder.StringTemplate
addLiteralSegment, afterInit, formatBySegment, formatMissingKey, formatNullValue, formatRawByKey, formatRawBySegment, formatSequence, getDefaultValue, getFeatures, getPlaceholderSegments, getPlaceholderTexts, getPlaceholderVariableNames, getSegments, getTemplate, hasDefaultValue, isMatches, matchesByKey, matchesByKey, matchesRawByKey, matchesRawBySegment, matchesSequence, of, ofNamed, setGlobalDefaultValue, setGlobalFeatures
-
Field Details
-
DEFAULT_PLACEHOLDER
默认的占位符- See Also:
-
placeholder
占位符,默认为:Symbol.DELIM
-
-
Constructor Details
-
SingleStringTemplate
protected SingleStringTemplate(String template, int features, String placeholder, char escape, String defaultValue, UnaryOperator<String> defaultValueHandler)
-
-
Method Details
-
builder
创建 builder- Parameters:
template- 字符串模板,不能为null- Returns:
- builder实例
-
parseSegments
Description copied from class:StringTemplate将 模板 解析为 SectionBuffer 列表- Specified by:
parseSegmentsin classStringTemplate- Parameters:
template- 字符串模板- Returns:
- Segment列表
-
format
按顺序使用 数组元素 替换 占位符- Parameters:
args- 可变参数- Returns:
- 格式化字符串
-
formatArray
按顺序使用 原始数组元素 替换 占位符- Parameters:
array- 原始类型数组,例如:int[]- Returns:
- 格式化字符串
-
formatArray
按顺序使用 数组元素 替换 占位符- Parameters:
array- 数组- Returns:
- 格式化字符串
-
format
按顺序使用 迭代器元素 替换 占位符- Parameters:
iterable- iterable- Returns:
- 格式化字符串
-
matchesToArray
将 占位符位置的值 按顺序解析为 字符串数组- Parameters:
text- 待解析的字符串,一般是格式化方法的返回值- Returns:
- 参数值数组
-
matches
将 占位符位置的值 按顺序解析为 字符串列表- Parameters:
text- 待解析的字符串,一般是格式化方法的返回值- Returns:
- 参数值列表
-