ICU-1434 improve method names; minor cleanup

X-SVN-Rev: 8970
This commit is contained in:
Alan Liu 2002-06-28 19:18:05 +00:00
parent 72a043bed7
commit 59164f02ca
12 changed files with 63 additions and 78 deletions

View file

@ -76,10 +76,9 @@ class FunctionReplacer implements UnicodeReplacer {
* Union the set of all characters that may output by this object
* into the given set.
* @param toUnionTo the set into which to union the output characters
* @return a reference to toUnionTo
*/
public UnicodeSet getReplacementSet(UnicodeSet toUnionTo) {
return toUnionTo.addAll(translit.getTargetSet());
public void addReplacementSetTo(UnicodeSet toUnionTo) {
toUnionTo.addAll(translit.getTargetSet());
}
}

View file

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/Quantifier.java,v $
* $Date: 2002/02/25 22:43:58 $
* $Revision: 1.7 $
* $Date: 2002/06/28 19:15:52 $
* $Revision: 1.8 $
*
*****************************************************************************************
*/
@ -111,11 +111,10 @@ class Quantifier implements UnicodeMatcher {
* @param toUnionTo the set into which to union the source characters
* @return a reference to toUnionTo
*/
public UnicodeSet getMatchSet(UnicodeSet toUnionTo) {
public void addMatchSetTo(UnicodeSet toUnionTo) {
if (maxCount > 0) {
matcher.getMatchSet(toUnionTo);
matcher.addMatchSetTo(toUnionTo);
}
return toUnionTo;
}
}

View file

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/RuleBasedTransliterator.java,v $
* $Date: 2002/06/26 18:12:39 $
* $Revision: 1.55 $
* $Date: 2002/06/28 19:15:52 $
* $Revision: 1.56 $
*
*****************************************************************************************
*/
@ -279,7 +279,7 @@ import com.ibm.icu.impl.data.ResourceReader;
* <p>Copyright (c) IBM Corporation 1999-2000. All rights reserved.</p>
*
* @author Alan Liu
* @version $RCSfile: RuleBasedTransliterator.java,v $ $Revision: 1.55 $ $Date: 2002/06/26 18:12:39 $
* @version $RCSfile: RuleBasedTransliterator.java,v $ $Revision: 1.56 $ $Date: 2002/06/28 19:15:52 $
*/
public class RuleBasedTransliterator extends Transliterator {
@ -454,7 +454,7 @@ public class RuleBasedTransliterator extends Transliterator {
* Transliterator, ignoring the effect of our filter.
*/
protected UnicodeSet handleGetSourceSet() {
return data.ruleSet.getSourceSet();
return data.ruleSet.getSourceTargetSet(false);
}
/**
@ -462,12 +462,15 @@ public class RuleBasedTransliterator extends Transliterator {
* replacement text by this transliterator.
*/
public UnicodeSet getTargetSet() {
return data.ruleSet.getTargetSet();
return data.ruleSet.getSourceTargetSet(true);
}
}
/**
* $Log: RuleBasedTransliterator.java,v $
* Revision 1.56 2002/06/28 19:15:52 alan
* jitterbug 1434: improve method names; minor cleanup
*
* Revision 1.55 2002/06/26 18:12:39 alan
* jitterbug 1434: initial public implementation of getSourceSet and getTargetSet
*

View file

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/StringMatcher.java,v $
* $Date: 2002/06/28 00:13:23 $
* $Revision: 1.11 $
* $Date: 2002/06/28 19:18:05 $
* $Revision: 1.12 $
*
*****************************************************************************************
*/
@ -220,20 +220,18 @@ class StringMatcher implements UnicodeMatcher, UnicodeReplacer {
* characters that may be matched by this object into the given
* set.
* @param toUnionTo the set into which to union the source characters
* @return a reference to toUnionTo
*/
public UnicodeSet getMatchSet(UnicodeSet toUnionTo) {
int ch;
public void addMatchSetTo(UnicodeSet toUnionTo) {
int ch;
for (int i=0; i<pattern.length(); i+=UTF16.getCharCount(ch)) {
ch = UTF16.charAt(pattern, i);
UnicodeMatcher matcher = data.lookupMatcher(ch);
if (matcher == null) {
toUnionTo.add(ch);
} else {
matcher.getMatchSet(toUnionTo);
matcher.addMatchSetTo(toUnionTo);
}
}
return toUnionTo;
}
/**
@ -284,15 +282,13 @@ class StringMatcher implements UnicodeMatcher, UnicodeReplacer {
* Union the set of all characters that may output by this object
* into the given set.
* @param toUnionTo the set into which to union the output characters
* @return a reference to toUnionTo
*/
public UnicodeSet getReplacementSet(UnicodeSet toUnionTo) {
public void addReplacementSetTo(UnicodeSet toUnionTo) {
// The output of this replacer varies; it is the source text between
// matchStart and matchLimit. Since this varies depending on the
// input text, we can't compute it here. We can either do nothing
// or we can add ALL characters to the set. It's probably more useful
// to do nothing.
return toUnionTo;
}
}

View file

@ -278,9 +278,8 @@ class StringReplacer implements UnicodeReplacer {
* Union the set of all characters that may output by this object
* into the given set.
* @param toUnionTo the set into which to union the output characters
* @return a reference to toUnionTo
*/
public UnicodeSet getReplacementSet(UnicodeSet toUnionTo) {
public void addReplacementSetTo(UnicodeSet toUnionTo) {
int ch;
for (int i=0; i<output.length(); i+=UTF16.getCharCount(ch)) {
ch = UTF16.charAt(output, i);
@ -288,10 +287,9 @@ class StringReplacer implements UnicodeReplacer {
if (r == null) {
toUnionTo.add(ch);
} else {
r.getReplacementSet(toUnionTo);
r.addReplacementSetTo(toUnionTo);
}
}
return toUnionTo;
}
}

View file

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/TransliterationRule.java,v $
* $Date: 2002/06/26 18:12:39 $
* $Revision: 1.46 $
* $Date: 2002/06/28 19:15:53 $
* $Revision: 1.47 $
*
*****************************************************************************************
*/
@ -46,7 +46,7 @@ import com.ibm.icu.impl.Utility;
* <p>Copyright &copy; IBM Corporation 1999. All rights reserved.
*
* @author Alan Liu
* @version $RCSfile: TransliterationRule.java,v $ $Revision: 1.46 $ $Date: 2002/06/26 18:12:39 $
* @version $RCSfile: TransliterationRule.java,v $ $Revision: 1.47 $ $Date: 2002/06/28 19:15:53 $
*/
class TransliterationRule {
@ -565,7 +565,7 @@ class TransliterationRule {
* Union the set of all characters that may be modified by this rule
* into the given set.
*/
UnicodeSet getSourceSet(UnicodeSet toUnionTo) {
void addSourceSetTo(UnicodeSet toUnionTo) {
int limit = anteContextLength + keyLength;
for (int i=anteContextLength; i<limit; ) {
int ch = UTF16.charAt(pattern, i);
@ -574,23 +574,25 @@ class TransliterationRule {
if (matcher == null) {
toUnionTo.add(ch);
} else {
matcher.getMatchSet(toUnionTo);
matcher.addMatchSetTo(toUnionTo);
}
}
return toUnionTo;
}
/**
* Union the set of all characters that may be emitted by this rule
* into the given set.
*/
UnicodeSet getTargetSet(UnicodeSet toUnionTo) {
return output.getReplacementSet(toUnionTo);
void addTargetSetTo(UnicodeSet toUnionTo) {
output.addReplacementSetTo(toUnionTo);
}
}
/**
* $Log: TransliterationRule.java,v $
* Revision 1.47 2002/06/28 19:15:53 alan
* jitterbug 1434: improve method names; minor cleanup
*
* Revision 1.46 2002/06/26 18:12:39 alan
* jitterbug 1434: initial public implementation of getSourceSet and getTargetSet
*

View file

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/TransliterationRuleSet.java,v $
* $Date: 2002/06/26 18:12:40 $
* $Revision: 1.24 $
* $Date: 2002/06/28 19:15:53 $
* $Revision: 1.25 $
*
*****************************************************************************************
*/
@ -28,7 +28,7 @@ import com.ibm.icu.impl.Utility;
* <p>Copyright &copy; IBM Corporation 1999. All rights reserved.
*
* @author Alan Liu
* @version $RCSfile: TransliterationRuleSet.java,v $ $Revision: 1.24 $ $Date: 2002/06/26 18:12:40 $
* @version $RCSfile: TransliterationRuleSet.java,v $ $Revision: 1.25 $ $Date: 2002/06/28 19:15:53 $
*/
class TransliterationRuleSet {
/**
@ -244,38 +244,32 @@ class TransliterationRuleSet {
}
/**
* Return the set of all characters that may be modified by this set.
* Return the set of all characters that may be modified (getTarget=false)
* or emitted (getTarget=true) by this set.
*/
UnicodeSet getSourceSet() {
UnicodeSet getSourceTargetSet(boolean getTarget) {
UnicodeSet set = new UnicodeSet();
int count = ruleVector.size();
for (int i=0; i<count; ++i) {
TransliterationRule r =
(TransliterationRule) ruleVector.elementAt(i);
r.getSourceSet(set);
}
return set;
}
/**
* Return the set of all characters that may be emitted by this set.
*/
UnicodeSet getTargetSet() {
UnicodeSet set = new UnicodeSet();
int count = ruleVector.size();
for (int i=0; i<count; ++i) {
TransliterationRule r =
(TransliterationRule) ruleVector.elementAt(i);
r.getTargetSet(set);
if (getTarget) {
r.addTargetSetTo(set);
} else {
r.addSourceSetTo(set);
}
}
return set;
}
}
/* $Log: TransliterationRuleSet.java,v $
* Revision 1.24 2002/06/26 18:12:40 alan
* jitterbug 1434: initial public implementation of getSourceSet and getTargetSet
* Revision 1.25 2002/06/28 19:15:53 alan
* jitterbug 1434: improve method names; minor cleanup
*
/* Revision 1.24 2002/06/26 18:12:40 alan
/* jitterbug 1434: initial public implementation of getSourceSet and getTargetSet
/*
/* Revision 1.23 2002/02/25 22:43:58 ram
/* Move Utility class to icu.impl
/*

View file

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/Transliterator.java,v $
* $Date: 2002/06/26 18:12:40 $
* $Revision: 1.78 $
* $Date: 2002/06/28 19:15:53 $
* $Revision: 1.79 $
*
*****************************************************************************************
*/
@ -250,7 +250,7 @@ import java.util.Vector;
* <p>Copyright &copy; IBM Corporation 1999. All rights reserved.
*
* @author Alan Liu
* @version $RCSfile: Transliterator.java,v $ $Revision: 1.78 $ $Date: 2002/06/26 18:12:40 $
* @version $RCSfile: Transliterator.java,v $ $Revision: 1.79 $ $Date: 2002/06/28 19:15:53 $
*/
public abstract class Transliterator {
/**
@ -1332,7 +1332,7 @@ public abstract class Transliterator {
filterSet = (UnicodeSet) filter;
} catch (ClassCastException e) {
filterSet = new UnicodeSet();
filter.getMatchSet(filterSet);
filter.addMatchSetTo(filterSet);
}
set.retainAll(filterSet);
}

View file

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/UnicodeFilter.java,v $
* $Date: 2002/02/16 03:06:21 $
* $Revision: 1.10 $
* $Date: 2002/06/28 19:15:53 $
* $Revision: 1.11 $
*
*****************************************************************************************
*/
@ -81,9 +81,7 @@ public abstract class UnicodeFilter implements UnicodeMatcher {
/**
* Stubbed out implementation of UnicodeMatcher API.
* @param toUnionTo the set into which to union the source characters
* @return a reference to toUnionTo
*/
public UnicodeSet getMatchSet(UnicodeSet toUnionTo) {
return toUnionTo;
public void addMatchSetTo(UnicodeSet toUnionTo) {
}
}

View file

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/UnicodeMatcher.java,v $
* $Date: 2002/03/15 19:02:25 $
* $Revision: 1.5 $
* $Date: 2002/06/28 19:15:53 $
* $Revision: 1.6 $
*
*****************************************************************************************
*/
@ -120,9 +120,8 @@ public interface UnicodeMatcher {
* Union the set of all characters that may be matched by this object
* into the given set.
* @param toUnionTo the set into which to union the source characters
* @return a reference to toUnionTo
*/
public abstract UnicodeSet getMatchSet(UnicodeSet toUnionTo);
public abstract void addMatchSetTo(UnicodeSet toUnionTo);
}
//eof

View file

@ -57,9 +57,8 @@ interface UnicodeReplacer {
* Union the set of all characters that may output by this object
* into the given set.
* @param toUnionTo the set into which to union the output characters
* @return a reference to toUnionTo
*/
public abstract UnicodeSet getReplacementSet(UnicodeSet toUnionTo);
public abstract void addReplacementSetTo(UnicodeSet toUnionTo);
}
//eof

View file

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/UnicodeSet.java,v $
* $Date: 2002/04/26 00:00:36 $
* $Revision: 1.67 $
* $Date: 2002/06/28 19:15:53 $
* $Revision: 1.68 $
*
*****************************************************************************************
*/
@ -209,7 +209,7 @@ import java.util.Iterator;
* </table>
* <br><b>Warning: you cannot add an empty string ("") to a UnicodeSet.</b>
* @author Alan Liu
* @version $RCSfile: UnicodeSet.java,v $ $Revision: 1.67 $ $Date: 2002/04/26 00:00:36 $
* @version $RCSfile: UnicodeSet.java,v $ $Revision: 1.68 $ $Date: 2002/06/28 19:15:53 $
*/
public class UnicodeSet extends UnicodeFilter {
@ -797,11 +797,9 @@ public class UnicodeSet extends UnicodeFilter {
* characters that may be matched by this object into the given
* set.
* @param toUnionTo the set into which to union the source characters
* @return a reference to toUnionTo
*/
public UnicodeSet getMatchSet(UnicodeSet toUnionTo) {
public void addMatchSetTo(UnicodeSet toUnionTo) {
toUnionTo.addAll(this);
return toUnionTo;
}
/**