diff --git a/icu4j/src/com/ibm/icu/text/RuleBasedTransliterator.java b/icu4j/src/com/ibm/icu/text/RuleBasedTransliterator.java index 04f92a10954..7bc5031d1ba 100755 --- a/icu4j/src/com/ibm/icu/text/RuleBasedTransliterator.java +++ b/icu4j/src/com/ibm/icu/text/RuleBasedTransliterator.java @@ -5,8 +5,8 @@ ******************************************************************************* * * $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/RuleBasedTransliterator.java,v $ - * $Date: 2000/03/10 04:07:23 $ - * $Revision: 1.17 $ + * $Date: 2000/04/12 20:17:45 $ + * $Revision: 1.18 $ * ***************************************************************************************** */ @@ -209,9 +209,12 @@ import com.ibm.util.Utility; *
Copyright (c) IBM Corporation 1999-2000. All rights reserved.
* * @author Alan Liu - * @version $RCSfile: RuleBasedTransliterator.java,v $ $Revision: 1.17 $ $Date: 2000/03/10 04:07:23 $ + * @version $RCSfile: RuleBasedTransliterator.java,v $ $Revision: 1.18 $ $Date: 2000/04/12 20:17:45 $ * * $Log: RuleBasedTransliterator.java,v $ + * Revision 1.18 2000/04/12 20:17:45 alan + * Delegate replace operation to rule object + * * Revision 1.17 2000/03/10 04:07:23 johnf * Copyright update * @@ -375,8 +378,10 @@ public class RuleBasedTransliterator extends Transliterator { ++cursor; } } else { - text.replace(cursor, cursor + r.getKeyLength(), r.getOutput()); - limit += r.getOutput().length() - r.getKeyLength(); + // Delegate replacement to TransliterationRule object + limit += r.replace(text, cursor); + // text.replace(cursor, cursor + r.getKeyLength(), r.getOutput()); + // limit += r.getOutput().length() - r.getKeyLength(); cursor += r.getCursorPos(); ++loopCount; } diff --git a/icu4j/src/com/ibm/icu/text/TransliterationRule.java b/icu4j/src/com/ibm/icu/text/TransliterationRule.java index f62c3ee21bf..27a7a3fff3f 100755 --- a/icu4j/src/com/ibm/icu/text/TransliterationRule.java +++ b/icu4j/src/com/ibm/icu/text/TransliterationRule.java @@ -5,8 +5,8 @@ ******************************************************************************* * * $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/TransliterationRule.java,v $ - * $Date: 2000/03/10 04:07:24 $ - * $Revision: 1.14 $ + * $Date: 2000/04/12 20:17:45 $ + * $Revision: 1.15 $ * ***************************************************************************************** */ @@ -33,9 +33,12 @@ import com.ibm.util.Utility; *Copyright © IBM Corporation 1999. All rights reserved.
*
* @author Alan Liu
- * @version $RCSfile: TransliterationRule.java,v $ $Revision: 1.14 $ $Date: 2000/03/10 04:07:24 $
+ * @version $RCSfile: TransliterationRule.java,v $ $Revision: 1.15 $ $Date: 2000/04/12 20:17:45 $
*
* $Log: TransliterationRule.java,v $
+ * Revision 1.15 2000/04/12 20:17:45 alan
+ * Delegate replace operation to rule object
+ *
* Revision 1.14 2000/03/10 04:07:24 johnf
* Copyright update
*
@@ -192,22 +195,6 @@ class TransliterationRule {
this.output = output;
}
- /**
- * Return the length of the key. Equivalent to getKey().length()
.
- * @return the length of the match key.
- */
- public int getKeyLength() {
- return keyLength;
- }
-
- /**
- * Return the output string.
- * @return the output string.
- */
- public String getOutput() {
- return output;
- }
-
/**
* Return the position of the cursor within the output string.
* @return a value from 0 to getOutput().length()
, inclusive.
@@ -241,6 +228,23 @@ class TransliterationRule {
return variables.lookup(c) == null ? (c & 0xFF) : -1;
}
+ /**
+ * Do a replacement of the input pattern with the output text in
+ * the given string, at the given offset. This method assumes
+ * that a match has already been found in the given text at the
+ * given position.
+ * @param text the text containing the substring to be replaced
+ * @param offset the offset into the text at which the pattern
+ * matches. This is the offset to the point after the ante
+ * context, if any, and before the match string and any post
+ * context.
+ * @return the change in the length of the text
+ */
+ int replace(Replaceable text, int offset) {
+ text.replace(offset, offset + keyLength, output);
+ return output.length() - keyLength;
+ }
+
/**
* Internal method. Returns true if this rule matches the given
* index value. The index value is an 8-bit integer, 0..255,
diff --git a/icu4j/src/com/ibm/text/RuleBasedTransliterator.java b/icu4j/src/com/ibm/text/RuleBasedTransliterator.java
index 23fb3933750..a3594062040 100755
--- a/icu4j/src/com/ibm/text/RuleBasedTransliterator.java
+++ b/icu4j/src/com/ibm/text/RuleBasedTransliterator.java
@@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/text/Attic/RuleBasedTransliterator.java,v $
- * $Date: 2000/03/10 04:07:23 $
- * $Revision: 1.17 $
+ * $Date: 2000/04/12 20:17:45 $
+ * $Revision: 1.18 $
*
*****************************************************************************************
*/
@@ -209,9 +209,12 @@ import com.ibm.util.Utility;
*
Copyright (c) IBM Corporation 1999-2000. All rights reserved.
* * @author Alan Liu - * @version $RCSfile: RuleBasedTransliterator.java,v $ $Revision: 1.17 $ $Date: 2000/03/10 04:07:23 $ + * @version $RCSfile: RuleBasedTransliterator.java,v $ $Revision: 1.18 $ $Date: 2000/04/12 20:17:45 $ * * $Log: RuleBasedTransliterator.java,v $ + * Revision 1.18 2000/04/12 20:17:45 alan + * Delegate replace operation to rule object + * * Revision 1.17 2000/03/10 04:07:23 johnf * Copyright update * @@ -375,8 +378,10 @@ public class RuleBasedTransliterator extends Transliterator { ++cursor; } } else { - text.replace(cursor, cursor + r.getKeyLength(), r.getOutput()); - limit += r.getOutput().length() - r.getKeyLength(); + // Delegate replacement to TransliterationRule object + limit += r.replace(text, cursor); + // text.replace(cursor, cursor + r.getKeyLength(), r.getOutput()); + // limit += r.getOutput().length() - r.getKeyLength(); cursor += r.getCursorPos(); ++loopCount; } diff --git a/icu4j/src/com/ibm/text/TransliterationRule.java b/icu4j/src/com/ibm/text/TransliterationRule.java index 5c154c795f2..a4db8546ee5 100755 --- a/icu4j/src/com/ibm/text/TransliterationRule.java +++ b/icu4j/src/com/ibm/text/TransliterationRule.java @@ -5,8 +5,8 @@ ******************************************************************************* * * $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/text/Attic/TransliterationRule.java,v $ - * $Date: 2000/03/10 04:07:24 $ - * $Revision: 1.14 $ + * $Date: 2000/04/12 20:17:45 $ + * $Revision: 1.15 $ * ***************************************************************************************** */ @@ -33,9 +33,12 @@ import com.ibm.util.Utility; *Copyright © IBM Corporation 1999. All rights reserved.
*
* @author Alan Liu
- * @version $RCSfile: TransliterationRule.java,v $ $Revision: 1.14 $ $Date: 2000/03/10 04:07:24 $
+ * @version $RCSfile: TransliterationRule.java,v $ $Revision: 1.15 $ $Date: 2000/04/12 20:17:45 $
*
* $Log: TransliterationRule.java,v $
+ * Revision 1.15 2000/04/12 20:17:45 alan
+ * Delegate replace operation to rule object
+ *
* Revision 1.14 2000/03/10 04:07:24 johnf
* Copyright update
*
@@ -192,22 +195,6 @@ class TransliterationRule {
this.output = output;
}
- /**
- * Return the length of the key. Equivalent to getKey().length()
.
- * @return the length of the match key.
- */
- public int getKeyLength() {
- return keyLength;
- }
-
- /**
- * Return the output string.
- * @return the output string.
- */
- public String getOutput() {
- return output;
- }
-
/**
* Return the position of the cursor within the output string.
* @return a value from 0 to getOutput().length()
, inclusive.
@@ -241,6 +228,23 @@ class TransliterationRule {
return variables.lookup(c) == null ? (c & 0xFF) : -1;
}
+ /**
+ * Do a replacement of the input pattern with the output text in
+ * the given string, at the given offset. This method assumes
+ * that a match has already been found in the given text at the
+ * given position.
+ * @param text the text containing the substring to be replaced
+ * @param offset the offset into the text at which the pattern
+ * matches. This is the offset to the point after the ante
+ * context, if any, and before the match string and any post
+ * context.
+ * @return the change in the length of the text
+ */
+ int replace(Replaceable text, int offset) {
+ text.replace(offset, offset + keyLength, output);
+ return output.length() - keyLength;
+ }
+
/**
* Internal method. Returns true if this rule matches the given
* index value. The index value is an 8-bit integer, 0..255,