/[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.9 by mkoch, Thu Jun 26 17:57:15 2003 UTC revision 1.10 by mkoch, Wed Oct 15 16:05:10 2003 UTC
# Line 85  public final class CollationElementItera Line 85  public final class CollationElementItera
85     * @param collator The <code>RuleBasedCollation</code> used for calculating collation values     * @param collator The <code>RuleBasedCollation</code> used for calculating collation values
86     * @param text The <code>String</code> to iterate over.     * @param text The <code>String</code> to iterate over.
87     */     */
88    CollationElementIterator (RuleBasedCollator collator, String text)    CollationElementIterator (String text, RuleBasedCollator collator)
89    {    {
90        setText (text);
91      this.collator = collator;      this.collator = collator;
     this.text = text;  
92    }    }
93    
94    /**    /**
# Line 98  public final class CollationElementItera Line 98  public final class CollationElementItera
98     *     *
99     * @return The collation ordering value.     * @return The collation ordering value.
100     */     */
101    public int next ()    public int next()
102    {    {
103      if (index >= text.length ())      if (index == text.length())
104        return NULLORDER;        return NULLORDER;
105    
106      String s = text.charAt (index) + "";      String s = text.charAt (index) + "";
# Line 126  public final class CollationElementItera Line 126  public final class CollationElementItera
126     * This method resets the internal position pointer to read from the     * This method resets the internal position pointer to read from the
127     * beginning of the <code>String again.     * beginning of the <code>String again.
128     */     */
129    public void reset ()    public void reset()
130    {    {
131      index = 0;      index = 0;
132    }    }
# Line 163  public final class CollationElementItera Line 163  public final class CollationElementItera
163     * This method sets the <code>String</code> that it is iterating over     * This method sets the <code>String</code> that it is iterating over
164     * to the specified <code>String</code>.     * to the specified <code>String</code>.
165     *     *
166     * @param The new <code>String</code> to iterate over.     * @param text The new <code>String</code> to iterate over.
167       *
168       * @since 1.2
169     */     */
170    public void setText (String text)    public void setText (String text)
171    {    {
# Line 180  public final class CollationElementItera Line 182  public final class CollationElementItera
182     */     */
183    public void setText (CharacterIterator ci)    public void setText (CharacterIterator ci)
184    {    {
185        // For now assume we read from the beginning of the string.
186        char c = ci.first();
187      StringBuffer sb = new StringBuffer ("");      StringBuffer sb = new StringBuffer ("");
188    
     // For now assume we read from the beginning of the string.  
     char c = ci.first ();  
189      while (c != CharacterIterator.DONE)      while (c != CharacterIterator.DONE)
190        {        {
191          sb.append (c);          sb.append (c);
192          c = ci.next ();          c = ci.next();
193        }        }
194    
195      setText (sb.toString ());      setText (sb.toString());
196    }    }
197    
198    /**    /**
# Line 198  public final class CollationElementItera Line 200  public final class CollationElementItera
200     * that is being iterated over.     * that is being iterated over.
201     *     *
202     * @return The iteration index position.     * @return The iteration index position.
203       *
204       * @since 1.2
205     */     */
206    public int getOffset ()    public int getOffset()
207    {    {
208      return index;      return index;
209    }    }
# Line 248  public final class CollationElementItera Line 252  public final class CollationElementItera
252     *     *
253     * @return The collation ordering value.     * @return The collation ordering value.
254     */     */
255    public int previous ()    public int previous()
256    {    {
257      --index;      --index;
258      if (index < 0)      if (index < 0)
# Line 257  public final class CollationElementItera Line 261  public final class CollationElementItera
261      String s = text.charAt (index) + "";      String s = text.charAt (index) + "";
262      return collator.getCollationElementValue (s);      return collator.getCollationElementValue (s);
263    }    }
264  }  
265    } // class CollationElementIterator
266    

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

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