1 | // CollationElementIterator.java - Iterate over decomposed characters.
|
---|
2 |
|
---|
3 | /* Copyright (C) 1999, 2001 Free Software Foundation
|
---|
4 |
|
---|
5 | This file is part of libgcj.
|
---|
6 |
|
---|
7 | This software is copyrighted work licensed under the terms of the
|
---|
8 | Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
|
---|
9 | details. */
|
---|
10 |
|
---|
11 | package java.text;
|
---|
12 |
|
---|
13 | /**
|
---|
14 | * @author Tom Tromey <tromey@cygnus.com>
|
---|
15 | * @date March 25, 1999
|
---|
16 | */
|
---|
17 | /* Written using "Java Class Libraries", 2nd edition, plus online
|
---|
18 | * API docs for JDK 1.2 from http://www.javasoft.com.
|
---|
19 | * Status: Believed complete and correct to JDK 1.1.
|
---|
20 | */
|
---|
21 |
|
---|
22 | public final class CollationElementIterator
|
---|
23 | {
|
---|
24 | public static final int NULLORDER = 0xffffffff;
|
---|
25 |
|
---|
26 | public int next ()
|
---|
27 | {
|
---|
28 | if (index == text.length())
|
---|
29 | return NULLORDER;
|
---|
30 | return collator.ceiNext(this);
|
---|
31 | }
|
---|
32 |
|
---|
33 | // This one returns int while the others return short.
|
---|
34 | public static final int primaryOrder (int order)
|
---|
35 | {
|
---|
36 | // From the JDK 1.2 spec.
|
---|
37 | return order >>> 16;
|
---|
38 | }
|
---|
39 |
|
---|
40 | public void reset ()
|
---|
41 | {
|
---|
42 | index = 0;
|
---|
43 | }
|
---|
44 |
|
---|
45 | public static final short secondaryOrder (int order)
|
---|
46 | {
|
---|
47 | // From the JDK 1.2 spec.
|
---|
48 | return (short) ((order >>> 8) & 255);
|
---|
49 | }
|
---|
50 |
|
---|
51 | public static final short tertiaryOrder (int order)
|
---|
52 | {
|
---|
53 | // From the JDK 1.2 spec.
|
---|
54 | return (short) (order & 255);
|
---|
55 | }
|
---|
56 |
|
---|
57 | // Non-public constructor.
|
---|
58 | CollationElementIterator (String text, RuleBasedCollator collator)
|
---|
59 | {
|
---|
60 | this.text = text;
|
---|
61 | this.index = 0;
|
---|
62 | this.lookahead_set = false;
|
---|
63 | this.lookahead = 0;
|
---|
64 | this.collator = collator;
|
---|
65 | }
|
---|
66 |
|
---|
67 | // Text over which we iterate.
|
---|
68 | String text;
|
---|
69 |
|
---|
70 | // Index of next character to examine in TEXT.
|
---|
71 | int index;
|
---|
72 |
|
---|
73 | // A piece of lookahead.
|
---|
74 | boolean lookahead_set;
|
---|
75 | int lookahead;
|
---|
76 |
|
---|
77 | // The RuleBasedCollator which created this object.
|
---|
78 | RuleBasedCollator collator;
|
---|
79 | }
|
---|