]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-4_4_2-src/main/classes/core/src/com/ibm/icu/text/UnicodeReplacer.java
go
[Dictionary.git] / jars / icu4j-4_4_2-src / main / classes / core / src / com / ibm / icu / text / UnicodeReplacer.java
1 /*\r
2 **********************************************************************\r
3 *   Copyright (c) 2002, International Business Machines Corporation\r
4 *   and others.  All Rights Reserved.\r
5 **********************************************************************\r
6 *   Date        Name        Description\r
7 *   01/14/2002  aliu        Creation.\r
8 **********************************************************************\r
9 */\r
10 \r
11 package com.ibm.icu.text;\r
12 \r
13 /**\r
14  * <code>UnicodeReplacer</code> defines a protocol for objects that\r
15  * replace a range of characters in a Replaceable string with output\r
16  * text.  The replacement is done via the Replaceable API so as to\r
17  * preserve out-of-band data.\r
18  * @author Alan Liu\r
19  */\r
20 interface UnicodeReplacer {\r
21 \r
22     /**\r
23      * Replace characters in 'text' from 'start' to 'limit' with the\r
24      * output text of this object.  Update the 'cursor' parameter to\r
25      * give the cursor position and return the length of the\r
26      * replacement text.\r
27      *\r
28      * @param text the text to be matched\r
29      * @param start inclusive start index of text to be replaced\r
30      * @param limit exclusive end index of text to be replaced;\r
31      * must be greater than or equal to start\r
32      * @param cursor output parameter for the cursor position.\r
33      * Not all replacer objects will update this, but in a complete\r
34      * tree of replacer objects, representing the entire output side\r
35      * of a transliteration rule, at least one must update it.\r
36      * @return the number of 16-bit code units in the text replacing\r
37      * the characters at offsets start..(limit-1) in text\r
38      */\r
39     public abstract int replace(Replaceable text,\r
40                                 int start,\r
41                                 int limit,\r
42                                 int[] cursor);\r
43 \r
44     /**\r
45      * Returns a string representation of this replacer.  If the\r
46      * result of calling this function is passed to the appropriate\r
47      * parser, typically TransliteratorParser, it will produce another\r
48      * replacer that is equal to this one.\r
49      * @param escapeUnprintable if TRUE then convert unprintable\r
50      * character to their hex escape representations, \\uxxxx or\r
51      * \\Uxxxxxxxx.  Unprintable characters are defined by\r
52      * Utility.isUnprintable().\r
53      */\r
54     public abstract String toReplacerPattern(boolean escapeUnprintable);\r
55 \r
56     /**\r
57      * Union the set of all characters that may output by this object\r
58      * into the given set.\r
59      * @param toUnionTo the set into which to union the output characters\r
60      */\r
61     public abstract void addReplacementSetTo(UnicodeSet toUnionTo);\r
62 }\r
63 \r
64 //eof\r