harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r462605 [2/8] - in /incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java: java/text/ org/apache/harmony/text/ org/apache/harmony/text/internal/nls/
Date Tue, 10 Oct 2006 22:18:37 GMT
Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/ChoiceFormat.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/ChoiceFormat.java?view=diff&rev=462605&r1=462604&r2=462605
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/ChoiceFormat.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/ChoiceFormat.java Tue Oct 10 15:18:35 2006
@@ -17,7 +17,6 @@
 
 package java.text;
 
-
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -31,375 +30,382 @@
 
 public class ChoiceFormat extends NumberFormat {
 
-	private static final long serialVersionUID = 1795184449645032964L;
+    private static final long serialVersionUID = 1795184449645032964L;
 
-	private double[] choiceLimits;
+    private double[] choiceLimits;
 
-	private String[] choiceFormats;
+    private String[] choiceFormats;
 
-	/**
-	 * Constructs a new ChoiceFormat with the specified ranges and associated
-	 * strings.
-	 * 
-	 * @param limits
-	 *            an array of double, the ranges are greater or equal to the
-	 *            value in lower index up to less than the value in the next
-	 *            higher index. The bounds of the lowest and highest indexes are
-	 *            negative and positive infinity.
-	 * @param formats
-	 *            the strings associated with the ranges. The lower bound of the
-	 *            associated range is at the same index as the string.
-	 */
-	public ChoiceFormat(double[] limits, String[] formats) {
-		setChoices(limits, formats);
-	}
-
-	/**
-	 * Constructs a new ChoiceFormat with the strings and ranges parsed from the
-	 * specified pattern.
-	 * 
-	 * @param template
-	 *            the pattern of strings and ranges
-	 * 
-	 * @exception IllegalArgumentException
-	 *                then an error occurs parsing the pattern
-	 */
-	public ChoiceFormat(String template) {
-		applyPattern(template);
-	}
-
-	/**
-	 * Parses the pattern to determine new strings and ranges for this
-	 * ChoiceFormat.
-	 * 
-	 * @param template
-	 *            the pattern of strings and ranges
-	 * 
-	 * @exception IllegalArgumentException
-	 *                then an error occurs parsing the pattern
-	 */
-	public void applyPattern(String template) {
-		double[] limits = new double[5];
-		List<String> formats = new ArrayList<String>();
-		int length = template.length(), limitCount = 0, index = 0;
-		StringBuffer buffer = new StringBuffer();
-		NumberFormat format = NumberFormat.getInstance(Locale.US);
-		ParsePosition position = new ParsePosition(0);
-		while (true) {
-			index = skipWhitespace(template, index);
-			if (index >= length) {
-				if (limitCount == limits.length) {
+    /**
+     * Constructs a new ChoiceFormat with the specified ranges and associated
+     * strings.
+     * 
+     * @param limits
+     *            an array of double, the ranges are greater or equal to the
+     *            value in lower index up to less than the value in the next
+     *            higher index. The bounds of the lowest and highest indexes are
+     *            negative and positive infinity.
+     * @param formats
+     *            the strings associated with the ranges. The lower bound of the
+     *            associated range is at the same index as the string.
+     */
+    public ChoiceFormat(double[] limits, String[] formats) {
+        setChoices(limits, formats);
+    }
+
+    /**
+     * Constructs a new ChoiceFormat with the strings and ranges parsed from the
+     * specified pattern.
+     * 
+     * @param template
+     *            the pattern of strings and ranges
+     * 
+     * @exception IllegalArgumentException
+     *                then an error occurs parsing the pattern
+     */
+    public ChoiceFormat(String template) {
+        applyPattern(template);
+    }
+
+    /**
+     * Parses the pattern to determine new strings and ranges for this
+     * ChoiceFormat.
+     * 
+     * @param template
+     *            the pattern of strings and ranges
+     * 
+     * @exception IllegalArgumentException
+     *                then an error occurs parsing the pattern
+     */
+    public void applyPattern(String template) {
+        double[] limits = new double[5];
+        List<String> formats = new ArrayList<String>();
+        int length = template.length(), limitCount = 0, index = 0;
+        StringBuffer buffer = new StringBuffer();
+        NumberFormat format = NumberFormat.getInstance(Locale.US);
+        ParsePosition position = new ParsePosition(0);
+        while (true) {
+            index = skipWhitespace(template, index);
+            if (index >= length) {
+                if (limitCount == limits.length) {
                     choiceLimits = limits;
                 } else {
-					choiceLimits = new double[limitCount];
-					System.arraycopy(limits, 0, choiceLimits, 0, limitCount);
-				}
-				choiceFormats = new String[formats.size()];
-				for (int i = 0; i < formats.size(); i++) {
+                    choiceLimits = new double[limitCount];
+                    System.arraycopy(limits, 0, choiceLimits, 0, limitCount);
+                }
+                choiceFormats = new String[formats.size()];
+                for (int i = 0; i < formats.size(); i++) {
                     choiceFormats[i] = formats.get(i);
                 }
-				return;
-			}
+                return;
+            }
 
-			position.setIndex(index);
-			Number value = format.parse(template, position);
-			index = skipWhitespace(template, position.getIndex());
-			if (position.getErrorIndex() != -1 || index >= length) {
-                //Fix Harmony 540
+            position.setIndex(index);
+            Number value = format.parse(template, position);
+            index = skipWhitespace(template, position.getIndex());
+            if (position.getErrorIndex() != -1 || index >= length) {
+                // Fix Harmony 540
                 choiceLimits = new double[0];
                 choiceFormats = new String[0];
                 return;
             }
-			char ch = template.charAt(index++);
-			if (limitCount == limits.length) {
-				double[] newLimits = new double[limitCount * 2];
-				System.arraycopy(limits, 0, newLimits, 0, limitCount);
-				limits = newLimits;
-			}
-			double next;
-			switch (ch) {
-			case '#':
-			case '\u2264':
-				next = value.doubleValue();
-				break;
-			case '<':
-				next = nextDouble(value.doubleValue());
-				break;
-			default:
-				throw new IllegalArgumentException();
-			}
-			if (limitCount > 0 && next <= limits[limitCount - 1]) {
+            char ch = template.charAt(index++);
+            if (limitCount == limits.length) {
+                double[] newLimits = new double[limitCount * 2];
+                System.arraycopy(limits, 0, newLimits, 0, limitCount);
+                limits = newLimits;
+            }
+            double next;
+            switch (ch) {
+                case '#':
+                case '\u2264':
+                    next = value.doubleValue();
+                    break;
+                case '<':
+                    next = nextDouble(value.doubleValue());
+                    break;
+                default:
+                    throw new IllegalArgumentException();
+            }
+            if (limitCount > 0 && next <= limits[limitCount - 1]) {
                 throw new IllegalArgumentException();
             }
-			buffer.setLength(0);
-			position.setIndex(index);
-			upTo(template, position, buffer, '|');
-			index = position.getIndex();
-			limits[limitCount++] = next;
-			formats.add(buffer.toString());
-		}
-	}
-
-	/**
-	 * Answers a new instance of ChoiceFormat with the same ranges and strings
-	 * as this ChoiceFormat.
-	 * 
-	 * @return a shallow copy of this ChoiceFormat
-	 * 
-	 * @see java.lang.Cloneable
-	 */
-	public Object clone() {
-		ChoiceFormat clone = (ChoiceFormat) super.clone();
-		clone.choiceLimits = choiceLimits.clone();
-		clone.choiceFormats = choiceFormats.clone();
-		return clone;
-	}
-
-	/**
-	 * Compares the specified object to this ChoiceFormat and answer if they are
-	 * equal. The object must be an instance of ChoiceFormat and have the same
-	 * limits and formats.
-	 * 
-	 * @param object
-	 *            the object to compare with this object
-	 * @return true if the specified object is equal to this ChoiceFormat, false
-	 *         otherwise
-	 * 
-	 * @see #hashCode
-	 */
-	public boolean equals(Object object) {
-		if (this == object) {
+            buffer.setLength(0);
+            position.setIndex(index);
+            upTo(template, position, buffer, '|');
+            index = position.getIndex();
+            limits[limitCount++] = next;
+            formats.add(buffer.toString());
+        }
+    }
+
+    /**
+     * Answers a new instance of ChoiceFormat with the same ranges and strings
+     * as this ChoiceFormat.
+     * 
+     * @return a shallow copy of this ChoiceFormat
+     * 
+     * @see java.lang.Cloneable
+     */
+    @Override
+    public Object clone() {
+        ChoiceFormat clone = (ChoiceFormat) super.clone();
+        clone.choiceLimits = choiceLimits.clone();
+        clone.choiceFormats = choiceFormats.clone();
+        return clone;
+    }
+
+    /**
+     * Compares the specified object to this ChoiceFormat and answer if they are
+     * equal. The object must be an instance of ChoiceFormat and have the same
+     * limits and formats.
+     * 
+     * @param object
+     *            the object to compare with this object
+     * @return true if the specified object is equal to this ChoiceFormat, false
+     *         otherwise
+     * 
+     * @see #hashCode
+     */
+    @Override
+    public boolean equals(Object object) {
+        if (this == object) {
             return true;
         }
-		if (!(object instanceof ChoiceFormat)) {
+        if (!(object instanceof ChoiceFormat)) {
             return false;
         }
-		ChoiceFormat choice = (ChoiceFormat) object;
-		return Arrays.equals(choiceLimits, choice.choiceLimits)
-				&& Arrays.equals(choiceFormats, choice.choiceFormats);
-	}
-
-	/**
-	 * Appends to the specified StringBuffer the string associated with the
-	 * range in which the specified double value fits.
-	 * 
-	 * @param value
-	 *            the double to format
-	 * @param buffer
-	 *            the StringBuffer
-	 * @param field
-	 *            a FieldPosition which is ignored
-	 * @return the StringBuffer parameter <code>buffer</code>
-	 */
-	public StringBuffer format(double value, StringBuffer buffer,
-			FieldPosition field) {
-        for(int i = choiceLimits.length - 1; i >= 0; i--) {
+        ChoiceFormat choice = (ChoiceFormat) object;
+        return Arrays.equals(choiceLimits, choice.choiceLimits)
+                && Arrays.equals(choiceFormats, choice.choiceFormats);
+    }
+
+    /**
+     * Appends to the specified StringBuffer the string associated with the
+     * range in which the specified double value fits.
+     * 
+     * @param value
+     *            the double to format
+     * @param buffer
+     *            the StringBuffer
+     * @param field
+     *            a FieldPosition which is ignored
+     * @return the StringBuffer parameter <code>buffer</code>
+     */
+    @Override
+    public StringBuffer format(double value, StringBuffer buffer,
+            FieldPosition field) {
+        for (int i = choiceLimits.length - 1; i >= 0; i--) {
             if (choiceLimits[i] <= value) {
                 return buffer.append(choiceFormats[i]);
             }
         }
-        return choiceFormats.length == 0 ? buffer : buffer.append(choiceFormats[0]);
-	}
+        return choiceFormats.length == 0 ? buffer : buffer
+                .append(choiceFormats[0]);
+    }
+
+    /**
+     * Appends to the specified StringBuffer the string associated with the
+     * range in which the specified long value fits.
+     * 
+     * @param value
+     *            the long to format
+     * @param buffer
+     *            the StringBuffer
+     * @param field
+     *            a FieldPosition which is ignored
+     * @return the StringBuffer parameter <code>buffer</code>
+     */
+    @Override
+    public StringBuffer format(long value, StringBuffer buffer,
+            FieldPosition field) {
+        return format((double) value, buffer, field);
+    }
+
+    /**
+     * Answers the Strings associated with the ranges of this ChoiceFormat.
+     * 
+     * @return an array of String
+     */
+    public Object[] getFormats() {
+        return choiceFormats;
+    }
+
+    /**
+     * Answers the ranges of this ChoiceFormat.
+     * 
+     * @return an array of double, the ranges are greater or equal to the value
+     *         in lower index up to less than the value in the next higher
+     *         index. The bounds of the lowest and highest indexes are negative
+     *         and positive infinity.
+     */
+    public double[] getLimits() {
+        return choiceLimits;
+    }
+
+    /**
+     * Answers an integer hash code for the receiver. Objects which are equal
+     * answer the same value for this method.
+     * 
+     * @return the receiver's hash
+     * 
+     * @see #equals
+     */
+    @Override
+    public int hashCode() {
+        int hashCode = 0;
+        for (int i = 0; i < choiceLimits.length; i++) {
+            long v = Double.doubleToLongBits(choiceLimits[i]);
+            hashCode += (int) (v ^ (v >>> 32)) + choiceFormats[i].hashCode();
+        }
+        return hashCode;
+    }
 
-	/**
-	 * Appends to the specified StringBuffer the string associated with the
-	 * range in which the specified long value fits.
-	 * 
-	 * @param value
-	 *            the long to format
-	 * @param buffer
-	 *            the StringBuffer
-	 * @param field
-	 *            a FieldPosition which is ignored
-	 * @return the StringBuffer parameter <code>buffer</code>
-	 */
-	public StringBuffer format(long value, StringBuffer buffer,
-			FieldPosition field) {
-		return format((double) value, buffer, field);
-	}
-
-	/**
-	 * Answers the Strings associated with the ranges of this ChoiceFormat.
-	 * 
-	 * @return an array of String
-	 */
-	public Object[] getFormats() {
-		return choiceFormats;
-	}
-
-	/**
-	 * Answers the ranges of this ChoiceFormat.
-	 * 
-	 * @return an array of double, the ranges are greater or equal to the value
-	 *         in lower index up to less than the value in the next higher
-	 *         index. The bounds of the lowest and highest indexes are negative
-	 *         and positive infinity.
-	 */
-	public double[] getLimits() {
-		return choiceLimits;
-	}
-
-	/**
-	 * Answers an integer hash code for the receiver. Objects which are equal
-	 * answer the same value for this method.
-	 * 
-	 * @return the receiver's hash
-	 * 
-	 * @see #equals
-	 */
-	public int hashCode() {
-		int hashCode = 0;
-		for (int i = 0; i < choiceLimits.length; i++) {
-			long v = Double.doubleToLongBits(choiceLimits[i]);
-			hashCode += (int) (v ^ (v >>> 32)) + choiceFormats[i].hashCode();
-		}
-		return hashCode;
-	}
-
-	/**
-	 * Answers the double value which is closest to the specified double but
-	 * larger.
-	 * 
-	 * @param value
-	 *            a double value
-	 * @return the next larger double value
-	 */
-	public static final double nextDouble(double value) {
-		if (value == Double.POSITIVE_INFINITY) {
+    /**
+     * Answers the double value which is closest to the specified double but
+     * larger.
+     * 
+     * @param value
+     *            a double value
+     * @return the next larger double value
+     */
+    public static final double nextDouble(double value) {
+        if (value == Double.POSITIVE_INFINITY) {
             return value;
         }
-		long bits;
-		// Handle -0.0
-		if (value == 0) {
+        long bits;
+        // Handle -0.0
+        if (value == 0) {
             bits = 0;
         } else {
             bits = Double.doubleToLongBits(value);
         }
-		return Double.longBitsToDouble(value < 0 ? bits - 1 : bits + 1);
-	}
+        return Double.longBitsToDouble(value < 0 ? bits - 1 : bits + 1);
+    }
 
-	/**
-	 * Answers the double value which is closest to the specified double but
-	 * either larger or smaller as specified.
-	 * 
-	 * @param value
-	 *            a double value
-	 * @param increment
-	 *            true to get a larger value, false to get a smaller value
-	 * @return the next larger or smaller double value
-	 */
-	public static double nextDouble(double value, boolean increment) {
-		return increment ? nextDouble(value) : previousDouble(value);
-	}
-
-	/**
-	 * Parse a Double from the specified String starting at the index specified
-	 * by the ParsePosition. The String is compared to the strings of this
-	 * ChoiceFormat and if a match occurs, the answer is the lower bound of the
-	 * corresponding range. If the string is successfully parsed, the index of
-	 * the ParsePosition is updated to the index following the parsed text.
-	 * 
-	 * @param string
-	 *            the String to parse
-	 * @param position
-	 *            the ParsePosition, updated on return with the index following
-	 *            the parsed text, or on error the index is unchanged and the
-	 *            error index is set to the index where the error occurred
-	 * @return a Double resulting from the parse, or Double.NaN if there is an
-	 *         error
-	 */
-	public Number parse(String string, ParsePosition position) {
-		int offset = position.getIndex();
-		for (int i = 0; i < choiceFormats.length; i++) {
-			if (string.startsWith(choiceFormats[i], offset)) {
-				position.setIndex(offset + choiceFormats[i].length());
-				return new Double(choiceLimits[i]);
-			}
-		}
-		position.setErrorIndex(offset);
-		return new Double(Double.NaN);
-	}
-
-	/**
-	 * Answers the double value which is closest to the specified double but
-	 * smaller.
-	 * 
-	 * @param value
-	 *            a double value
-	 * @return the next smaller double value
-	 */
-	public static final double previousDouble(double value) {
-		if (value == Double.NEGATIVE_INFINITY) {
+    /**
+     * Answers the double value which is closest to the specified double but
+     * either larger or smaller as specified.
+     * 
+     * @param value
+     *            a double value
+     * @param increment
+     *            true to get a larger value, false to get a smaller value
+     * @return the next larger or smaller double value
+     */
+    public static double nextDouble(double value, boolean increment) {
+        return increment ? nextDouble(value) : previousDouble(value);
+    }
+
+    /**
+     * Parse a Double from the specified String starting at the index specified
+     * by the ParsePosition. The String is compared to the strings of this
+     * ChoiceFormat and if a match occurs, the answer is the lower bound of the
+     * corresponding range. If the string is successfully parsed, the index of
+     * the ParsePosition is updated to the index following the parsed text.
+     * 
+     * @param string
+     *            the String to parse
+     * @param position
+     *            the ParsePosition, updated on return with the index following
+     *            the parsed text, or on error the index is unchanged and the
+     *            error index is set to the index where the error occurred
+     * @return a Double resulting from the parse, or Double.NaN if there is an
+     *         error
+     */
+    @Override
+    public Number parse(String string, ParsePosition position) {
+        int offset = position.getIndex();
+        for (int i = 0; i < choiceFormats.length; i++) {
+            if (string.startsWith(choiceFormats[i], offset)) {
+                position.setIndex(offset + choiceFormats[i].length());
+                return new Double(choiceLimits[i]);
+            }
+        }
+        position.setErrorIndex(offset);
+        return new Double(Double.NaN);
+    }
+
+    /**
+     * Answers the double value which is closest to the specified double but
+     * smaller.
+     * 
+     * @param value
+     *            a double value
+     * @return the next smaller double value
+     */
+    public static final double previousDouble(double value) {
+        if (value == Double.NEGATIVE_INFINITY) {
             return value;
         }
-		long bits;
-		// Handle 0.0
-		if (value == 0) {
+        long bits;
+        // Handle 0.0
+        if (value == 0) {
             bits = 0x8000000000000000L;
         } else {
             bits = Double.doubleToLongBits(value);
         }
-		return Double.longBitsToDouble(value <= 0 ? bits + 1 : bits - 1);
-	}
+        return Double.longBitsToDouble(value <= 0 ? bits + 1 : bits - 1);
+    }
 
-	/**
-	 * Sets the ranges and associated strings of this ChoiceFormat.
-	 * 
-	 * @param limits
-	 *            an array of double, the ranges are greater or equal to the
-	 *            value in lower index up to less than the value in the next
-	 *            higher index. The bounds of the lowest and highest indexes are
-	 *            negative and positive infinity.
-	 * @param formats
-	 *            the strings associated with the ranges. The lower bound of the
-	 *            range is at the same index as the string.
-	 */
-	public void setChoices(double[] limits, String[] formats) {
-		if (limits.length != formats.length) {
+    /**
+     * Sets the ranges and associated strings of this ChoiceFormat.
+     * 
+     * @param limits
+     *            an array of double, the ranges are greater or equal to the
+     *            value in lower index up to less than the value in the next
+     *            higher index. The bounds of the lowest and highest indexes are
+     *            negative and positive infinity.
+     * @param formats
+     *            the strings associated with the ranges. The lower bound of the
+     *            range is at the same index as the string.
+     */
+    public void setChoices(double[] limits, String[] formats) {
+        if (limits.length != formats.length) {
             throw new IllegalArgumentException();
         }
-		choiceLimits = limits;
-		choiceFormats = formats;
-	}
-
-	private int skipWhitespace(String string, int index) {
-		int length = string.length();
-		while (index < length && Character.isWhitespace(string.charAt(index))) {
+        choiceLimits = limits;
+        choiceFormats = formats;
+    }
+
+    private int skipWhitespace(String string, int index) {
+        int length = string.length();
+        while (index < length && Character.isWhitespace(string.charAt(index))) {
             index++;
         }
-		return index;
-	}
+        return index;
+    }
 
-	/**
-	 * Answers the pattern of this ChoiceFormat which specified the ranges and
-	 * their associated strings.
-	 * 
-	 * @return the pattern
-	 */
-	public String toPattern() {
-		StringBuffer buffer = new StringBuffer();
-		for (int i = 0; i < choiceLimits.length; i++) {
+    /**
+     * Answers the pattern of this ChoiceFormat which specified the ranges and
+     * their associated strings.
+     * 
+     * @return the pattern
+     */
+    public String toPattern() {
+        StringBuffer buffer = new StringBuffer();
+        for (int i = 0; i < choiceLimits.length; i++) {
             if (i != 0) {
                 buffer.append('|');
             }
-			String previous = String.valueOf(previousDouble(choiceLimits[i]));
-			String limit = String.valueOf(choiceLimits[i]);
-			if (previous.length() < limit.length()) {
-				buffer.append(previous);
-				buffer.append('<');
-			} else {
-				buffer.append(limit);
-				buffer.append('#');
-			}
-			boolean quote = (choiceFormats[i].indexOf('|') != -1);
-			if (quote) {
+            String previous = String.valueOf(previousDouble(choiceLimits[i]));
+            String limit = String.valueOf(choiceLimits[i]);
+            if (previous.length() < limit.length()) {
+                buffer.append(previous);
+                buffer.append('<');
+            } else {
+                buffer.append(limit);
+                buffer.append('#');
+            }
+            boolean quote = (choiceFormats[i].indexOf('|') != -1);
+            if (quote) {
                 buffer.append('\'');
             }
-			buffer.append(choiceFormats[i]);
-			if (quote) {
+            buffer.append(choiceFormats[i]);
+            if (quote) {
                 buffer.append('\'');
             }
-		}
-		return buffer.toString();
-	}
+        }
+        return buffer.toString();
+    }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/CollationElementIterator.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/CollationElementIterator.java?view=diff&rev=462605&r1=462604&r2=462605
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/CollationElementIterator.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/CollationElementIterator.java Tue Oct 10 15:18:35 2006
@@ -17,14 +17,13 @@
 
 package java.text;
 
-
 /**
  * <p>
  * <code>CollationElementIterator</code> is created by a
- * <code>RuleBasedCollator</code> to iterate through a string. The return result
- * of each iteration is a 32-bit collation element that defines the ordering
- * priority of the next character or sequence of characters in the source
- * string.
+ * <code>RuleBasedCollator</code> to iterate through a string. The return
+ * result of each iteration is a 32-bit collation element that defines the
+ * ordering priority of the next character or sequence of characters in the
+ * source string.
  * </p>
  * <p>
  * For illustration, consider the following in Spanish:
@@ -72,177 +71,178 @@
  */
 public final class CollationElementIterator {
 
-	/**
-	 * This constant is returned by the iterator in the methods
-	 * <code>next()</code> and <code>previous()</code> when the end or the
-	 * beginning of the source string has been reached, and there are no more
-	 * valid collation elements to return.
-	 */
-	public static final int NULLORDER = -1;
-
-	private com.ibm.icu.text.CollationElementIterator icuIterator;
-
-	CollationElementIterator(com.ibm.icu.text.CollationElementIterator iterator) {
-		this.icuIterator = iterator;
-	}
-
-	/**
-	 * Obtains the maximum length of any expansion sequence that ends with the
-	 * specified collation element. If there is no expansion with this collation
-	 * element as the last element, returns <code>1</code>.
-	 * 
-	 * @param order
-	 *            a collation element that has been previously obtained from
-	 *            a call to either the {@link #next()} or {@link #previous()} 
-	 *            method. 
-	 * @return the maximum length of any expansion sequence ending with the
-	 *         specified collation element.
-	 */
-	public int getMaxExpansion(int order) {
-		return this.icuIterator.getMaxExpansion(order);
-	}
-
-	/**
-	 * Obtains the character offset in the source string corresponding to the
-	 * next collation element. This value could be any of: <ui>
-	 * <li>The index of the first character in the source string that matches
-	 * the value of the next collation element. (This means that if
-	 * setOffset(offset) sets the index in the middle of a contraction,
-	 * getOffset() returns the index of the first character in the contraction,
-	 * which may not be equal to the original offset that was set. Hence calling
-	 * getOffset() immediately after setOffset(offset) does not guarantee that
-	 * the original offset set will be returned.)</li>
-	 * <li>If normalization is on, the index of the immediate subsequent
-	 * character, or composite character with the first character, having a
-	 * combining class of 0.</li>
-	 * <li>The length of the source string, if iteration has reached the end.
-	 * </li>
-	 * <ui>
-	 * 
-	 * @return The position of the collation element in the source string that
-	 * will be returned in the next invocation of the {@link #next()} method.
-	 */
-	public int getOffset() {
-		return this.icuIterator.getOffset();
-	}
-
-	/**
-	 * Obtains the next collation element in the source string.
-	 * 
-	 * @return the next collation element or <code>NULLORDER</code> if the end
-	 *         of the iteration has been reached.
-	 */
-	public int next() {
-		return this.icuIterator.next();
-	}
-
-	/**
-	 * Obtains the previous collation element in the source string.
-	 * 
-	 * @return the previous collation element, or <code>NULLORDER</code> when
-	 *         the start of the iteration has been reached.
-	 */
-	public int previous() {
-		return this.icuIterator.previous();
-	}
-
-	/**
-	 * Obtains the primary order of the specified collation element, i.e. the
-	 * first 16 bits. This value is unsigned.
-	 * 
-	 * @param order
-	 * @return the element's 16 bits primary order.
-	 */
-	public static final int primaryOrder(int order) {
-		return com.ibm.icu.text.CollationElementIterator.primaryOrder(order);
-	}
-
-	/**
-	 * Repositions the cursor to point at the first element of the current
-	 * string. The next call to <code>next()</code> or <code>previous()</code>
-	 * will return the first and last collation element in the string,
-	 * respectively.
-	 * <p>
-	 * If the <code>RuleBasedCollator</code> used by this iterator has had its
-	 * attributes changed, calling <code>reset()</code> will reinitialize the
-	 * iterator to use the new attributes.
-	 * </p>
-	 */
-	public void reset() {
-		this.icuIterator.reset();
-	}
-
-	/**
-	 * Obtains the secondary order of the specified collation element, i.e. the
-	 * 16th to 23th bits, inclusive. This value is unsigned.
-	 * 
-	 * @param order
-	 * @return the 8 bit secondary order of the element
-	 */
-	public static final short secondaryOrder(int order) {
-		return (short) com.ibm.icu.text.CollationElementIterator
-				.secondaryOrder(order);
-	}
-
-	/**
-	 * Points the iterator at the collation element associated with the
-	 * character in the source string which is found at the supplied offset.
-	 * After this call completes, an invocation of the {@link #next()} method
-	 * will return this collation element.
-	 * <p>
-	 * If <code>newOffset</code> corresponds to a character which is part of a
-	 * sequence that maps to a single collation element the iterator is adjusted
-	 * to the start of that sequence. As a result of this, any subsequent call
-	 * made to <code>getOffset()</code> may not return the same value set by
-	 * this method.
-	 * </p>
-	 * <p>
-	 * If the decomposition mode is on, and offset is in the middle of a
-	 * decomposible range of source text, the iterator may not return a correct
-	 * result for the next forwards or backwards iteration. The user must ensure
-	 * that the offset is not in the middle of a decomposible range.
-	 * </p>
-	 * 
-	 * @param newOffset
-	 *            the character offset into the original source string to set.
-	 *            Note that this is not an offset into the corresponding
-	 *            sequence of collation elements.
-	 */
-	public void setOffset(int newOffset) {
-		this.icuIterator.setOffset(newOffset);
-	}
-
-	/**
-	 * Sets a new source string interator for iteration, and reset the offset to
-	 * the beginning of the text.
-	 * 
-	 * @param source
-	 *            the new source string iterator for iteration.
-	 */
-	public void setText(CharacterIterator source) {
-		this.icuIterator.setText(source);
-	}
-
-	/**
-	 * Sets a new source string for iteration, and reset the offset to the
-	 * beginning of the text.
-	 * 
-	 * @param source
-	 *            the new source string for iteration
-	 */
-	public void setText(String source) {
-		this.icuIterator.setText(source);
-	}
-
-	/**
-	 * Obtains the tertiary order of the specified collation element, i.e. the
-	 * last 8 bits. This value is unsigned.
-	 * 
-	 * @param order
-	 * @return the 8 bits tertiary order of the element
-	 */
-	public static final short tertiaryOrder(int order) {
-		return (short) com.ibm.icu.text.CollationElementIterator
-				.tertiaryOrder(order);
-	}
+    /**
+     * This constant is returned by the iterator in the methods
+     * <code>next()</code> and <code>previous()</code> when the end or the
+     * beginning of the source string has been reached, and there are no more
+     * valid collation elements to return.
+     */
+    public static final int NULLORDER = -1;
+
+    private com.ibm.icu.text.CollationElementIterator icuIterator;
+
+    CollationElementIterator(com.ibm.icu.text.CollationElementIterator iterator) {
+        this.icuIterator = iterator;
+    }
+
+    /**
+     * Obtains the maximum length of any expansion sequence that ends with the
+     * specified collation element. If there is no expansion with this collation
+     * element as the last element, returns <code>1</code>.
+     * 
+     * @param order
+     *            a collation element that has been previously obtained from a
+     *            call to either the {@link #next()} or {@link #previous()}
+     *            method.
+     * @return the maximum length of any expansion sequence ending with the
+     *         specified collation element.
+     */
+    public int getMaxExpansion(int order) {
+        return this.icuIterator.getMaxExpansion(order);
+    }
+
+    /**
+     * Obtains the character offset in the source string corresponding to the
+     * next collation element. This value could be any of: <ui>
+     * <li>The index of the first character in the source string that matches
+     * the value of the next collation element. (This means that if
+     * setOffset(offset) sets the index in the middle of a contraction,
+     * getOffset() returns the index of the first character in the contraction,
+     * which may not be equal to the original offset that was set. Hence calling
+     * getOffset() immediately after setOffset(offset) does not guarantee that
+     * the original offset set will be returned.)</li>
+     * <li>If normalization is on, the index of the immediate subsequent
+     * character, or composite character with the first character, having a
+     * combining class of 0.</li>
+     * <li>The length of the source string, if iteration has reached the end.
+     * </li>
+     * <ui>
+     * 
+     * @return The position of the collation element in the source string that
+     *         will be returned in the next invocation of the {@link #next()}
+     *         method.
+     */
+    public int getOffset() {
+        return this.icuIterator.getOffset();
+    }
+
+    /**
+     * Obtains the next collation element in the source string.
+     * 
+     * @return the next collation element or <code>NULLORDER</code> if the end
+     *         of the iteration has been reached.
+     */
+    public int next() {
+        return this.icuIterator.next();
+    }
+
+    /**
+     * Obtains the previous collation element in the source string.
+     * 
+     * @return the previous collation element, or <code>NULLORDER</code> when
+     *         the start of the iteration has been reached.
+     */
+    public int previous() {
+        return this.icuIterator.previous();
+    }
+
+    /**
+     * Obtains the primary order of the specified collation element, i.e. the
+     * first 16 bits. This value is unsigned.
+     * 
+     * @param order
+     * @return the element's 16 bits primary order.
+     */
+    public static final int primaryOrder(int order) {
+        return com.ibm.icu.text.CollationElementIterator.primaryOrder(order);
+    }
+
+    /**
+     * Repositions the cursor to point at the first element of the current
+     * string. The next call to <code>next()</code> or <code>previous()</code>
+     * will return the first and last collation element in the string,
+     * respectively.
+     * <p>
+     * If the <code>RuleBasedCollator</code> used by this iterator has had its
+     * attributes changed, calling <code>reset()</code> will reinitialize the
+     * iterator to use the new attributes.
+     * </p>
+     */
+    public void reset() {
+        this.icuIterator.reset();
+    }
+
+    /**
+     * Obtains the secondary order of the specified collation element, i.e. the
+     * 16th to 23th bits, inclusive. This value is unsigned.
+     * 
+     * @param order
+     * @return the 8 bit secondary order of the element
+     */
+    public static final short secondaryOrder(int order) {
+        return (short) com.ibm.icu.text.CollationElementIterator
+                .secondaryOrder(order);
+    }
+
+    /**
+     * Points the iterator at the collation element associated with the
+     * character in the source string which is found at the supplied offset.
+     * After this call completes, an invocation of the {@link #next()} method
+     * will return this collation element.
+     * <p>
+     * If <code>newOffset</code> corresponds to a character which is part of a
+     * sequence that maps to a single collation element the iterator is adjusted
+     * to the start of that sequence. As a result of this, any subsequent call
+     * made to <code>getOffset()</code> may not return the same value set by
+     * this method.
+     * </p>
+     * <p>
+     * If the decomposition mode is on, and offset is in the middle of a
+     * decomposible range of source text, the iterator may not return a correct
+     * result for the next forwards or backwards iteration. The user must ensure
+     * that the offset is not in the middle of a decomposible range.
+     * </p>
+     * 
+     * @param newOffset
+     *            the character offset into the original source string to set.
+     *            Note that this is not an offset into the corresponding
+     *            sequence of collation elements.
+     */
+    public void setOffset(int newOffset) {
+        this.icuIterator.setOffset(newOffset);
+    }
+
+    /**
+     * Sets a new source string interator for iteration, and reset the offset to
+     * the beginning of the text.
+     * 
+     * @param source
+     *            the new source string iterator for iteration.
+     */
+    public void setText(CharacterIterator source) {
+        this.icuIterator.setText(source);
+    }
+
+    /**
+     * Sets a new source string for iteration, and reset the offset to the
+     * beginning of the text.
+     * 
+     * @param source
+     *            the new source string for iteration
+     */
+    public void setText(String source) {
+        this.icuIterator.setText(source);
+    }
+
+    /**
+     * Obtains the tertiary order of the specified collation element, i.e. the
+     * last 8 bits. This value is unsigned.
+     * 
+     * @param order
+     * @return the 8 bits tertiary order of the element
+     */
+    public static final short tertiaryOrder(int order) {
+        return (short) com.ibm.icu.text.CollationElementIterator
+                .tertiaryOrder(order);
+    }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/CollationKey.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/CollationKey.java?view=diff&rev=462605&r1=462604&r2=462605
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/CollationKey.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/CollationKey.java Tue Oct 10 15:18:35 2006
@@ -17,7 +17,6 @@
 
 package java.text;
 
-
 /**
  * CollationKey represents the collation order of a particular String for a
  * specific Collator. CollationKeys can be compared to determine the relative
@@ -26,76 +25,79 @@
  */
 public final class CollationKey implements Comparable<CollationKey> {
 
-	private String source;
+    private String source;
 
-	private com.ibm.icu.text.CollationKey icuKey;
+    private com.ibm.icu.text.CollationKey icuKey;
 
-	CollationKey(String source, com.ibm.icu.text.CollationKey key) {
-		this.source = source;
-		this.icuKey = key;
-	}
-
-	/**
-	 * Compare the receiver to the specified CollationKey to determine the
-	 * relative ordering.
-	 * 
-	 * @param value
-	 *            a CollationKey
-	 * @return an int < 0 if this CollationKey is less than the specified
-	 *         CollationKey, 0 if they are equal, and > 0 if this CollationKey
-	 *         is greater
-	 */
-	public int compareTo(CollationKey value) {
-		return icuKey.compareTo(value.icuKey);
-	}
-
-	/**
-	 * Compares the specified object to this CollationKey and answer if they are
-	 * equal. The object must be an instance of CollationKey and have the same
-	 * source string and collation key. The instances of CollationKey must have
-	 * been created by the same Collator.
-	 * 
-	 * @param object
-	 *            the object to compare with this object
-	 * @return true if the specified object is equal to this CollationKey, false
-	 *         otherwise
-	 * 
-	 * @see #hashCode
-	 */
-	public boolean equals(Object object) {
-		if (!(object instanceof CollationKey))
-			return false;
-		CollationKey collationKey = (CollationKey) object;
-		return icuKey.equals(collationKey.icuKey);
-	}
-
-	/**
-	 * Answer the String from which this CollationKey was created.
-	 * 
-	 * @return a String
-	 */
-	public String getSourceString() {
-		return this.source;
-	}
-
-	/**
-	 * Answers an integer hash code for the receiver. Objects which are equal
-	 * answer the same value for this method.
-	 * 
-	 * @return the receiver's hash
-	 * 
-	 * @see #equals
-	 */
-	public int hashCode() {
-		return icuKey.hashCode();
-	}
-
-	/**
-	 * Answer the collation key as a byte array.
-	 * 
-	 * @return an array of bytes
-	 */
-	public byte[] toByteArray() {
-		return icuKey.toByteArray();
-	}
+    CollationKey(String source, com.ibm.icu.text.CollationKey key) {
+        this.source = source;
+        this.icuKey = key;
+    }
+
+    /**
+     * Compare the receiver to the specified CollationKey to determine the
+     * relative ordering.
+     * 
+     * @param value
+     *            a CollationKey
+     * @return an int < 0 if this CollationKey is less than the specified
+     *         CollationKey, 0 if they are equal, and > 0 if this CollationKey
+     *         is greater
+     */
+    public int compareTo(CollationKey value) {
+        return icuKey.compareTo(value.icuKey);
+    }
+
+    /**
+     * Compares the specified object to this CollationKey and answer if they are
+     * equal. The object must be an instance of CollationKey and have the same
+     * source string and collation key. The instances of CollationKey must have
+     * been created by the same Collator.
+     * 
+     * @param object
+     *            the object to compare with this object
+     * @return true if the specified object is equal to this CollationKey, false
+     *         otherwise
+     * 
+     * @see #hashCode
+     */
+    @Override
+    public boolean equals(Object object) {
+        if (!(object instanceof CollationKey)) {
+            return false;
+        }
+        CollationKey collationKey = (CollationKey) object;
+        return icuKey.equals(collationKey.icuKey);
+    }
+
+    /**
+     * Answer the String from which this CollationKey was created.
+     * 
+     * @return a String
+     */
+    public String getSourceString() {
+        return this.source;
+    }
+
+    /**
+     * Answers an integer hash code for the receiver. Objects which are equal
+     * answer the same value for this method.
+     * 
+     * @return the receiver's hash
+     * 
+     * @see #equals
+     */
+    @Override
+    public int hashCode() {
+        return icuKey.hashCode();
+    }
+
+    /**
+     * Answer the collation key as a byte array.
+     * 
+     * @return an array of bytes
+     */
+    public byte[] toByteArray() {
+        return icuKey.toByteArray();
+    }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Collator.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Collator.java?view=diff&rev=462605&r1=462604&r2=462605
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Collator.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Collator.java Tue Oct 10 15:18:35 2006
@@ -17,7 +17,6 @@
 
 package java.text;
 
-
 import java.security.AccessController;
 import java.util.Comparator;
 import java.util.Locale;
@@ -32,332 +31,335 @@
  */
 public abstract class Collator implements Comparator<Object>, Cloneable {
 
-	static final int EQUAL = 0;
+    static final int EQUAL = 0;
 
-	static final int GREATER = 1;
+    static final int GREATER = 1;
 
-	static final int LESS = -1;
+    static final int LESS = -1;
 
-	/**
-	 * Constant used to specify the decomposition rule.
-	 */
-	public static final int NO_DECOMPOSITION = 0;
-
-	/**
-	 * Constant used to specify the decomposition rule.
-	 */
-	public static final int CANONICAL_DECOMPOSITION = 1;
-
-	/**
-	 * Constant used to specify the decomposition rule.
-	 */
-	public static final int FULL_DECOMPOSITION = 2;
-
-	/**
-	 * Constant used to specify the collation strength.
-	 */
-	public static final int PRIMARY = 0;
-
-	/**
-	 * Constant used to specify the collation strength.
-	 */
-	public static final int SECONDARY = 1;
-
-	/**
-	 * Constant used to specify the collation strength.
-	 */
-	public static final int TERTIARY = 2;
-
-	/**
-	 * Constant used to specify the collation strength.
-	 */
-	public static final int IDENTICAL = 3;
-
-	private static int CACHE_SIZE;
-
-	static {
-		// CACHE_SIZE includes key and value, so needs to be double
-		String cacheSize = AccessController.doPrivileged(new PriviAction<String>(
-                "collator.cache")); //$NON-NLS-1$
-		if (cacheSize != null) {
-			try {
-				CACHE_SIZE = Integer.parseInt(cacheSize);
-			} catch (NumberFormatException e) {
-				CACHE_SIZE = 6;
-			}
-		} else {
+    /**
+     * Constant used to specify the decomposition rule.
+     */
+    public static final int NO_DECOMPOSITION = 0;
+
+    /**
+     * Constant used to specify the decomposition rule.
+     */
+    public static final int CANONICAL_DECOMPOSITION = 1;
+
+    /**
+     * Constant used to specify the decomposition rule.
+     */
+    public static final int FULL_DECOMPOSITION = 2;
+
+    /**
+     * Constant used to specify the collation strength.
+     */
+    public static final int PRIMARY = 0;
+
+    /**
+     * Constant used to specify the collation strength.
+     */
+    public static final int SECONDARY = 1;
+
+    /**
+     * Constant used to specify the collation strength.
+     */
+    public static final int TERTIARY = 2;
+
+    /**
+     * Constant used to specify the collation strength.
+     */
+    public static final int IDENTICAL = 3;
+
+    private static int CACHE_SIZE;
+
+    static {
+        // CACHE_SIZE includes key and value, so needs to be double
+        String cacheSize = AccessController
+                .doPrivileged(new PriviAction<String>("collator.cache")); //$NON-NLS-1$
+        if (cacheSize != null) {
+            try {
+                CACHE_SIZE = Integer.parseInt(cacheSize);
+            } catch (NumberFormatException e) {
+                CACHE_SIZE = 6;
+            }
+        } else {
             CACHE_SIZE = 6;
         }
-	}
-    
+    }
+
     private static Vector<Collator> cache = new Vector<Collator>(CACHE_SIZE);
-    
+
     // Wrapper class of ICU4J Collator
     com.ibm.icu.text.Collator icuColl;
 
-	Collator(com.ibm.icu.text.Collator wrapper) {
-		this.icuColl = wrapper;
-	}
-
-	/**
-	 * Constructs a new instance of this Collator.
-	 */
-	protected Collator() {
-		super();
-	}
-
-	/**
-	 * Answers a new Collator with the same decomposition rule and strength
-	 * value as this Collator.
-	 * 
-	 * @return a shallow copy of this Collator
-	 * @see java.lang.Cloneable
-	 */
-	public Object clone() {
-		try {
-			Collator clone = (Collator) super.clone();
-			clone.icuColl = (com.ibm.icu.text.Collator) this.icuColl.clone();
-			return clone;
-		} catch (CloneNotSupportedException e) {
-			return null;
-		}
-	}
-
-	/**
-	 * Compares the two objects to determine their relative ordering. The
-	 * objects must be Strings.
-	 * 
-	 * @param object1
-	 *            the first String to compare
-	 * @param object2
-	 *            the second String to compare
-	 * @return an int < 0 if object1 is less than object2, 0 if they are equal,
-	 *         and > 0 if object1 is greater than object2
-	 * 
-	 * @exception ClassCastException
-	 *                when the objects are not Strings
-	 */
-	public int compare(Object object1, Object object2) {
-		return compare((String) object1, (String) object2);
-	}
-
-	/**
-	 * Compares the two Strings to determine their relative ordering.
-	 * 
-	 * @param string1
-	 *            the first String to compare
-	 * @param string2
-	 *            the second String to compare
-	 * @return an int < 0 if string1 is less than string2, 0 if they are equal,
-	 *         and > 0 if string1 is greater than string2
-	 */
-	public abstract int compare(String string1, String string2);
-
-	/**
-	 * Compares the specified object to this Collator and answer if they are
-	 * equal. The object must be an instance of Collator and have the same
-	 * strength and decomposition values.
-	 * 
-	 * @param object
-	 *            the object to compare with this object
-	 * @return true if the specified object is equal to this Collator, false
-	 *         otherwise
-	 * 
-	 * @see #hashCode
-	 */
-	public boolean equals(Object object) {
-		if (!(object instanceof Collator)) {
+    Collator(com.ibm.icu.text.Collator wrapper) {
+        this.icuColl = wrapper;
+    }
+
+    /**
+     * Constructs a new instance of this Collator.
+     */
+    protected Collator() {
+        super();
+    }
+
+    /**
+     * Answers a new Collator with the same decomposition rule and strength
+     * value as this Collator.
+     * 
+     * @return a shallow copy of this Collator
+     * @see java.lang.Cloneable
+     */
+    @Override
+    public Object clone() {
+        try {
+            Collator clone = (Collator) super.clone();
+            clone.icuColl = (com.ibm.icu.text.Collator) this.icuColl.clone();
+            return clone;
+        } catch (CloneNotSupportedException e) {
+            return null;
+        }
+    }
+
+    /**
+     * Compares the two objects to determine their relative ordering. The
+     * objects must be Strings.
+     * 
+     * @param object1
+     *            the first String to compare
+     * @param object2
+     *            the second String to compare
+     * @return an int < 0 if object1 is less than object2, 0 if they are equal,
+     *         and > 0 if object1 is greater than object2
+     * 
+     * @exception ClassCastException
+     *                when the objects are not Strings
+     */
+    public int compare(Object object1, Object object2) {
+        return compare((String) object1, (String) object2);
+    }
+
+    /**
+     * Compares the two Strings to determine their relative ordering.
+     * 
+     * @param string1
+     *            the first String to compare
+     * @param string2
+     *            the second String to compare
+     * @return an int < 0 if string1 is less than string2, 0 if they are equal,
+     *         and > 0 if string1 is greater than string2
+     */
+    public abstract int compare(String string1, String string2);
+
+    /**
+     * Compares the specified object to this Collator and answer if they are
+     * equal. The object must be an instance of Collator and have the same
+     * strength and decomposition values.
+     * 
+     * @param object
+     *            the object to compare with this object
+     * @return true if the specified object is equal to this Collator, false
+     *         otherwise
+     * 
+     * @see #hashCode
+     */
+    @Override
+    public boolean equals(Object object) {
+        if (!(object instanceof Collator)) {
             return false;
         }
-		Collator collator = (Collator) object;
-		return this.icuColl == null ? collator.icuColl == null : this.icuColl
-				.equals(collator.icuColl);
-	}
-
-	/**
-	 * Compares the two Strings using the collation rules to determine if they
-	 * are equal.
-	 * 
-	 * @param string1
-	 *            the first String to compare
-	 * @param string2
-	 *            the second String to compare
-	 * @return true if the strings are equal using the collation rules, false
-	 *         otherwise
-	 */
-	public boolean equals(String string1, String string2) {
-		return compare(string1, string2) == 0;
-	}
-
-	/**
-	 * Gets the list of installed Locales which support Collator.
-	 * 
-	 * @return an array of Locale
-	 */
-	public static Locale[] getAvailableLocales() {
-		return com.ibm.icu.text.Collator.getAvailableLocales();
-	}
-
-	/**
-	 * Answers a CollationKey for the specified String for this Collator with
-	 * the current decomposition rule and strength value.
-	 * 
-	 * @param string
-	 *            the collation key.
-	 * @return a CollationKey
-	 */
-	public abstract CollationKey getCollationKey(String string);
-
-	/**
-	 * Answers the decomposition rule for this Collator.
-	 * 
-	 * @return the decomposition rule, either NO_DECOMPOSITION,
-	 *         CANONICAL_DECOMPOSITION or FULL_DECOMPOSITION
-	 */
-	public int getDecomposition() {
-		return decompositionMode_ICU_Java(this.icuColl.getDecomposition());
-	}
-
-	/**
-	 * Answers a Collator instance which is appropriate for the default Locale.
-	 * 
-	 * @return a Collator
-	 */
-	public static Collator getInstance() {
-		return getInstance(Locale.getDefault());
-	}
-
-	/**
-	 * Answers a Collator instance which is appropriate for the specified
-	 * Locale.
-	 * 
-	 * @param locale
-	 *            the Locale
-	 * @return a Collator
-	 */
-	public static Collator getInstance(Locale locale) {
-		String key = locale.toString();
-		for (int i = cache.size() - 1; i >= 0; i -= 2) {
-			if (cache.elementAt(i).equals(key)) {
+        Collator collator = (Collator) object;
+        return this.icuColl == null ? collator.icuColl == null : this.icuColl
+                .equals(collator.icuColl);
+    }
+
+    /**
+     * Compares the two Strings using the collation rules to determine if they
+     * are equal.
+     * 
+     * @param string1
+     *            the first String to compare
+     * @param string2
+     *            the second String to compare
+     * @return true if the strings are equal using the collation rules, false
+     *         otherwise
+     */
+    public boolean equals(String string1, String string2) {
+        return compare(string1, string2) == 0;
+    }
+
+    /**
+     * Gets the list of installed Locales which support Collator.
+     * 
+     * @return an array of Locale
+     */
+    public static Locale[] getAvailableLocales() {
+        return com.ibm.icu.text.Collator.getAvailableLocales();
+    }
+
+    /**
+     * Answers a CollationKey for the specified String for this Collator with
+     * the current decomposition rule and strength value.
+     * 
+     * @param string
+     *            the collation key.
+     * @return a CollationKey
+     */
+    public abstract CollationKey getCollationKey(String string);
+
+    /**
+     * Answers the decomposition rule for this Collator.
+     * 
+     * @return the decomposition rule, either NO_DECOMPOSITION,
+     *         CANONICAL_DECOMPOSITION or FULL_DECOMPOSITION
+     */
+    public int getDecomposition() {
+        return decompositionMode_ICU_Java(this.icuColl.getDecomposition());
+    }
+
+    /**
+     * Answers a Collator instance which is appropriate for the default Locale.
+     * 
+     * @return a Collator
+     */
+    public static Collator getInstance() {
+        return getInstance(Locale.getDefault());
+    }
+
+    /**
+     * Answers a Collator instance which is appropriate for the specified
+     * Locale.
+     * 
+     * @param locale
+     *            the Locale
+     * @return a Collator
+     */
+    public static Collator getInstance(Locale locale) {
+        String key = locale.toString();
+        for (int i = cache.size() - 1; i >= 0; i -= 2) {
+            if (cache.elementAt(i).equals(key)) {
                 return (Collator) (cache.elementAt(i - 1)).clone();
             }
-		}
+        }
 
-		return new RuleBasedCollator(com.ibm.icu.text.Collator
-				.getInstance(locale));
-	}
-
-	/**
-	 * Answers the strength value for this Collator.
-	 * 
-	 * @return the strength value, either PRIMARY, SECONDARY, TERTIARY, or
-	 *         IDENTICAL
-	 */
-	public int getStrength() {
-		return strength_ICU_Java(this.icuColl.getStrength());
-	}
-
-	/**
-	 * Answers an integer hash code for the receiver. Objects which are equal
-	 * answer the same value for this method.
-	 * 
-	 * @return the receiver's hash
-	 * 
-	 * @see #equals(Object)
-	 * @see #equals(String, String)
-	 */
-	public abstract int hashCode();
-
-	/**
-	 * Sets the decomposition rule for this Collator.
-	 * 
-	 * @param value
-	 *            the decomposition rule, either NO_DECOMPOSITION,
-	 *            CANONICAL_DECOMPOSITION or FULL_DECOMPOSITION
-	 * 
-	 * @exception IllegalArgumentException
-	 *                when the decomposition rule is not valid
-	 */
-	public void setDecomposition(int value) {
-		this.icuColl.setDecomposition(decompositionMode_Java_ICU(value));
-	}
-
-	/**
-	 * Sets the strength value for this Collator.
-	 * 
-	 * @param value
-	 *            the strength value, either PRIMARY, SECONDARY, TERTIARY, or
-	 *            IDENTICAL
-	 * 
-	 * @exception IllegalArgumentException
-	 *                when the strength value is not valid
-	 */
-	public void setStrength(int value) {
-		this.icuColl.setStrength(strength_Java_ICU(value));
-	}
-
-	private int decompositionMode_Java_ICU(int mode) {
-		int icuDecomp = mode;
-		switch (mode) {
-		case Collator.CANONICAL_DECOMPOSITION:
-			icuDecomp = com.ibm.icu.text.Collator.CANONICAL_DECOMPOSITION;
-			break;
-		case Collator.NO_DECOMPOSITION:
-			icuDecomp = com.ibm.icu.text.Collator.NO_DECOMPOSITION;
-			break;
-		}
-		return icuDecomp;
-	}
-
-	private int decompositionMode_ICU_Java(int mode) {
-		int javaMode = mode;
-		switch (mode) {
-		case com.ibm.icu.text.Collator.NO_DECOMPOSITION:
-			javaMode = Collator.NO_DECOMPOSITION;
-			break;
-		case com.ibm.icu.text.Collator.CANONICAL_DECOMPOSITION:
-			javaMode = Collator.CANONICAL_DECOMPOSITION;
-			break;
-		}
-		return javaMode;
-	}
-
-	private int strength_Java_ICU(int value) {
-		int icuValue = value;
-		switch (value) {
-		case Collator.PRIMARY:
-			icuValue = com.ibm.icu.text.Collator.PRIMARY;
-			break;
-		case Collator.SECONDARY:
-			icuValue = com.ibm.icu.text.Collator.SECONDARY;
-			break;
-		case Collator.TERTIARY:
-			icuValue = com.ibm.icu.text.Collator.TERTIARY;
-			break;
-		case Collator.IDENTICAL:
-			icuValue = com.ibm.icu.text.Collator.IDENTICAL;
-			break;
-		}
-		return icuValue;
-
-	}
-
-	private int strength_ICU_Java(int value) {
-		int javaValue = value;
-		switch (value) {
-		case com.ibm.icu.text.Collator.PRIMARY:
-			javaValue = Collator.PRIMARY;
-			break;
-		case com.ibm.icu.text.Collator.SECONDARY:
-			javaValue = Collator.SECONDARY;
-			break;
-		case com.ibm.icu.text.Collator.TERTIARY:
-			javaValue = Collator.TERTIARY;
-			break;
-		case com.ibm.icu.text.Collator.IDENTICAL:
-			javaValue = Collator.IDENTICAL;
-			break;
-		}
-		return javaValue;
-	}
+        return new RuleBasedCollator(com.ibm.icu.text.Collator
+                .getInstance(locale));
+    }
+
+    /**
+     * Answers the strength value for this Collator.
+     * 
+     * @return the strength value, either PRIMARY, SECONDARY, TERTIARY, or
+     *         IDENTICAL
+     */
+    public int getStrength() {
+        return strength_ICU_Java(this.icuColl.getStrength());
+    }
+
+    /**
+     * Answers an integer hash code for the receiver. Objects which are equal
+     * answer the same value for this method.
+     * 
+     * @return the receiver's hash
+     * 
+     * @see #equals(Object)
+     * @see #equals(String, String)
+     */
+    @Override
+    public abstract int hashCode();
+
+    /**
+     * Sets the decomposition rule for this Collator.
+     * 
+     * @param value
+     *            the decomposition rule, either NO_DECOMPOSITION,
+     *            CANONICAL_DECOMPOSITION or FULL_DECOMPOSITION
+     * 
+     * @exception IllegalArgumentException
+     *                when the decomposition rule is not valid
+     */
+    public void setDecomposition(int value) {
+        this.icuColl.setDecomposition(decompositionMode_Java_ICU(value));
+    }
+
+    /**
+     * Sets the strength value for this Collator.
+     * 
+     * @param value
+     *            the strength value, either PRIMARY, SECONDARY, TERTIARY, or
+     *            IDENTICAL
+     * 
+     * @exception IllegalArgumentException
+     *                when the strength value is not valid
+     */
+    public void setStrength(int value) {
+        this.icuColl.setStrength(strength_Java_ICU(value));
+    }
+
+    private int decompositionMode_Java_ICU(int mode) {
+        int icuDecomp = mode;
+        switch (mode) {
+            case Collator.CANONICAL_DECOMPOSITION:
+                icuDecomp = com.ibm.icu.text.Collator.CANONICAL_DECOMPOSITION;
+                break;
+            case Collator.NO_DECOMPOSITION:
+                icuDecomp = com.ibm.icu.text.Collator.NO_DECOMPOSITION;
+                break;
+        }
+        return icuDecomp;
+    }
+
+    private int decompositionMode_ICU_Java(int mode) {
+        int javaMode = mode;
+        switch (mode) {
+            case com.ibm.icu.text.Collator.NO_DECOMPOSITION:
+                javaMode = Collator.NO_DECOMPOSITION;
+                break;
+            case com.ibm.icu.text.Collator.CANONICAL_DECOMPOSITION:
+                javaMode = Collator.CANONICAL_DECOMPOSITION;
+                break;
+        }
+        return javaMode;
+    }
+
+    private int strength_Java_ICU(int value) {
+        int icuValue = value;
+        switch (value) {
+            case Collator.PRIMARY:
+                icuValue = com.ibm.icu.text.Collator.PRIMARY;
+                break;
+            case Collator.SECONDARY:
+                icuValue = com.ibm.icu.text.Collator.SECONDARY;
+                break;
+            case Collator.TERTIARY:
+                icuValue = com.ibm.icu.text.Collator.TERTIARY;
+                break;
+            case Collator.IDENTICAL:
+                icuValue = com.ibm.icu.text.Collator.IDENTICAL;
+                break;
+        }
+        return icuValue;
+
+    }
+
+    private int strength_ICU_Java(int value) {
+        int javaValue = value;
+        switch (value) {
+            case com.ibm.icu.text.Collator.PRIMARY:
+                javaValue = Collator.PRIMARY;
+                break;
+            case com.ibm.icu.text.Collator.SECONDARY:
+                javaValue = Collator.SECONDARY;
+                break;
+            case com.ibm.icu.text.Collator.TERTIARY:
+                javaValue = Collator.TERTIARY;
+                break;
+            case com.ibm.icu.text.Collator.IDENTICAL:
+                javaValue = Collator.IDENTICAL;
+                break;
+        }
+        return javaValue;
+    }
 }



Mime
View raw message