Example usage for java.text Collator SECONDARY

List of usage examples for java.text Collator SECONDARY

Introduction

In this page you can find the example usage for java.text Collator SECONDARY.

Prototype

int SECONDARY

To view the source code for java.text Collator SECONDARY.

Click Source Link

Document

Collator strength value.

Usage

From source file:StringComparable.java

private static final int getMask(final int strength) {
    switch (strength) {
    case Collator.PRIMARY:
        return 0xFFFF0000;
    case Collator.SECONDARY:
        return 0xFFFFFF00;
    default:/*  www  . j  a v a  2s.  c  o  m*/
        return 0xFFFFFFFF;
    }
}

From source file:org.nuclos.common2.LangUtils.java

/**
 * @return the default <code>Collator</code> for this platform, that is the default <code>Collator</code>
 * for the default <code>Locale</code>. For international applications, this is the collation of choice.
 * Note that this is locale dependent.//from ww  w . j  av  a 2 s .com
 */
public static Collator getDefaultCollator() {
    if (collator == null) {
        collator = Collator.getInstance(SpringLocaleDelegate.getInstance().getLocale());
        collator.setStrength(Collator.SECONDARY);// a == A, a < 
    }
    return collator;
}

From source file:com.evolveum.midpoint.web.component.prism.ContainerValueWrapper.java

public void sort() {
    Locale locale = WebModelServiceUtils.getLocale();
    if (locale == null) {
        locale = Locale.getDefault();
    }/*from   w w w.  j av  a2 s  .  co m*/
    Collator collator = Collator.getInstance(locale);
    if (isSorted()) {
        collator.setStrength(Collator.SECONDARY); // e.g. "a" should be different from ""
        collator.setDecomposition(Collator.FULL_DECOMPOSITION); // slower but more precise

        Collections.sort(properties, new Comparator<ItemWrapper>() {
            @Override
            public int compare(ItemWrapper pw1, ItemWrapper pw2) {

                if (pw1 instanceof ContainerWrapper) {
                    ((ContainerWrapper) pw1).sort();
                }

                if (pw2 instanceof ContainerWrapper) {
                    ((ContainerWrapper) pw2).sort();
                }

                if (PropertyOrReferenceWrapper.class.isAssignableFrom(pw1.getClass())
                        && pw2 instanceof ContainerWrapper) {
                    return -1;
                }

                if (PropertyOrReferenceWrapper.class.isAssignableFrom(pw2.getClass())
                        && pw1 instanceof ContainerWrapper) {
                    return 1;
                }
                //               
                return compareByDisplayNames(pw1, pw2, collator);
            }
        });
    } else {
        Collections.sort(properties, new Comparator<ItemWrapper>() {
            @Override
            public int compare(ItemWrapper pw1, ItemWrapper pw2) {

                if (pw1 instanceof ContainerWrapper) {
                    ((ContainerWrapper) pw1).sort();
                }

                if (pw2 instanceof ContainerWrapper) {
                    ((ContainerWrapper) pw2).sort();
                }

                if (PropertyOrReferenceWrapper.class.isAssignableFrom(pw1.getClass())
                        && pw2 instanceof ContainerWrapper) {
                    return -1;
                }

                if (PropertyOrReferenceWrapper.class.isAssignableFrom(pw2.getClass())
                        && pw1 instanceof ContainerWrapper) {
                    return 1;
                }

                ItemDefinition id1 = pw1.getItemDefinition();
                ItemDefinition id2 = pw2.getItemDefinition();

                int displayOrder1 = (id1 == null || id1.getDisplayOrder() == null) ? Integer.MAX_VALUE
                        : id1.getDisplayOrder();
                int displayOrder2 = (id2 == null || id2.getDisplayOrder() == null) ? Integer.MAX_VALUE
                        : id2.getDisplayOrder();
                if (displayOrder1 == displayOrder2) {
                    return compareByDisplayNames(pw1, pw2, collator);
                } else {
                    return Integer.compare(displayOrder1, displayOrder2);
                }
            }
        });
    }

}

From source file:nl.inl.util.StringUtil.java

/**
 * Get a Dutch, case-insensitive collator.
 *
 * @return the Dutch, case-insensitive collator.
 *//*from  ww w .ja  v  a2s  .  co  m*/
public static Collator getDutchInsensitiveCollator() {
    if (dutchInsensitiveCollator == null) {
        dutchInsensitiveCollator = Collator.getInstance(dutchLocale);
        dutchInsensitiveCollator.setStrength(Collator.SECONDARY);
    }
    return dutchInsensitiveCollator;
}

From source file:nl.inl.util.StringUtil.java

/**
 * Get a Dutch, case-insensitive collator.
 *
 * @return the Dutch, case-insensitive collator.
 *//*from w w  w  . j  a  v  a  2 s.c o  m*/
public static Collator getEnglishInsensitiveCollator() {
    if (englishInsensitiveCollator == null) {
        englishInsensitiveCollator = Collator.getInstance(englishLocale);
        englishInsensitiveCollator.setStrength(Collator.SECONDARY);
    }
    return englishInsensitiveCollator;
}

From source file:org.nuxeo.directory.connector.SuggestDirectoryEntries.java

/**
 * @since 5.9.3/*from  w  w  w  .ja va2s.c  o  m*/
 */
protected Collator getCollator() {
    if (collator == null) {
        collator = Collator.getInstance(getLocale());
        if (caseSensitive) {
            collator.setStrength(Collator.TERTIARY);
        } else {
            collator.setStrength(Collator.SECONDARY);
        }
    }
    return collator;
}

From source file:nz.ac.otago.psyanlab.common.designer.ExperimentDesignerActivity.java

Collator getCollater() {
    Locale locale = Locale.getDefault();
    Collator collator = Collator.getInstance(locale);
    collator.setStrength(Collator.SECONDARY);
    return collator;
}