KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ibm > icu > text > RemoveTransliterator


1 /*
2  *******************************************************************************
3  * Copyright (C) 1996-2004, International Business Machines Corporation and *
4  * others. All Rights Reserved. *
5  *******************************************************************************
6  */

7 package com.ibm.icu.text;
8
9
10 /**
11  * A transliterator that removes characters. This is useful in conjunction
12  * with a filter.
13  */

14 class RemoveTransliterator extends Transliterator {
15
16     /**
17      * ID for this transliterator.
18      */

19     private static String JavaDoc _ID = "Any-Remove";
20
21     /**
22      * System registration hook.
23      */

24     static void register() {
25         Transliterator.registerFactory(_ID, new Transliterator.Factory() {
26             public Transliterator getInstance(String JavaDoc ID) {
27                 return new RemoveTransliterator();
28             }
29         });
30         Transliterator.registerSpecialInverse("Remove", "Null", false);
31     }
32
33     /**
34      * Constructs a transliterator.
35      */

36     public RemoveTransliterator() {
37         super(_ID, null);
38     }
39
40     /**
41      * Implements {@link Transliterator#handleTransliterate}.
42      */

43     protected void handleTransliterate(Replaceable text,
44                                        Position index, boolean incremental) {
45         // Our caller (filteredTransliterate) has already narrowed us
46
// to an unfiltered run. Delete it.
47
text.replace(index.start, index.limit, "");
48         int len = index.limit - index.start;
49         index.contextLimit -= len;
50         index.limit -= len;
51     }
52 }
53
Popular Tags