From: Michael Koch Date: Wed, 15 Oct 2003 14:49:30 +0000 (+0000) Subject: 2003-10-15 Michael Koch X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=12dc3f75be9b5e7d600dd686abc633ac177e6d20;p=gcc.git 2003-10-15 Michael Koch * java/text/CollationElementIterator.java (CollationElementIterator): Moved, documenatation added, call setText. (next): Reformated. (reset): Reformated. (setText): New method. (getOffset): New method. * java/text/CollationKey.java (getSourceString): Reformated. (hashCode): Reformated. (toByteArray): Reformated. From-SVN: r72523 --- diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 2a439c1fd2e..0b188193f2c 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,16 @@ +2003-10-15 Michael Koch + + * java/text/CollationElementIterator.java + (CollationElementIterator): Moved, documenatation added, call setText. + (next): Reformated. + (reset): Reformated. + (setText): New method. + (getOffset): New method. + * java/text/CollationKey.java + (getSourceString): Reformated. + (hashCode): Reformated. + (toByteArray): Reformated. + 2003-10-15 Michael Koch * java/util/zip/InflaterInputStream.java diff --git a/libjava/java/text/CollationElementIterator.java b/libjava/java/text/CollationElementIterator.java index 94c65005e8f..9eb17a50148 100644 --- a/libjava/java/text/CollationElementIterator.java +++ b/libjava/java/text/CollationElementIterator.java @@ -81,6 +81,20 @@ public final class CollationElementIterator boolean lookahead_set; int lookahead; + /** + * This method initializes a new instance of CollationElementIterator + * to iterate over the specified String using the rules in the + * specified RuleBasedCollator. + * + * @param collator The RuleBasedCollation used for calculating collation values + * @param text The String to iterate over. + */ + CollationElementIterator (String text, RuleBasedCollator collator) + { + setText (text); + this.collator = collator; + } + /** * This method returns the collation ordering value of the next character * in the string. This method will return NULLORDER if the @@ -88,12 +102,12 @@ public final class CollationElementIterator * * @return The collation ordering value. */ - public int next () + public int next() { if (index == text.length()) return NULLORDER; - return collator.ceiNext(this); + return collator.ceiNext (this); } /** @@ -114,7 +128,7 @@ public final class CollationElementIterator * This method resets the internal position pointer to read from the * beginning of the String again. */ - public void reset () + public void reset() { index = 0; } @@ -147,14 +161,33 @@ public final class CollationElementIterator return (short) (order & 255); } - // Non-public constructor. - CollationElementIterator (String text, RuleBasedCollator collator) + /** + * This method sets the String that it is iterating over + * to the specified String. + * + * @param text The new String to iterate over. + * + * @since 1.2 + */ + public void setText (String text) { this.text = text; this.index = 0; this.lookahead_set = false; this.lookahead = 0; - this.collator = collator; + } + + /** + * This method returns the current offset into the String + * that is being iterated over. + * + * @return The iteration index position. + * + * @since 1.2 + */ + public int getOffset() + { + return index; } } // class CollationElementIterator diff --git a/libjava/java/text/CollationKey.java b/libjava/java/text/CollationKey.java index 9517756cd14..f7e3148c50b 100644 --- a/libjava/java/text/CollationKey.java +++ b/libjava/java/text/CollationKey.java @@ -169,7 +169,7 @@ public final class CollationKey implements Comparable * * @return The source String for this object. */ - public String getSourceString () + public String getSourceString() { return originalText; } @@ -181,7 +181,7 @@ public final class CollationKey implements Comparable * * @return A hash value for this object. */ - public int hashCode () + public int hashCode() { // We just follow BitSet instead of thinking up something new. long h = originalText.hashCode(); @@ -195,7 +195,7 @@ public final class CollationKey implements Comparable * * @param A byte array containing the collation bit sequence. */ - public byte[] toByteArray () + public byte[] toByteArray() { byte[] r = new byte[4 * key.length]; int off = 0;