public String toPattern(UnicodeSet uset) {
first = true;
UnicodeSet putAtEnd = new UnicodeSet(uset).retainAll(sortAtEnd); // remove all the unassigned gorp for now
// make sure that comparison separates all strings, even canonically equivalent ones
Set orderedStrings = new TreeSet(ordering);
for (UnicodeSetIterator it = new UnicodeSetIterator(uset); it.nextRange();) {
if (it.codepoint == it.IS_STRING) {
orderedStrings.add(it.string);
} else {
for (int i = it.codepoint; i <= it.codepointEnd; ++i) {
if (!putAtEnd.contains(i)) {
orderedStrings.add(UTF16.valueOf(i));
}
}
}
}
target.setLength(0);
target.append("[");
for (Iterator it = orderedStrings.iterator(); it.hasNext();) {
appendUnicodeSetItem((String) it.next());
}
for (UnicodeSetIterator it = new UnicodeSetIterator(putAtEnd); it.next();) { // add back the unassigned gorp
appendUnicodeSetItem(it.codepoint);
}
flushLast();
target.append("]");
String sresult = target.toString();