177 |
public RuleBasedCollator (String rules) throws ParseException |
public RuleBasedCollator (String rules) throws ParseException |
178 |
{ |
{ |
179 |
if (rules.equals ("")) |
if (rules.equals ("")) |
180 |
throw new ParseException ("empty rule set", 0); |
throw new IllegalArgumentException ("Empty rule set"); |
181 |
|
|
182 |
this.rules = rules; |
this.rules = rules; |
183 |
Vector vec = new Vector(); |
Vector vec = new Vector(); |
196 |
if (Character.isWhitespace (c)) |
if (Character.isWhitespace (c)) |
197 |
continue; |
continue; |
198 |
|
|
199 |
// Primary difference. |
// Primary difference |
200 |
if (c == '<') |
if (c == '<') |
201 |
{ |
{ |
202 |
ignore_chars = false; |
ignore_chars = false; |
212 |
continue; |
continue; |
213 |
} |
} |
214 |
|
|
215 |
// Secondary difference. |
// Secondary difference |
216 |
if (c == ';') |
if (c == ';') |
217 |
{ |
{ |
218 |
if (primary_seq == 0) |
if (primary_seq == 0) |
229 |
continue; |
continue; |
230 |
} |
} |
231 |
|
|
232 |
// Tertiary difference. |
// Tertiary difference |
233 |
if (c == ',') |
if (c == ',') |
234 |
{ |
{ |
235 |
if (primary_seq == 0) |
if (primary_seq == 0) |
236 |
throw new ParseException (rules, index); |
throw new ParseException (rules, index); |
237 |
|
|
238 |
CollationElement e = new CollationElement (argument.toString(), |
CollationElement e = new CollationElement (argument.toString(), primary_seq, |
|
primary_seq, |
|
239 |
secondary_seq, |
secondary_seq, |
240 |
tertiary_seq); |
tertiary_seq); |
241 |
++tertiary_seq; |
++tertiary_seq; |
245 |
continue; |
continue; |
246 |
} |
} |
247 |
|
|
248 |
// Is equal to. |
// Is equal to |
249 |
if (c == '=') |
if (c == '=') |
250 |
{ |
{ |
251 |
if (primary_seq == 0) |
if (primary_seq == 0) |
252 |
throw new ParseException (rules, index); |
throw new ParseException (rules, index); |
253 |
|
|
254 |
CollationElement e = new CollationElement (argument.toString(), |
CollationElement e = new CollationElement (argument.toString(), primary_seq, |
|
primary_seq, |
|
255 |
secondary_seq, |
secondary_seq, |
256 |
tertiary_seq); |
tertiary_seq); |
257 |
vec.add (e); |
vec.add (e); |
259 |
continue; |
continue; |
260 |
} |
} |
261 |
|
|
262 |
// Sort accents backwards. |
// Sort accents backwards |
263 |
if (c == '@') |
if (c == '@') |
264 |
{ |
{ |
265 |
throw new ParseException ("French style accents not implemented yet", 0); |
throw new ParseException("French style accents not implemented yet", 0); |
266 |
} |
} |
267 |
|
|
268 |
// Reset command. |
// Reset command |
269 |
if (c == '&') |
if (c == '&') |
270 |
{ |
{ |
271 |
throw new ParseException ("Reset not implemented yet", 0); |
throw new ParseException("Reset not implemented yet", 0); |
272 |
} |
} |
273 |
|
|
274 |
// See if we are still reading characters to skip. |
// See if we are still reading characters to skip |
275 |
if (ignore_chars == true) |
if (ignore_chars == true) |
276 |
{ |
{ |
277 |
CollationElement e = new CollationElement (c + "", 0, (short) 0, |
CollationElement e = new CollationElement (c + "", 0, (short)0, |
278 |
(short) 0); |
(short)0); |
279 |
vec.add (e); |
vec.add(e); |
280 |
continue; |
continue; |
281 |
} |
} |
282 |
|
|