/[classpath]/classpath/java/text/CollationElementIterator.java
ViewVC logotype

Diff of /classpath/java/text/CollationElementIterator.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.18 by glavaux, Sun May 30 16:34:23 2004 UTC revision 1.19 by glavaux, Thu Jul 15 12:53:24 2004 UTC
# Line 38  exception statement from your version. * Line 38  exception statement from your version. *
38    
39  package java.text;  package java.text;
40    
41  import java.util.Vector;  import java.util.ArrayList;
42    
43  /* Written using "Java Class Libraries", 2nd edition, plus online  /* Written using "Java Class Libraries", 2nd edition, plus online
44   * API docs for JDK 1.2 from http://www.javasoft.com.   * API docs for JDK 1.2 from http://www.javasoft.com.
# Line 89  public final class CollationElementItera Line 89  public final class CollationElementItera
89     * Array containing the collation decomposition of the     * Array containing the collation decomposition of the
90     * text given to the constructor.     * text given to the constructor.
91     */     */
92    private Object[] text_decomposition;    private RuleBasedCollator.CollationElement[] text_decomposition;
93    
94    /**    /**
95     * Array containing the index of the specified block.     * Array containing the index of the specified block.
# Line 116  public final class CollationElementItera Line 116  public final class CollationElementItera
116      if (index >= text_decomposition.length)      if (index >= text_decomposition.length)
117        return null;        return null;
118            
119      RuleBasedCollator.CollationElement e =      RuleBasedCollator.CollationElement e = text_decomposition[index];
       (RuleBasedCollator.CollationElement) text_decomposition[index];  
120            
121      textIndex = text_indexes[index+1];      textIndex = text_indexes[index+1];
122    
# Line 132  public final class CollationElementItera Line 131  public final class CollationElementItera
131        return null;        return null;
132            
133      index--;      index--;
134      RuleBasedCollator.CollationElement e =      RuleBasedCollator.CollationElement e = text_decomposition[index];
       (RuleBasedCollator.CollationElement) text_decomposition[index];  
135    
136      textIndex = text_indexes[index+1];      textIndex = text_indexes[index+1];
137            
# Line 247  public final class CollationElementItera Line 245  public final class CollationElementItera
245    
246      String work_text = text.intern();      String work_text = text.intern();
247    
248      Vector v = new Vector();      ArrayList a_element = new ArrayList();
249      Vector vi = new Vector();      ArrayList a_idx = new ArrayList();
250    
251      // Build element collection ordered as they come in "text".      // Build element collection ordered as they come in "text".
252      while (idx < work_text.length())      while (idx < work_text.length())
# Line 301  public final class CollationElementItera Line 299  public final class CollationElementItera
299                  RuleBasedCollator.CollationElement e =                  RuleBasedCollator.CollationElement e =
300                    collator.getDefaultAccentedElement (work_text.charAt (idx));                    collator.getDefaultAccentedElement (work_text.charAt (idx));
301                                    
302                  v.add (e);                  a_element.add (e);
303                  vi.add (new Integer(idx_idx));                  a_idx.add (new Integer(idx_idx));
304                  idx++;                  idx++;
305                  alreadyExpanded--;                  alreadyExpanded--;
306                  if (alreadyExpanded == 0)                  if (alreadyExpanded == 0)
# Line 326  public final class CollationElementItera Line 324  public final class CollationElementItera
324                  /* Don't forget to mark it as a special sequence so the                  /* Don't forget to mark it as a special sequence so the
325                   * string can be ordered.                   * string can be ordered.
326                   */                   */
327                  v.add (RuleBasedCollator.SPECIAL_UNKNOWN_SEQ);                  a_element.add (RuleBasedCollator.SPECIAL_UNKNOWN_SEQ);
328                  vi.add (i_ref);                  a_idx.add (i_ref);
329                  v.add (e);                  a_element.add (e);
330                  vi.add (i_ref);                  a_idx.add (i_ref);
331                  idx_idx++;                  idx_idx++;
332                  idx++;                  idx++;
333                }                }
# Line 346  public final class CollationElementItera Line 344  public final class CollationElementItera
344              work_text = prefix.expansion              work_text = prefix.expansion
345                + work_text.substring (idx+prefix.key.length());                + work_text.substring (idx+prefix.key.length());
346              idx = 0;              idx = 0;
347              v.add (prefix);              a_element.add (prefix);
348              vi.add (new Integer(idx_idx));              a_idx.add (new Integer(idx_idx));
349              if (alreadyExpanded == 0)              if (alreadyExpanded == 0)
350                idxToMove = prefix.key.length();                idxToMove = prefix.key.length();
351              alreadyExpanded += prefix.expansion.length()-prefix.key.length();              alreadyExpanded += prefix.expansion.length()-prefix.key.length();
# Line 357  public final class CollationElementItera Line 355  public final class CollationElementItera
355              /* Third case: the simplest. We have got the prefix and it              /* Third case: the simplest. We have got the prefix and it
356               * has not to be expanded.               * has not to be expanded.
357               */               */
358              v.add (prefix);              a_element.add (prefix);
359              vi.add (new Integer(idx_idx));              a_idx.add (new Integer(idx_idx));
360              idx += prefix.key.length();              idx += prefix.key.length();
361              /* If the sequence is in an expansion, we must decrease the              /* If the sequence is in an expansion, we must decrease the
362               * counter.               * counter.
# Line 376  public final class CollationElementItera Line 374  public final class CollationElementItera
374            }            }
375        }        }
376            
377      text_decomposition = v.toArray();      text_decomposition = (RuleBasedCollator.CollationElement[])
378      text_indexes = new int[vi.size()+1];             a_element.toArray(new RuleBasedCollator.CollationElement[a_element.size()]);
379      for (int i = 0; i < vi.size(); i++)      text_indexes = new int[a_idx.size()+1];
380        for (int i = 0; i < a_idx.size(); i++)
381        {        {
382          text_indexes[i] = ((Integer)vi.elementAt(i)).intValue();          text_indexes[i] = ((Integer)a_idx.get(i)).intValue();
383        }        }
384      text_indexes[vi.size()] = text.length();      text_indexes[a_idx.size()] = text.length();
385    }    }
386    
387    /**    /**

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.19

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26