@Override
    protected void handleTransliterate(Replaceable text,
                                       Position pos, boolean isIncremental) {
        int start = pos.start;
        int limit = pos.limit;
        int i, ipat;

      loop:
        while (start < limit) {
            // Loop over the forms in spec[].  Exit this loop when we
            // match one of the specs.  Exit the outer loop if a
            // partial match is detected and isIncremental is true.
            for (ipat = 0; spec[ipat] != END;) {

                // Read the header
                int prefixLen = spec[ipat++];
                int suffixLen = spec[ipat++];
                int radix     = spec[ipat++];
                int minDigits = spec[ipat++];
                int maxDigits = spec[ipat++];

                // s is a copy of start that is advanced over the
                // characters as we parse them.
                int s = start;
                boolean match = true;

                for (i=0; i<prefixLen; ++i) {
                    if (s >= limit) {
                        if (i > 0) {
                            // We've already matched a character.  This is
                            // a partial match, so we return if in
                            // incremental mode.  In non-incremental mode,
                            // go to the next spec.
                            if (isIncremental) {
                                break loop;
                            }
                            match = false;
                            break;
                        }
                    }
                    char c = text.charAt(s++);
                    if (c != spec[ipat + i]) {
                        match = false;
                        break;
                    }
                }

                if (match) {
                    int u = 0;
                    int digitCount = 0;
                    for (;;) {
                        if (s >= limit) {
                            // Check for partial match in incremental mode.
                            if (s > start && isIncremental) {
                                break loop;
                            }
                            break;
                        }
                        int ch = text.char32At(s);
                        int digit = UCharacter.digit(ch, radix);
                        if (digit < 0) {
                            break;
                        }
                        s += UTF16.getCharCount(ch);
                        u = (u * radix) + digit;
                        if (++digitCount == maxDigits) {
                            break;
                        }
                    }

                    match = (digitCount >= minDigits);

                    if (match) {
                        for (i=0; i<suffixLen; ++i) {
                            if (s >= limit) {
                                // Check for partial match in incremental mode.
                                if (s > start && isIncremental) {
                                    break loop;
                                }
                                match = false;
                                break;
                            }
                            char c = text.charAt(s++);
                            if (c != spec[ipat + prefixLen + i]) {
                                match = false;
                                break;
                            }
                        }

                        if (match) {
                            // At this point, we have a match
                            String str = UTF16.valueOf(u);
                            text.replace(start, s, str);
                            limit -= s - start - str.length();
                            // The following break statement leaves the
                            // loop that is traversing the forms in
                            // spec[].  We then parse the next input
                            // character.
                            break;
                        }
                    }
                }

                ipat += prefixLen + suffixLen;
            }

            if (start < limit) {
                start += UTF16.getCharCount(text.char32At(start));
            }
        }

        pos.contextLimit += limit - pos.limit;
        pos.limit = limit;
        pos.start = start;
    }
@ Override protected void handleTransliterate ( Replaceable text , Position pos , boolean isIncremental ) { int start = pos . start ; int limit = pos . limit ; int i , ipat ; loop : while ( start < limit ) { for ( ipat = 0 ; spec [ ipat ] != END ; ) { int prefixLen = spec [ ipat ++ ] ; int suffixLen = spec [ ipat ++ ] ; int radix = spec [ ipat ++ ] ; int minDigits = spec [ ipat ++ ] ; int maxDigits = spec [ ipat ++ ] ; int s = start ; boolean match = true ; for ( i = 0 ; i < prefixLen ; ++ i ) { if ( s >= limit ) { if ( i > 0 ) { if ( isIncremental ) { break loop ; } match = false ; break ; } } char c = text . charAt ( s ++ ) ; if ( c != spec [ ipat + i ] ) { match = false ; break ; } } if ( match ) { int u = 0 ; int digitCount = 0 ; for ( ; ; ) { if ( s >= limit ) { if ( s > start && isIncremental ) { break loop ; } break ; } int ch = text . char32At ( s ) ; int digit = UCharacter . digit ( ch , radix ) ; if ( digit < 0 ) { break ; } s += UTF16 . getCharCount ( ch ) ; u = ( u * radix ) + digit ; if ( ++ digitCount == maxDigits ) { break ; } } match = ( digitCount >= minDigits ) ; if ( match ) { for ( i = 0 ; i < suffixLen ; ++ i ) { if ( s >= limit ) { if ( s > start && isIncremental ) { break loop ; } match = false ; break ; } char c = text . charAt ( s ++ ) ; if ( c != spec [ ipat + prefixLen + i ] ) { match = false ; break ; } } if ( match ) { String str = UTF16 . valueOf ( u ) ; text . replace ( start , s , str ) ; limit -= s - start - str . length ( ) ; break ; } } } ipat += prefixLen + suffixLen ; } if ( start < limit ) { start += UTF16 . getCharCount ( text . char32At ( start ) ) ; } } pos . contextLimit += limit - pos . limit ; pos . limit = limit ; pos . start = start ; }
Implements {@link Transliterator#handleTransliterate}.