c-decl.c (c_finish_incomplete_decl): Don't use xxx_with_decl.
[official-gcc.git] / libjava / java / text / CollationElementIterator.java
blob94c65005e8fd6da3468804d5e281befde1bfc0d9
1 /* CollationElementIterator.java -- Walks through collation elements
2 Copyright (C) 1998, 1999, 2001, 2002, 2003 Free Software Foundation
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package java.text;
41 /* Written using "Java Class Libraries", 2nd edition, plus online
42 * API docs for JDK 1.2 from http://www.javasoft.com.
43 * Status: Believed complete and correct to JDK 1.1.
46 /**
47 * This class walks through the character collation elements of a
48 * <code>String</code> as defined by the collation rules in an instance of
49 * <code>RuleBasedCollator</code>. There is no public constructor for
50 * this class. An instance is created by calling the
51 * <code>getCollationElementIterator</code> method on
52 * <code>RuleBasedCollator</code>.
54 * @author Aaron M. Renn <arenn@urbanophile.com>
55 * @author Tom Tromey <tromey@cygnus.com>
57 public final class CollationElementIterator
59 /**
60 * This is a constant value that is returned to indicate that the end of
61 * the string was encountered.
63 public static final int NULLORDER = -1;
65 /**
66 * This is the RuleBasedCollator this object was created from.
68 RuleBasedCollator collator;
70 /**
71 * This is the String that is being iterated over.
73 String text;
75 /**
76 * This is the index into the String where we are currently scanning.
78 int index;
80 // A piece of lookahead.
81 boolean lookahead_set;
82 int lookahead;
84 /**
85 * This method returns the collation ordering value of the next character
86 * in the string. This method will return <code>NULLORDER</code> if the
87 * end of the string was reached.
89 * @return The collation ordering value.
91 public int next ()
93 if (index == text.length())
94 return NULLORDER;
96 return collator.ceiNext(this);
99 /**
100 * This method returns the primary order value for the given collation
101 * value.
103 * @param value The collation value returned from <code>next()</code> or <code>previous()</code>.
105 * @return The primary order value of the specified collation value. This is the high 16 bits.
107 public static final int primaryOrder (int order)
109 // From the JDK 1.2 spec.
110 return order >>> 16;
114 * This method resets the internal position pointer to read from the
115 * beginning of the <code>String again.
117 public void reset ()
119 index = 0;
123 * This method returns the secondary order value for the given collation
124 * value.
126 * @param value The collation value returned from <code>next()</code> or <code>previous()</code>.
128 * @return The secondary order value of the specified collation value. This is the bits 8-15.
130 public static final short secondaryOrder (int order)
132 // From the JDK 1.2 spec.
133 return (short) ((order >>> 8) & 255);
137 * This method returns the tertiary order value for the given collation
138 * value.
140 * @param value The collation value returned from <code>next()</code> or <code>previous()</code>.
142 * @return The tertiary order value of the specified collation value. This is the low eight bits.
144 public static final short tertiaryOrder (int order)
146 // From the JDK 1.2 spec.
147 return (short) (order & 255);
150 // Non-public constructor.
151 CollationElementIterator (String text, RuleBasedCollator collator)
153 this.text = text;
154 this.index = 0;
155 this.lookahead_set = false;
156 this.lookahead = 0;
157 this.collator = collator;
160 } // class CollationElementIterator