Package com.luna.common.replacer
Class ReplacerChain
java.lang.Object
com.luna.common.replacer.StrReplacer
com.luna.common.replacer.ReplacerChain
- All Implemented Interfaces:
Chain<StrReplacer,
,ReplacerChain> Replacer<CharSequence>
,Serializable
,Iterable<StrReplacer>
- Direct Known Subclasses:
XmlEscape
,XmlUnescape
字符串替换链,用于组合多个字符串替换逻辑
- Since:
- 4.1.5
- Author:
- looly
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddChain
(StrReplacer element) 加入责任链iterator()
protected int
replace
(CharSequence str, int pos, StringBuilder out) 抽象的字符串替换方法,通过传入原字符串和当前位置,执行替换逻辑,返回处理或替换的字符串长度部分。Methods inherited from class com.luna.common.replacer.StrReplacer
replace
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
ReplacerChain
构造- Parameters:
strReplacers
- 字符串替换器
-
-
Method Details
-
iterator
- Specified by:
iterator
in interfaceIterable<StrReplacer>
-
addChain
Description copied from interface:Chain
加入责任链- Specified by:
addChain
in interfaceChain<StrReplacer,
ReplacerChain> - Parameters:
element
- 责任链新的环节元素- Returns:
- this
-
replace
Description copied from class:StrReplacer
抽象的字符串替换方法,通过传入原字符串和当前位置,执行替换逻辑,返回处理或替换的字符串长度部分。- Specified by:
replace
in classStrReplacer
- Parameters:
str
- 被处理的字符串pos
- 当前位置out
- 输出- Returns:
- 处理的原字符串长度,0表示跳过此字符
-