This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch: java.text.CollationElementIterator


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi list,


I just commited the attached patch from Guilhem Lavaux to merge 
java.text.CollationElementIterator with classpath again.


Michael


2004-07-17  Guilhem Lavaux <guilhem@kaffe.org>

	* java/text/CollationElementIterator.java
	(text_decomposition): Changed type to 
RuleBasedCollator.CollationElement[]
	(setText): Use ArrayList instead of Vector.
- -- 
Homepage: http://www.worldforge.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFA+OgqWSOgCCdjSDsRArpnAJsHobMj5wm9smu160+jovwhMmUrHQCfSuqk
RZkNbIhQ9nKObvjvuqy1Kjk=
=4xTz
-----END PGP SIGNATURE-----
Index: java/text/CollationElementIterator.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/text/CollationElementIterator.java,v
retrieving revision 1.14
diff -u -b -B -r1.14 CollationElementIterator.java
--- java/text/CollationElementIterator.java	31 May 2004 22:16:31 -0000	1.14
+++ java/text/CollationElementIterator.java	17 Jul 2004 08:45:56 -0000
@@ -38,7 +38,7 @@
 
 package java.text;
 
-import java.util.Vector;
+import java.util.ArrayList;
 
 /* Written using "Java Class Libraries", 2nd edition, plus online
  * API docs for JDK 1.2 from http://www.javasoft.com.
@@ -89,7 +89,7 @@
    * Array containing the collation decomposition of the
    * text given to the constructor.
    */
-  private Object[] text_decomposition;
+  private RuleBasedCollator.CollationElement[] text_decomposition;
 
   /**
    * Array containing the index of the specified block.
@@ -116,8 +116,7 @@
     if (index >= text_decomposition.length)
       return null;
     
-    RuleBasedCollator.CollationElement e =
-      (RuleBasedCollator.CollationElement) text_decomposition[index];
+    RuleBasedCollator.CollationElement e = text_decomposition[index];
     
     textIndex = text_indexes[index+1];
 
@@ -132,8 +131,7 @@
       return null;
     
     index--;
-    RuleBasedCollator.CollationElement e =
-      (RuleBasedCollator.CollationElement) text_decomposition[index];
+    RuleBasedCollator.CollationElement e = text_decomposition[index];
 
     textIndex = text_indexes[index+1];
     
@@ -247,8 +245,8 @@
 
     String work_text = text.intern();
 
-    Vector v = new Vector();
-    Vector vi = new Vector();
+    ArrayList a_element = new ArrayList();
+    ArrayList a_idx = new ArrayList();
 
     // Build element collection ordered as they come in "text".
     while (idx < work_text.length())
@@ -301,8 +299,8 @@
 		RuleBasedCollator.CollationElement e =
 		  collator.getDefaultAccentedElement (work_text.charAt (idx));
 		
-		v.add (e);
-		vi.add (new Integer(idx_idx));
+		a_element.add (e);
+		a_idx.add (new Integer(idx_idx));
 		idx++;
 		alreadyExpanded--;
 		if (alreadyExpanded == 0)
@@ -326,10 +324,10 @@
 		/* Don't forget to mark it as a special sequence so the
 		 * string can be ordered.
 		 */
-		v.add (RuleBasedCollator.SPECIAL_UNKNOWN_SEQ);
-		vi.add (i_ref);
-		v.add (e);
-		vi.add (i_ref);
+		a_element.add (RuleBasedCollator.SPECIAL_UNKNOWN_SEQ);
+		a_idx.add (i_ref);
+		a_element.add (e);
+		a_idx.add (i_ref);
 		idx_idx++;
 		idx++;
 	      }
@@ -346,8 +344,8 @@
 	    work_text = prefix.expansion
 	      + work_text.substring (idx+prefix.key.length());
 	    idx = 0;
-	    v.add (prefix);
-	    vi.add (new Integer(idx_idx));
+	    a_element.add (prefix);
+	    a_idx.add (new Integer(idx_idx));
 	    if (alreadyExpanded == 0)
 	      idxToMove = prefix.key.length();
 	    alreadyExpanded += prefix.expansion.length()-prefix.key.length();
@@ -357,8 +355,8 @@
 	    /* Third case: the simplest. We have got the prefix and it
 	     * has not to be expanded.
 	     */
-	    v.add (prefix);
-	    vi.add (new Integer(idx_idx));
+	    a_element.add (prefix);
+	    a_idx.add (new Integer(idx_idx));
 	    idx += prefix.key.length();
 	    /* If the sequence is in an expansion, we must decrease the
 	     * counter.
@@ -376,13 +374,14 @@
 	  }
       }
     
-    text_decomposition = v.toArray();
-    text_indexes = new int[vi.size()+1];
-    for (int i = 0; i < vi.size(); i++) 
+    text_decomposition = (RuleBasedCollator.CollationElement[])
+	   a_element.toArray(new RuleBasedCollator.CollationElement[a_element.size()]);
+    text_indexes = new int[a_idx.size()+1];
+    for (int i = 0; i < a_idx.size(); i++) 
       {
-	text_indexes[i] = ((Integer)vi.elementAt(i)).intValue();
+	text_indexes[i] = ((Integer)a_idx.get(i)).intValue();
       }
-    text_indexes[vi.size()] = text.length();
+    text_indexes[a_idx.size()] = text.length();
   }
 
   /**

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]