Class FunctionReplacer

  • All Implemented Interfaces:
    UnicodeReplacer

    class FunctionReplacer
    extends java.lang.Object
    implements UnicodeReplacer
    A replacer that calls a transliterator to generate its output text. The input text to the transliterator is the output of another UnicodeReplacer object. That is, this replacer wraps another replacer with a transliterator.
    • Constructor Summary

      Constructors 
      Constructor Description
      FunctionReplacer​(Transliterator theTranslit, UnicodeReplacer theReplacer)
      Construct a replacer that takes the output of the given replacer, passes it through the given transliterator, and emits the result as output.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addReplacementSetTo​(UnicodeSet toUnionTo)
      Union the set of all characters that may output by this object into the given set.
      int replace​(Replaceable text, int start, int limit, int[] cursor)
      UnicodeReplacer API
      java.lang.String toReplacerPattern​(boolean escapeUnprintable)
      UnicodeReplacer API
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • translit

        private Transliterator translit
        The transliterator. Must not be null.
      • replacer

        private UnicodeReplacer replacer
        The replacer object. This generates text that is then processed by 'translit'. Must not be null.
    • Constructor Detail

      • FunctionReplacer

        public FunctionReplacer​(Transliterator theTranslit,
                                UnicodeReplacer theReplacer)
        Construct a replacer that takes the output of the given replacer, passes it through the given transliterator, and emits the result as output.
    • Method Detail

      • replace

        public int replace​(Replaceable text,
                           int start,
                           int limit,
                           int[] cursor)
        UnicodeReplacer API
        Specified by:
        replace in interface UnicodeReplacer
        Parameters:
        text - the text to be matched
        start - inclusive start index of text to be replaced
        limit - exclusive end index of text to be replaced; must be greater than or equal to start
        cursor - output parameter for the cursor position. Not all replacer objects will update this, but in a complete tree of replacer objects, representing the entire output side of a transliteration rule, at least one must update it.
        Returns:
        the number of 16-bit code units in the text replacing the characters at offsets start..(limit-1) in text
      • toReplacerPattern

        public java.lang.String toReplacerPattern​(boolean escapeUnprintable)
        UnicodeReplacer API
        Specified by:
        toReplacerPattern in interface UnicodeReplacer
        Parameters:
        escapeUnprintable - if true then convert unprintable character to their hex escape representations, \\uxxxx or \\Uxxxxxxxx. Unprintable characters are defined by Utility.isUnprintable().
      • addReplacementSetTo

        public void addReplacementSetTo​(UnicodeSet toUnionTo)
        Union the set of all characters that may output by this object into the given set.
        Specified by:
        addReplacementSetTo in interface UnicodeReplacer
        Parameters:
        toUnionTo - the set into which to union the output characters