Class NumericUnescaper

java.lang.Object
org.aoju.bus.core.text.translate.CharSequenceTranslator
org.aoju.bus.core.text.escape.NumericUnescaper

public class NumericUnescaper extends CharSequenceTranslator
Translate XML numeric entities of the form &#[xX]?\d+;? to the specific codepoint.

Note that the semi-colon is optional.

Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • NumericUnescaper

      public NumericUnescaper(NumericUnescaper.OPTION... options)
      Create a UnicodeUnescaper.

      The constructor takes a list of options, only one type of which is currently available (whether to allow, error or ignore the semi-colon on the end of a numeric entity to being missing).

      For example, to support numeric entities without a ';': new NumericUnescaper(NumericUnescaper.OPTION.semiColonOptional) and to throw an IllegalArgumentException when they're missing: new NumericUnescaper(NumericUnescaper.OPTION.errorIfNoSemiColon)

      Note that the default behaviour is to ignore them.

      Parameters:
      options - to apply to this unescaper
  • Method Details

    • isSet

      public boolean isSet(NumericUnescaper.OPTION option)
      Whether the passed in option is currently set.
      Parameters:
      option - to check state of
      Returns:
      whether the option is set
    • translate

      public int translate(CharSequence input, int index, Writer out) throws IOException
      Description copied from class: CharSequenceTranslator
      将一组由int索引表示的代码点转换为CharSequence, 转换成另一组代码点 必须返回所使用的代码点数量,
      Specified by:
      translate in class CharSequenceTranslator
      Parameters:
      input - 正在翻译的CharSequence
      index - int表示当前翻译点
      out - Writer将文本翻译成
      Returns:
      所使用代码点的int计数
      Throws:
      IOException - 当写入器生成IOException时抛出IOException