2004-01-07 Michael Koch <konqueror@gmx.de>
+ * java/text/CollationElementIterator.java
+ (textIndex): Renamed from index.
+ * java/text/CollationKey.java
+ (collator): New member.
+ (CollationKey): New argument for parent collator.
+ (equals): Check for same collator, source string and key array.
+ * java/text/RuleBasedCollator.java:
+ Reformated.
+ (RuleBasedCollator): Don't re-initialize frenchAccents with default
+ value.
+ (getCollationElementIterator): Rewritten.
+ (getCollationKey): Added new argument to CollationKey constructor.
+
+2004-01-07 Michael Koch <konqueror@gmx.de>
+
* gnu/java/nio/DatagramChannelImpl.java
(blocking): Removed.
(DatagramChannelImpl): Call configureBlocking().
public final class CollationKey implements Comparable
{
/**
+ * This is the <code>Collator</code> this object was created from.
+ */
+ private Collator collator;
+
+ /**
* This is the <code>String</code> this object represents.
*/
private String originalText;
*/
private int[] key;
- CollationKey (CollationElementIterator iter, String originalText,
- int strength)
+ CollationKey(Collator collator, CollationElementIterator iter,
+ String originalText, int strength)
{
+ this.collator = collator;
this.originalText = originalText;
// Compute size of required array.
CollationKey ck = (CollationKey) obj;
- if (key.length != ck.key.length)
+ if (ck.collator != collator)
return false;
- for (int i = 0; i < key.length; ++i)
- if (key[i] != ck.key[i])
- return false;
+ if (!ck.getSourceString ().equals (getSourceString ()))
+ return false;
+
+ if (!ck.toByteArray ().equals (toByteArray ()))
+ return false;
return true;
}
String key;
char relation;
- CollationElement (String key, char relation)
+ CollationElement(String key, char relation)
{
this.key = key;
this.relation = relation;
}
-
- } // inner class CollationElement
+ }
// True if we are using French-style accent ordering.
private boolean frenchAccents;
*/
public RuleBasedCollator(String rules) throws ParseException
{
- if (rules.equals (""))
- throw new ParseException ("empty rule set", 0);
+ if (rules.equals(""))
+ throw new ParseException("empty rule set", 0);
this.rules = rules;
- this.frenchAccents = false;
// We keep each rule in order in a vector. At the end we traverse
// the vector and compute collation values from it.
int insertion_index = 0;
Vector vec = new Vector ();
- StringBuffer argument = new StringBuffer ();
-
+ int index;
+ StringBuffer argument = new StringBuffer();
int len = rules.length();
- for (int index = 0; index < len; ++index)
+
+ for (index = 0; index < len; ++index)
{
char c = rules.charAt(index);
return cei.lookahead;
}
- int save = cei.index;
+ int save = cei.textIndex;
int max = cei.text.length();
String s = null;
}
// Update state.
- cei.index = i;
+ cei.textIndex = i;
if (obj == null)
{
*/
public CollationElementIterator getCollationElementIterator(String source)
{
- StringBuffer expand = new StringBuffer (source.length());
- int max = source.length();
- for (int i = 0; i < max; ++i)
- decomposeCharacter (source.charAt(i), expand);
+ int len = source.length();
+ StringBuffer expand = new StringBuffer(len);
+
+ for (int index = 0; index < len; ++index)
+ decomposeCharacter(source.charAt(index), expand);
+
return new CollationElementIterator(this, expand.toString());
}
*/
public CollationElementIterator getCollationElementIterator(CharacterIterator source)
{
- StringBuffer expand = new StringBuffer();
- for (char c = source.first ();
+ StringBuffer expand = new StringBuffer("");
+
+ // Right now we assume that we will read from the beginning of the string.
+ for (char c = source.first();
c != CharacterIterator.DONE;
- c = source.next ())
- decomposeCharacter (c, expand);
+ c = source.next())
+ decomposeCharacter(c, expand);
return new CollationElementIterator(this, expand.toString());
}
*/
public CollationKey getCollationKey(String source)
{
- return new CollationKey(getCollationElementIterator(source), source,
+ return new CollationKey(this, getCollationElementIterator(source), source,
strength);
}