001: /*
002: * Copyright (C) 1996-2004, International Business Machines Corporation and
003: * others. All Rights Reserved.
004: *
005: */
006: package com.ibm.icu.text;
007:
008: //import java.util.*;
009:
010: abstract class TransformTransliterator {
011: // Currently unused
012: }
013:
014: ///**
015: // * An abstract class for transliterators based on a transform
016: // * operation. To create a transliterator that implements a
017: // * transformation, create a subclass of this class and implement the
018: // * abstract <code>transform()</code> and <code>hasTransform()</code>
019: // * methods.
020: // * @author Alan Liu
021: // */
022: //abstract class TransformTransliterator extends Transliterator {
023: //
024: // /**
025: // * Constructs a transliterator. For use by subclasses.
026: // */
027: // protected TransformTransliterator(String id, UnicodeFilter f) {
028: // super(id, f);
029: // }
030: //
031: // /**
032: // * Implements {@link Transliterator#handleTransliterate}.
033: // */
034: // protected void handleTransliterate(Replaceable text,
035: // Position offsets, boolean incremental) {
036: //
037: // int start;
038: // for (start = offsets.start; start < offsets.limit; ++start) {
039: // // Scan for the first character that is != its transform.
040: // // If there are none, we fall out without doing anything.
041: // char c = text.charAt(start);
042: // if (hasTransform(c)) {
043: // // There is a transforming character at start. Break
044: // // up the remaining string, from start to
045: // // offsets.limit, into segments of unfiltered and
046: // // filtered characters. Only transform the unfiltered
047: // // characters. As always, minimize the number of
048: // // calls to Replaceable.replace().
049: //
050: // int len = offsets.limit - start;
051: // // assert(len >= 1);
052: //
053: // char[] buf = new char[len];
054: // text.getChars(start, offsets.limit, buf, 0);
055: //
056: // int segStart = 0;
057: // int segLimit;
058: // UnicodeFilter filt = getFilter();
059: //
060: // // lenDelta is the accumulated length difference for
061: // // all transformed segments. It is new length - old
062: // // length.
063: // int lenDelta = 0;
064: //
065: // // Set segStart, segLimit to the unfiltered segment
066: // // starting with start. If the filter is null, then
067: // // segStart/Limit will be set to the whole string,
068: // // that is, 0/len.
069: // do {
070: // // Set segLimit to the first filtered char at or
071: // // after segStart.
072: // segLimit = len;
073: // if (filt != null) {
074: // segLimit = segStart;
075: // while (segLimit < len && filt.contains(buf[segLimit])) {
076: // ++segLimit;
077: // }
078: // }
079: //
080: // // Transform the unfiltered chars between segStart
081: // // and segLimit.
082: // int segLen = segLimit - segStart;
083: // if (segLen != 0) {
084: // String newStr = transform(
085: // new String(buf, segStart, segLen));
086: // text.replace(start, start + segLen, newStr);
087: // start += newStr.length();
088: // lenDelta += newStr.length() - segLen;
089: // }
090: //
091: // // Set segStart to the first unfiltered char at or
092: // // after segLimit.
093: // segStart = segLimit;
094: // if (filt != null) {
095: // while (segStart < len && !filt.contains(buf[segStart])) {
096: // ++segStart;
097: // }
098: // }
099: // start += segStart - segLimit;
100: //
101: // } while (segStart < len);
102: //
103: // offsets.limit += lenDelta;
104: // offsets.contextLimit += lenDelta;
105: // offsets.start = offsets.limit;
106: // return;
107: // }
108: // }
109: // // assert(start == offsets.limit);
110: // offsets.start = start;
111: // }
112: //
113: // /**
114: // * Subclasses must implement this method to determine whether a
115: // * given character has a transform that is not equal to itself.
116: // * This is approximately equivalent to <code>c !=
117: // * transform(String.valueOf(c))</code>, where
118: // * <code>String.valueOf(c)</code> returns a String containing the
119: // * single character (not integer) <code>c</code>. Subclasses that
120: // * transform all their input can simply return <code>true</code>.
121: // */
122: // protected abstract boolean hasTransform(int c);
123: //
124: // /**
125: // * Subclasses must implement this method to transform a string.
126: // */
127: // protected abstract String transform(String s);
128: //}
|