summaryrefslogtreecommitdiff
path: root/libjava/classpath/java/text/RuleBasedCollator.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/java/text/RuleBasedCollator.java')
-rw-r--r--libjava/classpath/java/text/RuleBasedCollator.java696
1 files changed, 348 insertions, 348 deletions
diff --git a/libjava/classpath/java/text/RuleBasedCollator.java b/libjava/classpath/java/text/RuleBasedCollator.java
index b761039ad80..c7fc549fe57 100644
--- a/libjava/classpath/java/text/RuleBasedCollator.java
+++ b/libjava/classpath/java/text/RuleBasedCollator.java
@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
-
+
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -66,7 +66,7 @@ import java.util.HashMap;
* case with French. The modifier applies to all rules <b>after</b>
* the modifier but before the next primary sequence. If placed at the end
* of the sequence if applies to all unknown accented character.
- * The relational operators specify how the text
+ * The relational operators specify how the text
* argument relates to the previous term. The relation characters have
* the following meanings:
* <ul>
@@ -81,9 +81,9 @@ import java.util.HashMap;
* <p>
* As for the text argument itself, this is any sequence of Unicode
* characters not in the following ranges: 0x0009-0x000D, 0x0020-0x002F,
- * 0x003A-0x0040, 0x005B-0x0060, and 0x007B-0x007E. If these characters are
- * desired, they must be enclosed in single quotes. If any whitespace is
- * encountered, it is ignored. (For example, "a b" is equal to "ab").
+ * 0x003A-0x0040, 0x005B-0x0060, and 0x007B-0x007E. If these characters are
+ * desired, they must be enclosed in single quotes. If any whitespace is
+ * encountered, it is ignored. (For example, "a b" is equal to "ab").
* <p>
* The reset operation inserts the following rule at the point where the
* text argument to it exists in the previously declared rule string. This
@@ -91,7 +91,7 @@ import java.util.HashMap;
* them in a reset sequence at the end. Note that the text argument, or
* at least the first character of it, must be present somewhere in the
* previously declared rules in order to be inserted properly. If this
- * is not satisfied, a <code>ParseException</code> will be thrown.
+ * is not satisfied, a <code>ParseException</code> will be thrown.
* <p>
* This system of configuring <code>RuleBasedCollator</code> is needlessly
* complex and the people at Taligent who developed it (along with the folks
@@ -100,7 +100,7 @@ import java.util.HashMap;
* <p>
* Here are a couple of example of rule strings:
* <p>
- * "&lt; a &lt; b &lt; c" - This string says that a is greater than b which is
+ * "&lt; a &lt; b &lt; c" - This string says that a is greater than b which is
* greater than c, with all differences being primary differences.
* <p>
* "&lt; a,A &lt; b,B &lt; c,C" - This string says that 'A' is greater than 'a' with
@@ -108,7 +108,7 @@ import java.util.HashMap;
* 'A' during a primary strength comparison. But 'B' is greater than 'b'
* under a tertiary strength comparison.
* <p>
- * "&lt; a &lt; c &amp; a &lt; b " - This sequence is identical in function to the
+ * "&lt; a &lt; c &amp; a &lt; b " - This sequence is identical in function to the
* "&lt; a &lt; b &lt; c" rule string above. The '&amp;' reset symbol indicates that
* the rule "&lt; b" is to be inserted after the text argument "a" in the
* previous rule string segment.
@@ -125,7 +125,7 @@ import java.util.HashMap;
* <p>
* As an additional complication to this already overly complex rule scheme,
* if any characters precede the first rule, these characters are considered
- * ignorable. They will be treated as if they did not exist during
+ * ignorable. They will be treated as if they did not exist during
* comparisons. For example, "- &lt; a &lt; b ..." would make '-' an ignorable
* character such that the strings "high-tech" and "hightech" would
* be considered identical.
@@ -146,7 +146,7 @@ import java.util.HashMap;
public class RuleBasedCollator extends Collator
{
/**
- * This class describes what rank has a character (or a sequence of characters)
+ * This class describes what rank has a character (or a sequence of characters)
* in the lexicographic order. Each element in a rule has a collation element.
*/
static final class CollationElement
@@ -160,7 +160,7 @@ public class RuleBasedCollator extends Collator
final String expansion;
CollationElement(String key, int primary, short secondary, short tertiary,
- short equality, String expansion, boolean ignore)
+ short equality, String expansion, boolean ignore)
{
this.key = key;
this.primary = primary;
@@ -193,7 +193,7 @@ public class RuleBasedCollator extends Collator
static final int EQUAL = 3;
static final int RESET = 4;
static final int INVERSE_SECONDARY = 5;
-
+
final int comparisonType;
final String textElement;
final int hashText;
@@ -203,7 +203,7 @@ public class RuleBasedCollator extends Collator
String expansionOrdering;
private CollationSorter(final int comparisonType, final String textElement,
- final int offset, final boolean ignore)
+ final int offset, final boolean ignore)
{
this.comparisonType = comparisonType;
this.textElement = textElement;
@@ -254,10 +254,10 @@ public class RuleBasedCollator extends Collator
* The JDK uses it to mark and sort the characters which has
* no collation rules.
*/
- static final CollationElement SPECIAL_UNKNOWN_SEQ =
+ static final CollationElement SPECIAL_UNKNOWN_SEQ =
new CollationElement("", (short) 32767, (short) 0, (short) 0,
- (short) 0, null, false);
-
+ (short) 0, null, false);
+
/**
* This method initializes a new instance of <code>RuleBasedCollator</code>
* with the specified collation rules. Note that an application normally
@@ -273,7 +273,7 @@ public class RuleBasedCollator extends Collator
{
if (rules.equals(""))
throw new ParseException("empty rule set", 0);
-
+
this.rules = rules;
buildCollationVector(parseString(rules));
@@ -296,8 +296,8 @@ public class RuleBasedCollator extends Collator
for (index = 0; index < len && index < s.length(); ++index)
{
- if (prefix.charAt(index) != s.charAt(index))
- return index;
+ if (prefix.charAt(index) != s.charAt(index))
+ return index;
}
@@ -317,45 +317,45 @@ public class RuleBasedCollator extends Collator
* @throws ParseException if it is impossible to find an anchor point for the new rules.
*/
private void mergeRules(int offset, String starter, ArrayList<CollationSorter> main,
- ArrayList<CollationSorter> patch)
- throws ParseException
+ ArrayList<CollationSorter> patch)
+ throws ParseException
{
int insertion_point = -1;
int max_length = 0;
-
+
/* We must check that no rules conflict with another already present. If it
- * is the case delete the old rule.
+ * is the case delete the old rule.
*/
-
+
/* For the moment good old O(N^2) algorithm.
*/
for (int i = 0; i < patch.size(); i++)
{
- int j = 0;
-
- while (j < main.size())
- {
- CollationSorter rule1 = patch.get(i);
- CollationSorter rule2 = main.get(j);
-
- if (rule1.textElement.equals(rule2.textElement))
- main.remove(j);
- else
- j++;
- }
+ int j = 0;
+
+ while (j < main.size())
+ {
+ CollationSorter rule1 = patch.get(i);
+ CollationSorter rule2 = main.get(j);
+
+ if (rule1.textElement.equals(rule2.textElement))
+ main.remove(j);
+ else
+ j++;
+ }
}
// Find the insertion point... O(N)
for (int i = 0; i < main.size(); i++)
{
- CollationSorter sorter = main.get(i);
- int length = findPrefixLength(starter, sorter.textElement);
-
- if (length > max_length)
- {
- max_length = length;
- insertion_point = i+1;
- }
+ CollationSorter sorter = main.get(i);
+ int length = findPrefixLength(starter, sorter.textElement);
+
+ if (length > max_length)
+ {
+ max_length = length;
+ insertion_point = i+1;
+ }
}
if (insertion_point < 0)
@@ -363,28 +363,28 @@ public class RuleBasedCollator extends Collator
if (max_length < starter.length())
{
- /*
- * We need to expand the first entry. It must be sorted
- * like if it was the reference key itself (like the spec
- * said. So the first entry is special: the element is
- * replaced by the specified text element for the sorting.
- * This text replace the old one for comparisons. However
- * to preserve the behaviour we replace the first key (corresponding
- * to the found prefix) by a new code rightly ordered in the
- * sequence. The rest of the subsequence must be appended
- * to the end of the sequence.
- */
- CollationSorter sorter = patch.get(0);
-
- sorter.expansionOrdering = starter.substring(max_length); // Skip the first good prefix element
-
- main.add(insertion_point, sorter);
-
- /*
- * This is a new set of rules. Append to the list.
- */
- patch.remove(0);
- insertion_point++;
+ /*
+ * We need to expand the first entry. It must be sorted
+ * like if it was the reference key itself (like the spec
+ * said. So the first entry is special: the element is
+ * replaced by the specified text element for the sorting.
+ * This text replace the old one for comparisons. However
+ * to preserve the behaviour we replace the first key (corresponding
+ * to the found prefix) by a new code rightly ordered in the
+ * sequence. The rest of the subsequence must be appended
+ * to the end of the sequence.
+ */
+ CollationSorter sorter = patch.get(0);
+
+ sorter.expansionOrdering = starter.substring(max_length); // Skip the first good prefix element
+
+ main.add(insertion_point, sorter);
+
+ /*
+ * This is a new set of rules. Append to the list.
+ */
+ patch.remove(0);
+ insertion_point++;
}
// Now insert all elements of patch at the insertion point.
@@ -395,7 +395,7 @@ public class RuleBasedCollator extends Collator
/**
* This method parses a string and build a set of sorting instructions. The parsing
* may only be partial on the case the rules are to be merged sometime later.
- *
+ *
* @param stop_on_reset If this parameter is true then the parser stops when it
* encounters a reset instruction. In the other case, it tries to parse the subrules
* and merged it in the same repository.
@@ -403,12 +403,12 @@ public class RuleBasedCollator extends Collator
* @param base_offset Offset in the string to begin parsing.
* @param rules Rules to be parsed.
* @return -1 if the parser reached the end of the string, an integer representing the
- * offset in the string at which it stopped parsing.
+ * offset in the string at which it stopped parsing.
* @throws ParseException if something turned wrong during the parsing. To get details
* decode the message.
*/
private int subParseString(boolean stop_on_reset, ArrayList<CollationSorter> v,
- int base_offset, String rules)
+ int base_offset, String rules)
throws ParseException
{
boolean ignoreChars = (base_offset == 0);
@@ -419,155 +419,155 @@ public class RuleBasedCollator extends Collator
boolean nextIsModifier = false;
boolean isModifier = false;
int i;
-
+
main_parse_loop:
for (i = 0; i < rules.length(); i++)
{
- char c = rules.charAt(i);
- int type = -1;
-
- if (!eatingChars &&
- ((c >= 0x09 && c <= 0x0D) || (c == 0x20)))
- continue;
-
- isModifier = nextIsModifier;
- nextIsModifier = false;
-
- if (eatingChars && c != '\'')
- {
- doubleQuote = false;
- sb.append(c);
- continue;
- }
- if (doubleQuote && eatingChars)
- {
- sb.append(c);
- doubleQuote = false;
- continue;
- }
-
- switch (c)
- {
- case '!':
- throw new ParseException
- ("Modifier '!' is not yet supported by Classpath", i + base_offset);
- case '<':
- type = CollationSorter.GREATERP;
- break;
- case ';':
- type = CollationSorter.GREATERS;
- break;
- case ',':
- type = CollationSorter.GREATERT;
- break;
- case '=':
- type = CollationSorter.EQUAL;
- break;
- case '\'':
- eatingChars = !eatingChars;
- doubleQuote = true;
- break;
- case '@':
- if (ignoreChars)
- throw new ParseException
- ("comparison list has not yet been started. You may only use"
- + "(<,;=&)", i + base_offset);
- // Inverse the order of secondaries from now on.
- nextIsModifier = true;
- type = CollationSorter.INVERSE_SECONDARY;
- break;
- case '&':
- type = CollationSorter.RESET;
- if (stop_on_reset)
- break main_parse_loop;
- break;
- default:
- if (operator < 0)
- throw new ParseException
- ("operator missing at " + (i + base_offset), i + base_offset);
- if (! eatingChars
- && ((c >= 0x21 && c <= 0x2F)
- || (c >= 0x3A && c <= 0x40)
- || (c >= 0x5B && c <= 0x60)
- || (c >= 0x7B && c <= 0x7E)))
- throw new ParseException
- ("unquoted punctuation character '" + c + "'", i + base_offset);
-
- //type = ignoreChars ? CollationSorter.IGNORE : -1;
- sb.append(c);
- break;
- }
-
- if (type < 0)
- continue;
-
- if (operator < 0)
- {
- operator = type;
- continue;
- }
-
- if (sb.length() == 0 && !isModifier)
- throw new ParseException
- ("text element empty at " + (i+base_offset), i+base_offset);
-
- if (operator == CollationSorter.RESET)
- {
- /* Reposition in the sorting list at the position
- * indicated by the text element.
- */
- String subrules = rules.substring(i);
- ArrayList<CollationSorter> sorted_rules = new ArrayList<CollationSorter>();
- int idx;
-
- // Parse the subrules but do not iterate through all
- // sublist. This is the privilege of the first call.
- idx = subParseString(true, sorted_rules, base_offset+i, subrules);
-
- // Merge new parsed rules into the list.
- mergeRules(base_offset+i, sb.toString(), v, sorted_rules);
- sb.setLength(0);
-
- // Reset state to none.
- operator = -1;
- type = -1;
- // We have found a new subrule at 'idx' but it has not been parsed.
- if (idx >= 0)
- {
- i += idx-1;
- continue main_parse_loop;
- }
- else
- // No more rules.
- break main_parse_loop;
- }
-
- String textElement = sb.toString();
- if (operator == CollationSorter.GREATERP)
- ignoreChars = false;
- CollationSorter sorter = new CollationSorter(operator, textElement,
- base_offset + rules.length(),
- ignoreChars);
- sb.setLength(0);
-
- v.add(sorter);
- operator = type;
+ char c = rules.charAt(i);
+ int type = -1;
+
+ if (!eatingChars &&
+ ((c >= 0x09 && c <= 0x0D) || (c == 0x20)))
+ continue;
+
+ isModifier = nextIsModifier;
+ nextIsModifier = false;
+
+ if (eatingChars && c != '\'')
+ {
+ doubleQuote = false;
+ sb.append(c);
+ continue;
+ }
+ if (doubleQuote && eatingChars)
+ {
+ sb.append(c);
+ doubleQuote = false;
+ continue;
+ }
+
+ switch (c)
+ {
+ case '!':
+ throw new ParseException
+ ("Modifier '!' is not yet supported by Classpath", i + base_offset);
+ case '<':
+ type = CollationSorter.GREATERP;
+ break;
+ case ';':
+ type = CollationSorter.GREATERS;
+ break;
+ case ',':
+ type = CollationSorter.GREATERT;
+ break;
+ case '=':
+ type = CollationSorter.EQUAL;
+ break;
+ case '\'':
+ eatingChars = !eatingChars;
+ doubleQuote = true;
+ break;
+ case '@':
+ if (ignoreChars)
+ throw new ParseException
+ ("comparison list has not yet been started. You may only use"
+ + "(<,;=&)", i + base_offset);
+ // Inverse the order of secondaries from now on.
+ nextIsModifier = true;
+ type = CollationSorter.INVERSE_SECONDARY;
+ break;
+ case '&':
+ type = CollationSorter.RESET;
+ if (stop_on_reset)
+ break main_parse_loop;
+ break;
+ default:
+ if (operator < 0)
+ throw new ParseException
+ ("operator missing at " + (i + base_offset), i + base_offset);
+ if (! eatingChars
+ && ((c >= 0x21 && c <= 0x2F)
+ || (c >= 0x3A && c <= 0x40)
+ || (c >= 0x5B && c <= 0x60)
+ || (c >= 0x7B && c <= 0x7E)))
+ throw new ParseException
+ ("unquoted punctuation character '" + c + "'", i + base_offset);
+
+ //type = ignoreChars ? CollationSorter.IGNORE : -1;
+ sb.append(c);
+ break;
+ }
+
+ if (type < 0)
+ continue;
+
+ if (operator < 0)
+ {
+ operator = type;
+ continue;
+ }
+
+ if (sb.length() == 0 && !isModifier)
+ throw new ParseException
+ ("text element empty at " + (i+base_offset), i+base_offset);
+
+ if (operator == CollationSorter.RESET)
+ {
+ /* Reposition in the sorting list at the position
+ * indicated by the text element.
+ */
+ String subrules = rules.substring(i);
+ ArrayList<CollationSorter> sorted_rules = new ArrayList<CollationSorter>();
+ int idx;
+
+ // Parse the subrules but do not iterate through all
+ // sublist. This is the privilege of the first call.
+ idx = subParseString(true, sorted_rules, base_offset+i, subrules);
+
+ // Merge new parsed rules into the list.
+ mergeRules(base_offset+i, sb.toString(), v, sorted_rules);
+ sb.setLength(0);
+
+ // Reset state to none.
+ operator = -1;
+ type = -1;
+ // We have found a new subrule at 'idx' but it has not been parsed.
+ if (idx >= 0)
+ {
+ i += idx-1;
+ continue main_parse_loop;
+ }
+ else
+ // No more rules.
+ break main_parse_loop;
+ }
+
+ String textElement = sb.toString();
+ if (operator == CollationSorter.GREATERP)
+ ignoreChars = false;
+ CollationSorter sorter = new CollationSorter(operator, textElement,
+ base_offset + rules.length(),
+ ignoreChars);
+ sb.setLength(0);
+
+ v.add(sorter);
+ operator = type;
}
if (operator >= 0)
{
- int pos = rules.length() + base_offset;
+ int pos = rules.length() + base_offset;
- if ((sb.length() != 0 && nextIsModifier)
- || (sb.length() == 0 && !nextIsModifier && !eatingChars))
- throw new ParseException("text element empty at " + pos, pos);
+ if ((sb.length() != 0 && nextIsModifier)
+ || (sb.length() == 0 && !nextIsModifier && !eatingChars))
+ throw new ParseException("text element empty at " + pos, pos);
- if (operator == CollationSorter.GREATERP)
- ignoreChars = false;
+ if (operator == CollationSorter.GREATERP)
+ ignoreChars = false;
- CollationSorter sorter = new CollationSorter(operator, sb.toString(),
- base_offset+pos, ignoreChars);
- v.add(sorter);
+ CollationSorter sorter = new CollationSorter(operator, sb.toString(),
+ base_offset+pos, ignoreChars);
+ v.add(sorter);
}
if (i == rules.length())
@@ -589,12 +589,12 @@ main_parse_loop:
/**
* This method completely parses a string 'rules' containing sorting rules.
*
- * @param rules String containing the rules to be parsed.
+ * @param rules String containing the rules to be parsed.
* @return A set of sorting instructions stored in a Vector.
* @throws ParseException if something turned wrong during the parsing. To get details
* decode the message.
*/
- private ArrayList<CollationSorter> parseString(String rules)
+ private ArrayList<CollationSorter> parseString(String rules)
throws ParseException
{
ArrayList<CollationSorter> v = new ArrayList<CollationSorter>();
@@ -602,7 +602,7 @@ main_parse_loop:
// result of the first subParseString is not absolute (may be -1 or a
// positive integer). But we do not care.
subParseString(false, v, 0, rules);
-
+
return v;
}
@@ -631,60 +631,60 @@ main_parse_loop:
element_loop:
for (int i = 0; i < parsedElements.size(); i++)
{
- CollationSorter elt = parsedElements.get(i);
-
- switch (elt.comparisonType)
- {
- case CollationSorter.GREATERP:
- primary_seq++;
- if (inverseComparisons)
- {
- secondary_seq = Short.MAX_VALUE;
- secondaryType = DECREASING;
- }
- else
- {
- secondary_seq = 0;
- secondaryType = INCREASING;
- }
- tertiary_seq = 0;
- equality_seq = 0;
- inverseComparisons = false;
- break;
- case CollationSorter.GREATERS:
- if (secondaryType == DECREASING)
- secondary_seq--;
- else
- secondary_seq++;
- tertiary_seq = 0;
- equality_seq = 0;
- break;
- case CollationSorter.INVERSE_SECONDARY:
- inverseComparisons = true;
- continue element_loop;
- case CollationSorter.GREATERT:
- tertiary_seq++;
- if (primary_seq == 0)
- last_tertiary_seq = tertiary_seq;
- equality_seq = 0;
- break;
- case CollationSorter.EQUAL:
- equality_seq++;
- break;
- case CollationSorter.RESET:
- throw new ParseException
- ("Invalid reached state 'RESET'. Internal error", elt.offset);
- default:
- throw new ParseException
- ("Invalid unknown state '" + elt.comparisonType + "'", elt.offset);
- }
-
- v.add(new CollationElement(elt.textElement, primary_seq,
- secondary_seq, tertiary_seq,
- equality_seq, elt.expansionOrdering, elt.ignore));
+ CollationSorter elt = parsedElements.get(i);
+
+ switch (elt.comparisonType)
+ {
+ case CollationSorter.GREATERP:
+ primary_seq++;
+ if (inverseComparisons)
+ {
+ secondary_seq = Short.MAX_VALUE;
+ secondaryType = DECREASING;
+ }
+ else
+ {
+ secondary_seq = 0;
+ secondaryType = INCREASING;
+ }
+ tertiary_seq = 0;
+ equality_seq = 0;
+ inverseComparisons = false;
+ break;
+ case CollationSorter.GREATERS:
+ if (secondaryType == DECREASING)
+ secondary_seq--;
+ else
+ secondary_seq++;
+ tertiary_seq = 0;
+ equality_seq = 0;
+ break;
+ case CollationSorter.INVERSE_SECONDARY:
+ inverseComparisons = true;
+ continue element_loop;
+ case CollationSorter.GREATERT:
+ tertiary_seq++;
+ if (primary_seq == 0)
+ last_tertiary_seq = tertiary_seq;
+ equality_seq = 0;
+ break;
+ case CollationSorter.EQUAL:
+ equality_seq++;
+ break;
+ case CollationSorter.RESET:
+ throw new ParseException
+ ("Invalid reached state 'RESET'. Internal error", elt.offset);
+ default:
+ throw new ParseException
+ ("Invalid unknown state '" + elt.comparisonType + "'", elt.offset);
+ }
+
+ v.add(new CollationElement(elt.textElement, primary_seq,
+ secondary_seq, tertiary_seq,
+ equality_seq, elt.expansionOrdering, elt.ignore));
}
- this.inverseAccentComparison = inverseComparisons;
+ this.inverseAccentComparison = inverseComparisons;
ce_table = v.toArray(new CollationElement[v.size()]);
@@ -703,9 +703,9 @@ element_loop:
for (int i = 0; i < ce_table.length; i++)
{
- CollationElement e = ce_table[i];
+ CollationElement e = ce_table[i];
- prefix_tree.put(e.key, e);
+ prefix_tree.put(e.key, e);
}
}
@@ -734,72 +734,72 @@ element_loop:
for(;;)
{
- int ord1;
- int ord2;
-
- /*
- * We have to check whether the characters are ignorable.
- * If it is the case then forget them.
- */
- if (advance_block_1)
- {
- ord1block = cs.nextBlock();
- if (ord1block != null && ord1block.ignore)
- continue;
- }
-
- if (advance_block_2)
- {
- ord2block = ct.nextBlock();
- if (ord2block != null && ord2block.ignore)
- {
- advance_block_1 = false;
- continue;
- }
- }
- else
- advance_block_2 = true;
-
- if (!advance_block_1)
- advance_block_1 = true;
-
- if (ord1block != null)
- ord1 = ord1block.getValue();
- else
- {
- if (ord2block == null)
- return 0;
- return -1;
- }
-
- if (ord2block == null)
- return 1;
-
- ord2 = ord2block.getValue();
-
- // We know chars are totally equal, so skip
+ int ord1;
+ int ord2;
+
+ /*
+ * We have to check whether the characters are ignorable.
+ * If it is the case then forget them.
+ */
+ if (advance_block_1)
+ {
+ ord1block = cs.nextBlock();
+ if (ord1block != null && ord1block.ignore)
+ continue;
+ }
+
+ if (advance_block_2)
+ {
+ ord2block = ct.nextBlock();
+ if (ord2block != null && ord2block.ignore)
+ {
+ advance_block_1 = false;
+ continue;
+ }
+ }
+ else
+ advance_block_2 = true;
+
+ if (!advance_block_1)
+ advance_block_1 = true;
+
+ if (ord1block != null)
+ ord1 = ord1block.getValue();
+ else
+ {
+ if (ord2block == null)
+ return 0;
+ return -1;
+ }
+
+ if (ord2block == null)
+ return 1;
+
+ ord2 = ord2block.getValue();
+
+ // We know chars are totally equal, so skip
if (ord1 == ord2)
- {
- if (getStrength() == IDENTICAL)
- if (!ord1block.key.equals(ord2block.key))
- return ord1block.key.compareTo(ord2block.key);
- continue;
- }
+ {
+ if (getStrength() == IDENTICAL)
+ if (!ord1block.key.equals(ord2block.key))
+ return ord1block.key.compareTo(ord2block.key);
+ continue;
+ }
// Check for primary strength differences
- int prim1 = CollationElementIterator.primaryOrder(ord1);
- int prim2 = CollationElementIterator.primaryOrder(ord2);
-
- if (prim1 == 0 && getStrength() < TERTIARY)
- {
+ int prim1 = CollationElementIterator.primaryOrder(ord1);
+ int prim2 = CollationElementIterator.primaryOrder(ord2);
+
+ if (prim1 == 0 && getStrength() < TERTIARY)
+ {
advance_block_2 = false;
- continue;
- }
- else if (prim2 == 0 && getStrength() < TERTIARY)
- {
- advance_block_1 = false;
- continue;
- }
+ continue;
+ }
+ else if (prim2 == 0 && getStrength() < TERTIARY)
+ {
+ advance_block_1 = false;
+ continue;
+ }
if (prim1 < prim2)
return -1;
@@ -812,7 +812,7 @@ element_loop:
int sec1 = CollationElementIterator.secondaryOrder(ord1);
int sec2 = CollationElementIterator.secondaryOrder(ord2);
- if (sec1 < sec2)
+ if (sec1 < sec2)
return -1;
else if (sec1 > sec2)
return 1;
@@ -827,16 +827,16 @@ element_loop:
return -1;
else if (tert1 > tert2)
return 1;
- else if (getStrength() == TERTIARY)
- continue;
+ else if (getStrength() == TERTIARY)
+ continue;
- // Apparently JDK does this (at least for my test case).
- return ord1block.key.compareTo(ord2block.key);
+ // Apparently JDK does this (at least for my test case).
+ return ord1block.key.compareTo(ord2block.key);
}
}
/**
- * This method tests this object for equality against the specified
+ * This method tests this object for equality against the specified
* object. This will be true if and only if the specified object is
* another reference to this object.
*
@@ -872,7 +872,7 @@ element_loop:
else
v = (short) c;
return new CollationElement("" + c, last_primary_value + v,
- (short) 0, (short) 0, (short) 0, null, false);
+ (short) 0, (short) 0, (short) 0, null, false);
}
/**
@@ -894,7 +894,7 @@ element_loop:
else
v = (short) c;
return new CollationElement("" + c, (short) 0,
- (short) 0, (short) (last_tertiary_value + v), (short) 0, null, false);
+ (short) 0, (short) (last_tertiary_value + v), (short) 0, null, false);
}
/**
@@ -948,29 +948,29 @@ element_loop:
while (ord != CollationElementIterator.NULLORDER)
{
- // If the primary order is null, it means this is an ignorable
- // character.
- if (CollationElementIterator.primaryOrder(ord) == 0)
- {
+ // If the primary order is null, it means this is an ignorable
+ // character.
+ if (CollationElementIterator.primaryOrder(ord) == 0)
+ {
ord = cei.next();
- continue;
- }
+ continue;
+ }
switch (getStrength())
{
case PRIMARY:
- ord = CollationElementIterator.primaryOrder(ord);
- break;
-
+ ord = CollationElementIterator.primaryOrder(ord);
+ break;
+
case SECONDARY:
- ord = CollationElementIterator.primaryOrder(ord) << 8;
- ord |= CollationElementIterator.secondaryOrder(ord);
+ ord = CollationElementIterator.primaryOrder(ord) << 8;
+ ord |= CollationElementIterator.secondaryOrder(ord);
default:
break;
}
- vect.add(Integer.valueOf(ord));
- ord = cei.next(); //increment to next key
+ vect.add(Integer.valueOf(ord));
+ ord = cei.next(); //increment to next key
}
Integer[] objarr = vect.toArray(new Integer[vect.size()]);