Class StrReplacer

java.lang.Object
com.luna.common.replacer.StrReplacer
All Implemented Interfaces:
Replacer<CharSequence>, Serializable
Direct Known Subclasses:
LookupReplacer, NumericEntityUnescaper, ReplacerChain

public abstract class StrReplacer extends Object implements Replacer<CharSequence>, Serializable
抽象字符串替换类
通过实现replace方法实现局部替换逻辑
Since:
4.1.5
Author:
looly
See Also:
  • Constructor Details

    • StrReplacer

      public StrReplacer()
  • Method Details

    • replace

      protected abstract int replace(CharSequence str, int pos, StringBuilder out)
      抽象的字符串替换方法,通过传入原字符串和当前位置,执行替换逻辑,返回处理或替换的字符串长度部分。
      Parameters:
      str - 被处理的字符串
      pos - 当前位置
      out - 输出
      Returns:
      处理的原字符串长度,0表示跳过此字符
    • replace

      public CharSequence replace(CharSequence t)
      Description copied from interface: Replacer
      替换指定类型为目标类型
      Specified by:
      replace in interface Replacer<CharSequence>
      Parameters:
      t - 被替换的对象
      Returns:
      替代后的对象