aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/text/CollationElementIterator.java
blob: 96732f7b2e339e8afd48c90f636f9b9d02b2e881 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// CollationElementIterator.java - Iterate over decomposed characters.

/* Copyright (C) 1999  Free Software Foundation

   This file is part of libgcj.

This software is copyrighted work licensed under the terms of the
Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
details.  */

package java.text;

/**
 * @author Tom Tromey <tromey@cygnus.com>
 * @date March 25, 1999
 */
/* Written using "Java Class Libraries", 2nd edition, plus online
 * API docs for JDK 1.2 from http://www.javasoft.com.
 * Status: Believed complete and correct to JDK 1.1.
 */

public final class CollationElementIterator
{
  public static final int NULLORDER = 0xffffffff;

  public int next ()
  {
    if (index == text.length())
      return NULLORDER;
    return collator.ceiNext(this);
  }

  // This one returns int while the others return short.
  public static final int primaryOrder (int order)
  {
    // From the JDK 1.2 spec.
    return order >>> 16;
  }

  public void reset ()
  {
    index = 0;
  }

  public static final short secondaryOrder (int order)
  {
    // From the JDK 1.2 spec.
    return (order >>> 8) & 255;
  }

  public static final short tertiaryOrder (int order)
  {
    // From the JDK 1.2 spec.
    return order & 255;
  }

  // Non-public constructor.
  CollationElementIterator (String text, RuleBasedCollator collator)
  {
    this.text = text;
    this.index = 0;
    this.lookahead_set = false;
    this.lookahead = 0;
    this.collator = collator;
  }

  // Text over which we iterate.
  String text;

  // Index of next character to examine in TEXT.
  int index;

  // A piece of lookahead.
  boolean lookahead_set;
  int lookahead;

  // The RuleBasedCollator which created this object.
  RuleBasedCollator collator;
}