if (rules.equals("")) throw new IllegalArgumentException("Empty rule set");  Vector v = new Vector(); boolean ignore_chars = true; int primary_seq = 0; short secondary_seq = 0; short tertiary_seq = 0; StringBuffer sb = new StringBuffer(""); for (int i = 0; i < rules.length(); i++) { char c = rules.charAt(i);   if (((c >= 0x09) && (c <= 0x0D)) || (c == 0x20)) continue;   if (c == '<') { ignore_chars = false; secondary_seq = 0; tertiary_seq = 0; ++primary_seq;  CollationElement e = new CollationElement(sb.toString(), primary_seq, secondary_seq, tertiary_seq); v.add(e); sb.setLength(0); continue; }   if (c == ';') { if (primary_seq == 0) throw new ParseException(rules, i);  ++secondary_seq; tertiary_seq = 0;  CollationElement e = new CollationElement(sb.toString(), primary_seq, secondary_seq, tertiary_seq); v.add(e); sb.setLength(0); continue; }   if (c == ',') { if (primary_seq == 0) throw new ParseException(rules, i);  ++tertiary_seq;  CollationElement e = new CollationElement(sb.toString(), primary_seq, secondary_seq, tertiary_seq); v.add(e); sb.setLength(0); continue; }   if (c == '=') { if (primary_seq == 0) throw new ParseException(rules, i);  CollationElement e = new CollationElement(sb.toString(), primary_seq, secondary_seq, tertiary_seq); v.add(e); sb.setLength(0); continue; }   if (c == '@') { throw new ParseException("French style accents not implemented yet", 0); }   if (c == '&') { throw new ParseException("Reset not implemented yet", 0); }   if (ignore_chars == true) { CollationElement e = new CollationElement(c + "", 0, (short)0, (short)0); v.add(e); continue; }  sb.append(c); }  ce_table = v.toArray(); }
buildCollationVector(parseString(rules)); buildPrefixAccess(); }
RuleBasedCollator(String rules) throws ParseException{  this.rules = rules;  if (rules.equals(""))    throw new IllegalArgumentException("Empty rule set");  Vector v = new Vector();  boolean ignore_chars = true;  int primary_seq = 0;  short secondary_seq = 0;  short tertiary_seq = 0;  StringBuffer sb = new StringBuffer("");  for (int i = 0; i < rules.length(); i++)    {      char c = rules.charAt(i);      // Check if it is a whitespace character      if (((c >= 0x09) && (c <= 0x0D)) || (c == 0x20))        continue;      // Primary difference      if (c == '<')        {          ignore_chars = false;          secondary_seq = 0;          tertiary_seq = 0;          ++primary_seq;          CollationElement e = new CollationElement(sb.toString(), primary_seq,                                                    secondary_seq,                                                    tertiary_seq);          v.add(e);          sb.setLength(0);          continue;        }      // Secondary difference      if (c == ';')        {          if (primary_seq == 0)            throw new ParseException(rules, i);          ++secondary_seq;          tertiary_seq = 0;          CollationElement e = new CollationElement(sb.toString(), primary_seq,                                                    secondary_seq,                                                    tertiary_seq);          v.add(e);          sb.setLength(0);          continue;        }      // Tertiary difference      if (c == ',')        {          if (primary_seq == 0)            throw new ParseException(rules, i);          ++tertiary_seq;          CollationElement e = new CollationElement(sb.toString(), primary_seq,                                                    secondary_seq,                                                    tertiary_seq);          v.add(e);          sb.setLength(0);          continue;        }      // Is equal to      if (c == '=')        {          if (primary_seq == 0)            throw new ParseException(rules, i);          CollationElement e = new CollationElement(sb.toString(), primary_seq,                                                    secondary_seq,                                                    tertiary_seq);          v.add(e);          sb.setLength(0);          continue;        }      // Sort accents backwards      if (c == '@')        {          throw new ParseException("French style accents not implemented yet", 0);        }      // Reset command      if (c == '&')        {          throw new ParseException("Reset not implemented yet", 0);        }      // See if we are still reading characters to skip      if (ignore_chars == true)        {          CollationElement e = new CollationElement(c + "", 0, (short)0,                                                     (short)0);          v.add(e);          continue;        }      sb.append(c);    }  ce_table = v.toArray();}