01: /*
02: *******************************************************************************
03: * Copyright (C) 1996-2004, International Business Machines Corporation and *
04: * others. All Rights Reserved. *
05: *******************************************************************************
06: */
07: package com.ibm.icu.text;
08:
09: /**
10: * A transliterator that removes characters. This is useful in conjunction
11: * with a filter.
12: */
13: class RemoveTransliterator extends Transliterator {
14:
15: /**
16: * ID for this transliterator.
17: */
18: private static String _ID = "Any-Remove";
19:
20: /**
21: * System registration hook.
22: */
23: static void register() {
24: Transliterator.registerFactory(_ID,
25: new Transliterator.Factory() {
26: public Transliterator getInstance(String 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: }
|