1 |
/* RuleBasedCollator.java -- Concrete Collator Class |
/* RuleBasedCollator.java -- Concrete Collator Class |
2 |
Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc. |
Copyright (C) 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
40 |
|
|
41 |
import java.util.Vector; |
import java.util.Vector; |
42 |
|
|
43 |
|
/* Written using "Java Class Libraries", 2nd edition, plus online |
44 |
|
* API docs for JDK 1.2 from http://www.javasoft.com. |
45 |
|
* Status: Believed complete and correct |
46 |
|
*/ |
47 |
|
|
48 |
/** |
/** |
49 |
* This class is a concrete subclass of <code>Collator</code> suitable |
* This class is a concrete subclass of <code>Collator</code> suitable |
50 |
* for string collation in a wide variety of languages. An instance of |
* for string collation in a wide variety of languages. An instance of |
56 |
* Rules take the form of a <code>String</code> with the following syntax |
* Rules take the form of a <code>String</code> with the following syntax |
57 |
* <ul> |
* <ul> |
58 |
* <li> Modifier: '@' |
* <li> Modifier: '@' |
59 |
* <li> Relation: '<' | ';' | ',' | '=' : <text> |
* <li> Relation: '<' | ';' | ',' | '=' : <text> |
60 |
* <li> Reset: '&' : <text> |
* <li> Reset: '&' : <text> |
61 |
* </ul> |
* </ul> |
62 |
* The modifier character indicates that accents sort backward as is the |
* The modifier character indicates that accents sort backward as is the |
63 |
* case with French. The relational operators specify how the text |
* case with French. The relational operators specify how the text |
64 |
* argument relates to the previous term. The relation characters have |
* argument relates to the previous term. The relation characters have |
65 |
* the following meanings: |
* the following meanings: |
66 |
* <ul> |
* <ul> |
67 |
* <li>'<' - The text argument is greater than the prior term at the primary |
* <li>'<' - The text argument is greater than the prior term at the primary |
68 |
* difference level. |
* difference level. |
69 |
* <li>';' - The text argument is greater than the prior term at the secondary |
* <li>';' - The text argument is greater than the prior term at the secondary |
70 |
* difference level. |
* difference level. |
94 |
* <p> |
* <p> |
95 |
* Here are a couple of example of rule strings: |
* Here are a couple of example of rule strings: |
96 |
* <p> |
* <p> |
97 |
* "< a < b < c" - This string says that a is greater than b which is |
* "< a < b < c" - This string says that a is greater than b which is |
98 |
* greater than c, with all differences being primary differences. |
* greater than c, with all differences being primary differences. |
99 |
* <p> |
* <p> |
100 |
* "< a,A < b,B < c,C" - This string says that 'A' is greater than 'a' with |
* "< a,A < b,B < c,C" - This string says that 'A' is greater than 'a' with |
101 |
* a tertiary strength comparison. Both 'b' and 'B' are greater than 'a' and |
* a tertiary strength comparison. Both 'b' and 'B' are greater than 'a' and |
102 |
* 'A' during a primary strength comparison. But 'B' is greater than 'b' |
* 'A' during a primary strength comparison. But 'B' is greater than 'b' |
103 |
* under a tertiary strength comparison. |
* under a tertiary strength comparison. |
104 |
* <p> |
* <p> |
105 |
* "< a < c & a < b " - This sequence is identical in function to the |
* "< a < c & a < b " - This sequence is identical in function to the |
106 |
* "< a < b < c" rule string above. The '&' reset symbol indicates that |
* "< a < b < c" rule string above. The '&' reset symbol indicates that |
107 |
* the rule "< b" is to be inserted after the text argument "a" in the |
* the rule "< b" is to be inserted after the text argument "a" in the |
108 |
* previous rule string segment. |
* previous rule string segment. |
109 |
* <p> |
* <p> |
110 |
* "< a < b & y < z" - This is an error. The character 'y' does not appear |
* "< a < b & y < z" - This is an error. The character 'y' does not appear |
111 |
* anywhere in the previous rule string segment so the rule following the |
* anywhere in the previous rule string segment so the rule following the |
112 |
* reset rule cannot be inserted. |
* reset rule cannot be inserted. |
113 |
* <p> |
* <p> |
117 |
* As an additional complication to this already overly complex rule scheme, |
* As an additional complication to this already overly complex rule scheme, |
118 |
* if any characters precede the first rule, these characters are considered |
* if any characters precede the first rule, these characters are considered |
119 |
* ignorable. They will be treated as if they did not exist during |
* ignorable. They will be treated as if they did not exist during |
120 |
* comparisons. For example, "- < a < b ..." would make '-' an ignorable |
* comparisons. For example, "- < a < b ..." would make '-' an ignorable |
121 |
* character such that the strings "high-tech" and "hightech" would |
* character such that the strings "high-tech" and "hightech" would |
122 |
* be considered identical. |
* be considered identical. |
123 |
* <p> |
* <p> |
130 |
* the previous rule string section. |
* the previous rule string section. |
131 |
* </ul> |
* </ul> |
132 |
* |
* |
133 |
* @author Aaron M. Renn (arenn@urbanophile.com) |
* @author Aaron M. Renn <arenn@urbanophile.com> |
134 |
|
* @author Tom Tromey <tromey@cygnus.com> |
135 |
|
* @date March 25, 1999 |
136 |
*/ |
*/ |
137 |
public class RuleBasedCollator extends Collator |
public class RuleBasedCollator extends Collator |
138 |
{ |
{ |