Package org.aoju.bus.core.text.replacer
Class ReplacerChain
java.lang.Object
org.aoju.bus.core.text.replacer.TextReplacer
org.aoju.bus.core.text.replacer.ReplacerChain
- All Implemented Interfaces:
Serializable,Iterable<TextReplacer>,Chain<TextReplacer,,ReplacerChain> Replacer<CharSequence>
字符串替换链,用于组合多个字符串替换逻辑
- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddChain(TextReplacer element) 加入责任链iterator()protected intreplace(CharSequence text, int indexes, TextBuilder builder) 抽象的字符串替换方法,通过传入原字符串和当前位置,执行替换逻辑,返回处理或替换的字符串长度部分。Methods inherited from class org.aoju.bus.core.text.replacer.TextReplacer
replaceMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
ReplacerChain
-
-
Method Details
-
iterator
- Specified by:
iteratorin interfaceIterable<TextReplacer>
-
addChain
Description copied from interface:Chain加入责任链- Specified by:
addChainin interfaceChain<TextReplacer,ReplacerChain> - Parameters:
element- 责任链新的环节元素- Returns:
- this
-
replace
Description copied from class:TextReplacer抽象的字符串替换方法,通过传入原字符串和当前位置,执行替换逻辑,返回处理或替换的字符串长度部分。- Specified by:
replacein classTextReplacer- Parameters:
text- 被处理的字符串indexes- 当前位置builder- 输出- Returns:
- 处理的原字符串长度,0表示跳过此字符
-