Hi!

This patch moves the logic to build a CollationElementIterator from
RuleBasedCollator and Collator into the class CollationElementIterator
itself.

*This is not a fix*. Infact, actually the new Constructor just read a
string out of the iterator, without any processing.

This way we can declare the 1.3 completeness and I can start fixing the
CollationElementIterator in just one place.

I would like to have this in for 0.93, but I understand that this is not
a fix...

What do you think?

Mario
-- 
Lima Software, SO.PR.IND. s.r.l.
http://www.limasoftware.net/
pgp key: http://subkeys.pgp.net/

Please, support open standards:
http://opendocumentfellowship.org/petition/
http://www.nosoftwarepatents.com/
### Eclipse Workspace Patch 1.0
#P classpath
Index: java/text/CollationElementIterator.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/text/CollationElementIterator.java,v
retrieving revision 1.24
diff -u -r1.24 CollationElementIterator.java
--- java/text/CollationElementIterator.java	23 Jul 2005 20:25:15 -0000	1.24
+++ java/text/CollationElementIterator.java	6 Dec 2006 12:16:37 -0000
@@ -101,7 +101,8 @@
    * to iterate over the specified <code>String</code> using the rules in the
    * specified <code>RuleBasedCollator</code>.
    *
-   * @param collator The <code>RuleBasedCollation</code> used for calculating collation values
+   * @param collator The <code>RuleBasedCollation</code> used for calculating
+   * collation values
    * @param text The <code>String</code> to iterate over.
    */
   CollationElementIterator(RuleBasedCollator collator, String text)
@@ -111,6 +112,33 @@
     setText (text);    
   }
 
+  /**
+   * This method initializes a new instance of <code>CollationElementIterator</code>
+   * to iterate over the specified <code>CharacterIterator</code> using the
+   * rules in the specified <code>RuleBasedCollator</code>.
+   *
+   * @param collator The <code>RuleBasedCollation</code> used for calculating
+   * collation values
+   * @param text The <code>String</code> to iterate over.
+   */
+  CollationElementIterator(RuleBasedCollator collator,
+                           CharacterIterator source)
+  {
+    this.collator = collator;
+    
+    // FIXME: does the same as CollationElementIterator(RuleBasedCollator,
+    // String text) for now
+    
+    StringBuffer text = new StringBuffer("");
+    
+    for (char c = source.first();
+         c != CharacterIterator.DONE;
+         c = source.next())
+      text.append(c);
+    
+    setText (text.toString());
+  }
+  
   RuleBasedCollator.CollationElement nextBlock()
   {
     if (index >= text_decomposition.length)
Index: java/text/Collator.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/text/Collator.java,v
retrieving revision 1.17
diff -u -r1.17 Collator.java
--- java/text/Collator.java	24 Mar 2006 17:04:23 -0000	1.17
+++ java/text/Collator.java	6 Dec 2006 12:16:38 -0000
@@ -375,14 +375,6 @@
     this.strength = strength;
   }
 
-  // Decompose a single character and append results to the buffer.
-  // FIXME: for libgcj this is a native method which handles
-  // decomposition.  For Classpath, for now, it does nothing.
-  final void decomposeCharacter (char c, StringBuffer buf)
-  {
-    buf.append (c);
-  }
-
   /**
    * This is the current collation decomposition setting.
    */
Index: java/text/RuleBasedCollator.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/text/RuleBasedCollator.java,v
retrieving revision 1.32
diff -u -r1.32 RuleBasedCollator.java
--- java/text/RuleBasedCollator.java	22 Mar 2006 19:15:25 -0000	1.32
+++ java/text/RuleBasedCollator.java	6 Dec 2006 12:16:40 -0000
@@ -38,8 +38,6 @@
 
 package java.text;
 
-import gnu.classpath.NotImplementedException;
-
 import java.util.ArrayList;
 import java.util.HashMap;
 
@@ -894,7 +892,8 @@
     else
       v = (short) c;
     return new CollationElement("" + c, (short) 0,
-				(short) 0, (short) (last_tertiary_value + v), (short) 0, null, false);
+				(short) 0, (short) (last_tertiary_value + v),
+                                (short) 0, null, false);
   }
 
   /**
@@ -922,18 +921,10 @@
    *
    * @return A <code>CollationElementIterator</code> for the specified <code>String</code>.
    */
-  public CollationElementIterator getCollationElementIterator(CharacterIterator source)
-    throws NotImplementedException  // Because decomposeCharacter does not work
+  public
+  CollationElementIterator getCollationElementIterator(CharacterIterator source)
   {
-    StringBuffer expand = new StringBuffer("");
-    
-    // Right now we assume that we will read from the beginning of the string.
-    for (char c = source.first();
-	 c != CharacterIterator.DONE;
-	 c = source.next())
-      decomposeCharacter(c, expand);
-
-    return getCollationElementIterator(expand.toString());
+    return new CollationElementIterator(this, source);
   }
 
   /**

Reply via email to