java.text.Collator Java Examples

The following examples show how to use java.text.Collator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CountryPickerDialog.java    From Android-country-picker with Apache License 2.0 6 votes vote down vote up
/**
 * You can set the heading country in headingCountryCode to show
 * your favorite country as the head of the list
 *
 * @param context
 * @param callbacks
 * @param headingCountryCode
 */
public CountryPickerDialog(Context context, CountryPickerCallbacks callbacks,
                           @Nullable String headingCountryCode, boolean showDialingCode) {
    super(context);
    this.callbacks = callbacks;
    this.headingCountryCode = headingCountryCode;
    this.showDialingCode = showDialingCode;
    countries = Utils.parseCountries(Utils.getCountriesJSON(this.getContext()));
    Collections.sort(countries, new Comparator<Country>() {
        @Override
        public int compare(Country country1, Country country2) {
            final Locale locale = getContext().getResources().getConfiguration().locale;
            final Collator collator = Collator.getInstance(locale);
            collator.setStrength(Collator.PRIMARY);
            return collator.compare(
                    new Locale(locale.getLanguage(), country1.getIsoCode()).getDisplayCountry(),
                    new Locale(locale.getLanguage(), country2.getIsoCode()).getDisplayCountry());
        }
    });
}
 
Example #2
Source File: HanziToPinyin.java    From KUtils-master with Apache License 2.0 6 votes vote down vote up
public static HanziToPinyin getInstance() {
    synchronized (HanziToPinyin.class) {
        if (sInstance != null) {
            return sInstance;
        }
        // Check if zh_CN collation data is available
        final Locale locale[] = Collator.getAvailableLocales();
        for (int i = 0; i < locale.length; i++) {
            if (locale[i].equals(Locale.CHINA)) {
                // Do self validation just once.
                if (DEBUG) {

                    android.util.Log.d(TAG, "Self validation. Result: " +
                            doSelfValidation());
                }
                sInstance = new HanziToPinyin(true);
                return sInstance;
            }
        }
        android.util.Log.w(TAG,
                "There is no Chinese collator, HanziToPinyin is disabled");
        sInstance = new HanziToPinyin(false);
        return sInstance;
    }
}
 
Example #3
Source File: IconPackActivity.java    From Taskbar with Apache License 2.0 6 votes vote down vote up
@Override
protected AppListAdapter doInBackground(Void... params) {
    List<IconPack> list = IconPackManager.getInstance().getAvailableIconPacks(IconPackActivity.this);
    if(list.isEmpty())
        return null;
    else {
        List<IconPack> finalList = new ArrayList<>();
        IconPack dummyIconPack = new IconPack();
        dummyIconPack.setPackageName(getPackageName());
        dummyIconPack.setName(getString(R.string.tb_icon_pack_none));

        Collections.sort(list, (ip1, ip2) -> Collator.getInstance().compare(ip1.getName(), ip2.getName()));

        finalList.add(dummyIconPack);
        finalList.addAll(list);

        return new AppListAdapter(IconPackActivity.this, R.layout.tb_row, finalList);
    }
}
 
Example #4
Source File: G7Test.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void TestDemoTest2() {
    final Collator myCollation = Collator.getInstance(Locale.US);
    final String defRules = ((RuleBasedCollator)myCollation).getRules();
    String newRules = defRules + "& C < ch , cH, Ch, CH";

    try {
        RuleBasedCollator tblColl = new RuleBasedCollator(newRules);
        for (int j = 0; j < TOTALTESTSET; j++) {
            for (int n = j+1; n < TOTALTESTSET; n++) {
                doTest(tblColl, testCases[Test2Results[j]],
                       testCases[Test2Results[n]], -1);
            }
        }
    } catch (Exception foo) {
        errln("Exception: " + foo.getMessage() +
              "\nDemo Test 2 Table Collation object creation failed.\n");
    }
}
 
Example #5
Source File: GraphObjectAdapter.java    From Klyph with MIT License 6 votes vote down vote up
private static int compareGraphObjects(GraphObject a, GraphObject b, Collection<String> sortFields,
        Collator collator) {
    for (String sortField : sortFields) {
        String sa = (String) a.getProperty(sortField);
        String sb = (String) b.getProperty(sortField);

        if (sa != null && sb != null) {
            int result = collator.compare(sa, sb);
            if (result != 0) {
                return result;
            }
        } else if (!(sa == null && sb == null)) {
            return (sa == null) ? -1 : 1;
        }
    }
    return 0;
}
 
Example #6
Source File: BrowseFolders.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
protected void addNotify() {
    super.addNotify();
    List<FileObject> l = new ArrayList<FileObject>();
    for (FileObject f : fo.getChildren()) {
        if (f.isFolder() && group.contains(f) && VisibilityQuery.getDefault().isVisible(f)) {
            l.add(f);
        }
    }
    Collections.sort(l, new Comparator<FileObject>() { // #116545
        Collator COLL = Collator.getInstance();
        @Override
        public int compare(FileObject f1, FileObject f2) {
            return COLL.compare(f1.getNameExt(), f2.getNameExt());
        }
    });
    setKeys(l);
}
 
Example #7
Source File: SurrogatesTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private Collator getCollator() {
    RuleBasedCollator base = (RuleBasedCollator)Collator.getInstance();
    String rule = base.getRules();
    try {
        return new RuleBasedCollator(rule
                                 + "&B < \ud800\udc01 < \ud800\udc00"
                                 + ", \ud800\udc02, \ud800\udc03"
                                 + "; \ud800\udc04, \ud800\udc05"
                                 + "< \ud800\udc06 < \ud800\udc07"
                                 + "&FE < \ud800\udc08"
                                 + "&PE, \ud800\udc09"
                                 + "&Z < \ud800\udc0a < \ud800\udc0b < \ud800\udc0c"
                                 + "&\ud800\udc0a < x, X"
                                 + "&A < \ud800\udc04\ud800\udc05");
    } catch (Exception e) {
        errln("Failed to create new RulebasedCollator object");
        return null;
    }
}
 
Example #8
Source File: SimpleListActivity.java    From dbclf with Apache License 2.0 6 votes vote down vote up
private void prepareListData() {
    listDataHeader = new ArrayList<>();
    listDataChild = new HashMap<>();

    Collections.addAll(listDataHeader, getResources().getStringArray(R.array.breeds_array));
    final String[] fileNames = getResources().getStringArray(R.array.file_names);

    // load file names
    for (int i = 0; i < listDataHeader.size(); i++) {
        listDataChild.put(listDataHeader.get(i), fileNames[i]);
    }

    if (null != recogs) {
        listDataHeader = new ArrayList<>();
        listDataHeader.addAll(recogs);
        expListView.setFastScrollAlwaysVisible(false);
    } else {
        final Collator coll = Collator.getInstance(Locale.getDefault());
        coll.setStrength(Collator.PRIMARY);
        Collections.sort(listDataHeader, coll);
        expListView.setFastScrollAlwaysVisible(true);
    }
}
 
Example #9
Source File: Util.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Order projects by display name.
 */
public static Comparator<Project> projectDisplayNameComparator() {
    return new Comparator<Project>() {
        private final Collator LOC_COLLATOR = Collator.getInstance();
        public int compare(Project o1, Project o2) {
            ProjectInformation i1 = ProjectUtils.getInformation(o1);
            ProjectInformation i2 = ProjectUtils.getInformation(o2);
            int result = LOC_COLLATOR.compare(i1.getDisplayName(), i2.getDisplayName());
            if (result != 0) {
                return result;
            } else {
                result = i1.getName().compareTo(i2.getName());
                if (result != 0) {
                    return result;
                } else {
                    return System.identityHashCode(o1) - System.identityHashCode(o2);
                }
            }
        }
    };
}
 
Example #10
Source File: HanziToPinyin.java    From Contacts with Apache License 2.0 6 votes vote down vote up
public static HanziToPinyin getInstance() {
    synchronized (HanziToPinyin.class) {
        if (sInstance != null) {
            return sInstance;
        }
        // Check if zh_CN collation data is available
        final Locale locale[] = Collator.getAvailableLocales();
        for (int i = 0; i < locale.length; i++) {
            if (locale[i].equals(Locale.CHINESE)) {
                // Do self validation just once.
                if (DEBUG) {
                    Log.d(TAG, "Self validation. Result: " + doSelfValidation());
                }
                sInstance = new HanziToPinyin(true);
                return sInstance;
            }
        }
        Log.w(TAG, "There is no Chinese collator, HanziToPinyin is disabled");
        sInstance = new HanziToPinyin(false);
        return sInstance;
    }
}
 
Example #11
Source File: TrackIcon.java    From gpx-animator with Apache License 2.0 6 votes vote down vote up
@SuppressFBWarnings(value = "DC_DOUBLECHECK", justification = "Before and after synchronization") //NON-NLS
public static Vector<TrackIcon> getAllTrackIcons() {
    if (trackIcons == null) {
        synchronized (TrackIcon.class) {
            if (trackIcons == null) {
                trackIcons = new Vector<>();
                for (final String key : KEYS) {
                    trackIcons.add(new TrackIcon(key, RESOURCE_BUNDLE.getString(RESOURCE_BUNDLE_TRACKICON_PREFIX.concat(key))));
                }
                final Collator collator = Collator.getInstance();
                trackIcons.sort((a, b) -> collator.compare(a.name, b.name));
                trackIcons.add(0, new TrackIcon("", ""));
            }
        }
    }
    return trackIcons;
}
 
Example #12
Source File: Table.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Sorts the foreign keys alphabetically.
 * 
 * @param caseSensitive Whether case matters
 */
public void sortForeignKeys(final boolean caseSensitive)
{
    if (!_foreignKeys.isEmpty())
    {
        final Collator collator = Collator.getInstance();

        Collections.sort(_foreignKeys, new Comparator() {
            public int compare(Object obj1, Object obj2)
            {
                String fk1Name = ((ForeignKey)obj1).getName();
                String fk2Name = ((ForeignKey)obj2).getName();

                if (!caseSensitive)
                {
                    fk1Name = (fk1Name != null ? fk1Name.toLowerCase() : null);
                    fk2Name = (fk2Name != null ? fk2Name.toLowerCase() : null);
                }
                return collator.compare(fk1Name, fk2Name);
            }
        });
    }
}
 
Example #13
Source File: SurrogatesTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private Collator getCollator() {
    RuleBasedCollator base = (RuleBasedCollator)Collator.getInstance();
    String rule = base.getRules();
    try {
        return new RuleBasedCollator(rule
                                 + "&B < \ud800\udc01 < \ud800\udc00"
                                 + ", \ud800\udc02, \ud800\udc03"
                                 + "; \ud800\udc04, \ud800\udc05"
                                 + "< \ud800\udc06 < \ud800\udc07"
                                 + "&FE < \ud800\udc08"
                                 + "&PE, \ud800\udc09"
                                 + "&Z < \ud800\udc0a < \ud800\udc0b < \ud800\udc0c"
                                 + "&\ud800\udc0a < x, X"
                                 + "&A < \ud800\udc04\ud800\udc05");
    } catch (Exception e) {
        errln("Failed to create new RulebasedCollator object");
        return null;
    }
}
 
Example #14
Source File: GroupManagerActivity.java    From Aegis with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_groups);

    Intent intent = getIntent();
    _groups = new TreeSet<>(Collator.getInstance());
    _groups.addAll(intent.getStringArrayListExtra("groups"));

    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setDisplayShowHomeEnabled(true);
    }

    // set up the recycler view
    _adapter = new GroupAdapter(this);
    RecyclerView slotsView = findViewById(R.id.list_slots);
    LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    slotsView.setLayoutManager(layoutManager);
    slotsView.setAdapter(_adapter);
    slotsView.setNestedScrollingEnabled(false);

    for (String group : _groups) {
        _adapter.addGroup(group);
    }
}
 
Example #15
Source File: RightsPanel.java    From nextreports-server with Apache License 2.0 6 votes vote down vote up
private ArrayList<String> getNames(String type) {
	ArrayList<String> names = new ArrayList<String>();
	if (type.equals(AuditRights.USER_TYPE)) {
      	User[] users = securityService.getUsers();
      	for (User user : users) {
      		if (!user.isAdmin()) {
      			names.add(user.getUsername());
      		}
           }
       } else {
       	Group[] groups = securityService.getGroups();     
       	for (Group group : groups) {
       		names.add(group.getGroupname());
       	}
       }
	Collections.sort(names, new Comparator<String>() {
		@Override
		public int compare(String s1, String s2) {
			return Collator.getInstance().compare(s1, s2);
		}			
	});
	return names;
}
 
Example #16
Source File: AutocompletingStringConstraintEditor.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public List<String> getMatchingData(String searchText) {
	if (StringUtils.isBlank(searchText) || !isValidPatternString(searchText)) {
		return Collections.emptyList();
	}
	searchText = searchText.trim();
	lastConstraint =
		(StringColumnConstraint) currentConstraint.parseConstraintValue(searchText,
			columnDataSource.getTableDataSource());

	// Use a Collator to support languages other than English.
	Collator collator = Collator.getInstance();
	collator.setStrength(Collator.SECONDARY);

	// @formatter:off
	return dataSet.stream()
			.filter(k -> lastConstraint.accepts(k, null))
			.sorted( (k1, k2) -> collator.compare(k1,  k2))
			.collect(Collectors.toList());
	// @formatter:on
}
 
Example #17
Source File: ListAdapter.java    From dbclf with Apache License 2.0 6 votes vote down vote up
ListAdapter(Context context, List<String> listDataHeader,
            HashMap<String, String> listChildData) {
    this.context = context;
    this.listDataHeader = listDataHeader;
    this.listDataChild = listChildData;

    // HashMap will prevent duplicates
    mapIndex = new LinkedHashMap<String, Integer>();
    for (int i = listDataHeader.size() - 1; i >= 0; i--) {
        mapIndex.put(listDataHeader.get(i).substring(0, 1).toUpperCase(Locale.getDefault()), i);
    }

    // create a list from the set to sort
    final ArrayList<String> sectionList = new ArrayList<String>(mapIndex.keySet());

    final Collator coll = Collator.getInstance(Locale.getDefault());
    coll.setStrength(Collator.PRIMARY);
    Collections.sort(sectionList, coll);

    sections = new String[sectionList.size()];

    sectionList.toArray(sections);
}
 
Example #18
Source File: GraphObjectAdapter.java    From aws-mobile-self-paced-labs-samples with Apache License 2.0 6 votes vote down vote up
private static int compareGraphObjects(GraphObject a, GraphObject b, Collection<String> sortFields,
        Collator collator) {
    for (String sortField : sortFields) {
        String sa = (String) a.getProperty(sortField);
        String sb = (String) b.getProperty(sortField);

        if (sa != null && sb != null) {
            int result = collator.compare(sa, sb);
            if (result != 0) {
                return result;
            }
        } else if (!(sa == null && sb == null)) {
            return (sa == null) ? -1 : 1;
        }
    }
    return 0;
}
 
Example #19
Source File: PreferenceUtil.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 获取项目属性的文本字段
 * @return ;
 */
public static ArrayList<String> getProjectFieldList() {
	IPreferenceStore store = Activator.getDefault().getPreferenceStore();
	ArrayList<String> lstField = new ArrayList<String>();
	int fieldCount = store
			.getInt("net.heartsome.cat.ts.ui.preferencepage.ProjectPropertiesPreferencePage.fieldCount");
	if (fieldCount > 0) {
		for (int i = 0; i < fieldCount; i++) {
			lstField.add(store
					.getString("net.heartsome.cat.ts.ui.preferencepage.ProjectPropertiesPreferencePage.field" + i));
		}
	}
	// 对中文按拼音排序
	Collator collatorChinese = Collator.getInstance(java.util.Locale.CHINA);
	Collections.sort(lstField, collatorChinese);
	return lstField;
}
 
Example #20
Source File: Collation.java    From evosql with Apache License 2.0 6 votes vote down vote up
private Collation(String name, String language, String country,
                  int strength, int decomposition, boolean ucc) {

    locale   = new Locale(language, country);
    collator = Collator.getInstance(locale);

    if (strength >= 0) {
        collator.setStrength(strength);
    }

    if (decomposition >= 0) {
        collator.setDecomposition(decomposition);
    }

    strength        = collator.getStrength();
    isUnicodeSimple = false;
    this.name = HsqlNameManager.newInfoSchemaObjectName(name, true,
            SchemaObject.COLLATION);
    charset            = Charset.SQL_TEXT;
    isUpperCaseCompare = ucc;
    isFinal            = true;
}
 
Example #21
Source File: SnapshotsWindowUI.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
public int compareTo(Object o) {
    Snapshot s = (Snapshot)o;
    // Alternative sorting: when sorting by snapshot type, the secondary
    // sorting sorts custom-named snapshots alphabetically and default-named
    // snapshots by timestamp, newest first. Custom-named snapshots display
    // above the default-named snapshots.
    if (alternativeSorting()) {
        if (customName) {
            if (!s.customName) return -1;
            else return Collator.getInstance().compare(getDisplayName(), s.getDisplayName());
        } else {
            if (s.customName) return 1;
            else return Long.compare(timestamp, s.timestamp);
        }
    } else {
        return Collator.getInstance().compare(getDisplayName(), s.getDisplayName());
    }
}
 
Example #22
Source File: DefaultAnalysisService.java    From nextreports-server with Apache License 2.0 6 votes vote down vote up
private List<Analysis> getAnalysis(Entity[] entities, String tableName) {       
    List<Analysis> analysis = new ArrayList<Analysis>();
    for (Entity entity : entities) {         
    	Analysis a = (Analysis)entity;
    	if (tableName != null) {
    		if (a.getTableName().equals(tableName)) {
    			analysis.add(a);
    		}
    	} else {
    		analysis.add(a);
    	}
    }
    Collections.sort(analysis, new Comparator<Analysis>() {

        public int compare(Analysis o1, Analysis o2) {                
            return Collator.getInstance().compare(o1.getName(), o2.getName());                
        }
    });
    return analysis;
}
 
Example #23
Source File: Authority.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public AuthorityComparator(String sortBy, boolean sortAsc)
{
    col = Collator.getInstance(I18NUtil.getLocale());
    this.sortBy = sortBy;
    this.nameCache = new HashMap<Authority, String>();
    if (!sortAsc)
    {
        orderMultiplicator = -1;
    }
}
 
Example #24
Source File: Natural.java    From jease with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Smart compare of two objects: numbers and dates will compared by value,
 * for all other objects a natural comparision of string-values will be
 * used.
 */
public static int compare(Object o1, Object o2) {
	if (o1 instanceof Number && o2 instanceof Number) {
		return Double.compare(((Number) o1).doubleValue(),
				((Number) o2).doubleValue());
	}

	if (o1 instanceof Date && o2 instanceof Date) {
		return ((Date) o1).compareTo(((Date) o2));
	}

	return compareObjects(String.valueOf(o1), String.valueOf(o2),
			Collator.getInstance());
}
 
Example #25
Source File: MonkeyTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void TestCompare()
{
    String source = "-abcdefghijklmnopqrstuvwxyz#&^$@";
    Random r = new Random(3);
    int s = checkValue(r.nextInt() % source.length());
    int t = checkValue(r.nextInt() % source.length());
    int slen = checkValue((r.nextInt() - source.length()) % source.length());
    int tlen = checkValue((r.nextInt() - source.length()) % source.length());
    String subs = source.substring((s > slen ? slen : s), (s >= slen ? s : slen));
    String subt = source.substring((t > tlen ? tlen : t), (t >= tlen ? t : tlen));
    myCollator.setStrength(Collator.TERTIARY);
    int result = myCollator.compare(subs, subt);  // Tertiary
    int revResult = myCollator.compare(subt, subs);  // Tertiary
    report(subs, subt, result, revResult);
    myCollator.setStrength(Collator.SECONDARY);
    result = myCollator.compare(subs, subt);  // Secondary
    revResult = myCollator.compare(subt, subs);  // Secondary
    report(subs, subt, result, revResult);
    myCollator.setStrength(Collator.PRIMARY);
    result = myCollator.compare(subs, subt);  // Primary
    revResult = myCollator.compare(subt, subs);  // Primary
    report(subs, subt, result, revResult);
    String addOne = subs + "\uE000";
    result = myCollator.compare(subs, addOne);
    if (result != -1)
        errln("Test : " + subs + " .LT. " + addOne + " Failed.");
    result = myCollator.compare(addOne, subs);
    if (result != 1)
        errln("Test : " + addOne + " .GE. " + subs + " Failed.");
}
 
Example #26
Source File: CustomizerRun.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Comparator<String> getComparator() {
    return new Comparator<String>() {
        Collator coll = Collator.getInstance();

        @Override
        public int compare(String s1, String s2) {
            String lbl1 = configurationFor(s1).getDisplayName();
            String lbl2 = configurationFor(s2).getDisplayName();
            return coll.compare(lbl1, lbl2);
        }
    };
}
 
Example #27
Source File: GlobalsTwoPanelElementSelector2.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Comparator<AdditionalInfoAndIInfo> getItemsComparator() {
    return new Comparator<AdditionalInfoAndIInfo>() {

        /*
         * (non-Javadoc)
         *
         * @see java.util.Comparator#compare(java.lang.Object,
         *      java.lang.Object)
         */
        @Override
        public int compare(AdditionalInfoAndIInfo resource1, AdditionalInfoAndIInfo resource2) {
            Collator collator = Collator.getInstance();
            String s1 = resource1.info.getName();
            String s2 = resource2.info.getName();
            int comparability = collator.compare(s1, s2);
            //same name
            if (comparability == 0) {
                String p1 = resource1.info.getDeclaringModuleName();
                String p2 = resource2.info.getDeclaringModuleName();
                if (p1 == null && p2 == null) {
                    return 0;
                }
                if (p1 != null && p2 == null) {
                    return -1;
                }
                if (p1 == null && p2 != null) {
                    return 1;
                }
                return p1.compareTo(p2);
            }

            return comparability;
        }
    };
}
 
Example #28
Source File: APITest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public final void TestGetAll()
{
    Locale[] list = Collator.getAvailableLocales();
    for (int i = 0; i < list.length; ++i) {
        log("Locale name: ");
        log(list[i].toString());
        log(" , the display name is : ");
        logln(list[i].getDisplayName());
    }
}
 
Example #29
Source File: StringComparable.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public StringComparable(final String text, final Locale locale, final Collator collator, final String caseOrder){
     m_text =  text;
     m_locale = locale;
     m_collator = (RuleBasedCollator)collator;
     m_caseOrder = caseOrder;
     m_mask = getMask(m_collator.getStrength());
}
 
Example #30
Source File: NativeString.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ECMA 15.5.4.9 String.prototype.localeCompare (that)
 * @param self self reference
 * @param that comparison object
 * @return result of locale sensitive comparison operation between {@code self} and {@code that}
 */
@Function(attributes = Attribute.NOT_ENUMERABLE)
public static Object localeCompare(final Object self, final Object that) {

    final String   str      = checkObjectToString(self);
    final Collator collator = Collator.getInstance(Global.getEnv()._locale);

    collator.setStrength(Collator.IDENTICAL);
    collator.setDecomposition(Collator.CANONICAL_DECOMPOSITION);

    return (double)collator.compare(str, JSType.toString(that));
}