1999-04-26 17:34:44 +02:00
|
|
|
// CollationElementIterator.java - Iterate over decomposed characters.
|
|
|
|
|
2001-12-18 18:27:43 +01:00
|
|
|
/* Copyright (C) 1999, 2001 Free Software Foundation
|
1999-04-26 17:34:44 +02:00
|
|
|
|
|
|
|
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;
|
1999-04-30 11:31:00 +02:00
|
|
|
return collator.ceiNext(this);
|
1999-04-26 17:34:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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.
|
2001-12-18 18:27:43 +01:00
|
|
|
return (short) ((order >>> 8) & 255);
|
1999-04-26 17:34:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static final short tertiaryOrder (int order)
|
|
|
|
{
|
|
|
|
// From the JDK 1.2 spec.
|
2001-12-18 18:27:43 +01:00
|
|
|
return (short) (order & 255);
|
1999-04-26 17:34:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Non-public constructor.
|
1999-04-30 11:31:00 +02:00
|
|
|
CollationElementIterator (String text, RuleBasedCollator collator)
|
1999-04-26 17:34:44 +02:00
|
|
|
{
|
|
|
|
this.text = text;
|
|
|
|
this.index = 0;
|
|
|
|
this.lookahead_set = false;
|
|
|
|
this.lookahead = 0;
|
1999-04-30 11:31:00 +02:00
|
|
|
this.collator = collator;
|
1999-04-26 17:34:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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;
|
1999-04-30 11:31:00 +02:00
|
|
|
|
|
|
|
// The RuleBasedCollator which created this object.
|
|
|
|
RuleBasedCollator collator;
|
1999-04-26 17:34:44 +02:00
|
|
|
}
|