From 697ee8afba76f6e2b82920bd81ed92f22ba054e1 Mon Sep 17 00:00:00 2001 From: Alan Liu Date: Thu, 6 Jan 2000 17:38:25 +0000 Subject: [PATCH] Add null transliterator X-SVN-Rev: 491 --- .../com/ibm/icu/text/NullTransliterator.java | 43 +++++++++++++++++++ .../src/com/ibm/icu/text/Transliterator.java | 5 ++- .../src/com/ibm/text/NullTransliterator.java | 43 +++++++++++++++++++ icu4j/src/com/ibm/text/Transliterator.java | 5 ++- 4 files changed, 94 insertions(+), 2 deletions(-) create mode 100755 icu4j/src/com/ibm/icu/text/NullTransliterator.java create mode 100755 icu4j/src/com/ibm/text/NullTransliterator.java diff --git a/icu4j/src/com/ibm/icu/text/NullTransliterator.java b/icu4j/src/com/ibm/icu/text/NullTransliterator.java new file mode 100755 index 0000000000..cf469e82b5 --- /dev/null +++ b/icu4j/src/com/ibm/icu/text/NullTransliterator.java @@ -0,0 +1,43 @@ +package com.ibm.text; +import java.util.*; + +/** + * A transliterator that leaves text unchanged. + */ +public class NullTransliterator extends Transliterator { + private static final String COPYRIGHT = + "\u00A9 IBM Corporation 2000. All rights reserved."; + + /** + * Package accessible ID for this transliterator. + */ + static String _ID = "Null"; + + /** + * Constructs a transliterator. + */ + public NullTransliterator() { + super(_ID, null); + } + + /** + * Transliterates a segment of a string. Transliterator API. + * @param text the string to be transliterated + * @param start the beginning index, inclusive; 0 <= start + * <= limit. + * @param limit the ending index, exclusive; start <= limit + * <= text.length(). + * @return the new limit index + */ + public int transliterate(Replaceable text, int start, int limit) { + return limit; + } + + /** + * Implements {@link Transliterator#handleKeyboardTransliterate}. + */ + protected void handleKeyboardTransliterate(Replaceable text, + int[] offsets) { + offsets[CURSOR] = offsets[LIMIT]; + } +} diff --git a/icu4j/src/com/ibm/icu/text/Transliterator.java b/icu4j/src/com/ibm/icu/text/Transliterator.java index 61c83d2a91..ef159ce1e7 100755 --- a/icu4j/src/com/ibm/icu/text/Transliterator.java +++ b/icu4j/src/com/ibm/icu/text/Transliterator.java @@ -198,7 +198,7 @@ import java.text.MessageFormat; *

Copyright © IBM Corporation 1999. All rights reserved. * * @author Alan Liu - * @version $RCSfile: Transliterator.java,v $ $Revision: 1.5 $ $Date: 2000/01/06 01:36:36 $ + * @version $RCSfile: Transliterator.java,v $ $Revision: 1.6 $ $Date: 2000/01/06 17:38:25 $ */ public abstract class Transliterator { /** @@ -880,9 +880,12 @@ public abstract class Transliterator { } } catch (MissingResourceException e) {} + // Register non-rule-based transliterators registerClass(HexToUnicodeTransliterator._ID, HexToUnicodeTransliterator.class); registerClass(UnicodeToHexTransliterator._ID, UnicodeToHexTransliterator.class); + registerClass(NullTransliterator._ID, + NullTransliterator.class); } } diff --git a/icu4j/src/com/ibm/text/NullTransliterator.java b/icu4j/src/com/ibm/text/NullTransliterator.java new file mode 100755 index 0000000000..cf469e82b5 --- /dev/null +++ b/icu4j/src/com/ibm/text/NullTransliterator.java @@ -0,0 +1,43 @@ +package com.ibm.text; +import java.util.*; + +/** + * A transliterator that leaves text unchanged. + */ +public class NullTransliterator extends Transliterator { + private static final String COPYRIGHT = + "\u00A9 IBM Corporation 2000. All rights reserved."; + + /** + * Package accessible ID for this transliterator. + */ + static String _ID = "Null"; + + /** + * Constructs a transliterator. + */ + public NullTransliterator() { + super(_ID, null); + } + + /** + * Transliterates a segment of a string. Transliterator API. + * @param text the string to be transliterated + * @param start the beginning index, inclusive; 0 <= start + * <= limit. + * @param limit the ending index, exclusive; start <= limit + * <= text.length(). + * @return the new limit index + */ + public int transliterate(Replaceable text, int start, int limit) { + return limit; + } + + /** + * Implements {@link Transliterator#handleKeyboardTransliterate}. + */ + protected void handleKeyboardTransliterate(Replaceable text, + int[] offsets) { + offsets[CURSOR] = offsets[LIMIT]; + } +} diff --git a/icu4j/src/com/ibm/text/Transliterator.java b/icu4j/src/com/ibm/text/Transliterator.java index 61c83d2a91..ef159ce1e7 100755 --- a/icu4j/src/com/ibm/text/Transliterator.java +++ b/icu4j/src/com/ibm/text/Transliterator.java @@ -198,7 +198,7 @@ import java.text.MessageFormat; *

Copyright © IBM Corporation 1999. All rights reserved. * * @author Alan Liu - * @version $RCSfile: Transliterator.java,v $ $Revision: 1.5 $ $Date: 2000/01/06 01:36:36 $ + * @version $RCSfile: Transliterator.java,v $ $Revision: 1.6 $ $Date: 2000/01/06 17:38:25 $ */ public abstract class Transliterator { /** @@ -880,9 +880,12 @@ public abstract class Transliterator { } } catch (MissingResourceException e) {} + // Register non-rule-based transliterators registerClass(HexToUnicodeTransliterator._ID, HexToUnicodeTransliterator.class); registerClass(UnicodeToHexTransliterator._ID, UnicodeToHexTransliterator.class); + registerClass(NullTransliterator._ID, + NullTransliterator.class); } }