Java 类java.text.CollationKey 实例源码

项目:openjdk-jdk10    文件:CollationKeyTestImpl.java   
private  void  InsertionSort(CollationKey[] keys){
    int f, i;
    CollationKey tmp;

    for (f=1; f < keys.length; f++){
        if(keys[f].compareTo( keys[f-1]) > 0){
            continue;
        }
        tmp = keys[f];
        i = f-1;
        while ( (i>=0) && (keys[i].compareTo(tmp) > 0) ) {
            keys[i+1] = keys[i];
            i--;
        }
        keys[i+1]=tmp;
    }
}
项目:openjdk9    文件:CollationKeyTestImpl.java   
private  void  InsertionSort(CollationKey[] keys){
    int f, i;
    CollationKey tmp;

    for (f=1; f < keys.length; f++){
        if(keys[f].compareTo( keys[f-1]) > 0){
            continue;
        }
        tmp = keys[f];
        i = f-1;
        while ( (i>=0) && (keys[i].compareTo(tmp) > 0) ) {
            keys[i+1] = keys[i];
            i--;
        }
        keys[i+1]=tmp;
    }
}
项目:ThriftyPaxos    文件:CompareModeDefault.java   
@Override
public int compareString(String a, String b, boolean ignoreCase) {
    if (ignoreCase) {
        // this is locale sensitive
        a = a.toUpperCase();
        b = b.toUpperCase();
    }
    int comp;
    if (collationKeys != null) {
        CollationKey aKey = getKey(a);
        CollationKey bKey = getKey(b);
        comp = aKey.compareTo(bKey);
    } else {
        comp = collator.compare(a, b);
    }
    return comp;
}
项目:gemfirexd-oss    文件:WorkHorseForCollatorDatatypes.java   
/** @see SQLChar#stringCompare(SQLChar, SQLChar) */
int stringCompare(SQLChar str1, SQLChar str2)
throws StandardException
{
    CollationKey ckey1 = str1.getCollationKey();
    CollationKey ckey2 = str2.getCollationKey();

    /*
    ** By convention, nulls sort High, and null == null
    */
    if (ckey1 == null || ckey2 == null)
    {
        if (ckey1 != null)  // str2 == null
            return -1;
        if (ckey2 != null)  // this == null
            return 1;
        return 0;           // both == null
    }

    return ckey1.compareTo(ckey2);
}
项目:LuckPerms    文件:CollationKeyCache.java   
public static int compareStrings(String o1, String o2) {
    //noinspection StringEquality
    if (o1 == o2) {
        return 0;
    }

    try {
        CollationKey o1c = CACHE.get(o1);
        CollationKey o2c = CACHE.get(o2);

        if (o1c != null && o2c != null) {
            int i = o1c.compareTo(o2c);
            if (i != 0) {
                return i;
            }
        }

        // fallback to standard string comparison
        return o1.compareTo(o2);
    } catch (Exception e) {
        // ignored
    }

    // shrug
    return 0;
}
项目:gemfirexd-oss    文件:WorkHorseForCollatorDatatypes.java   
/** @see SQLChar#stringCompare(SQLChar, SQLChar) */
int stringCompare(SQLChar str1, SQLChar str2)
throws StandardException
{
    CollationKey ckey1 = str1.getCollationKey();
    CollationKey ckey2 = str2.getCollationKey();

    /*
    ** By convention, nulls sort High, and null == null
    */
    if (ckey1 == null || ckey2 == null)
    {
        if (ckey1 != null)  // str2 == null
            return -1;
        if (ckey2 != null)  // this == null
            return 1;
        return 0;           // both == null
    }

    return ckey1.compareTo(ckey2);
}
项目:grafikon    文件:LocalizedStringListPM.java   
@Override
public Comparable<?> getComparable() {
    class DynamicTextComparable implements Comparable<DynamicTextComparable> {

        private CollationKey key;

        public DynamicTextComparable() {
            key = Collator.getInstance().getCollationKey(getText());
        }

        @Override
        public int compareTo(DynamicTextComparable o) {
            return key.compareTo(o.key);
        }
    }
    return new DynamicTextComparable();
}
项目:freeVM    文件:CollationKeyTest_ArrHash.java   
private void sort(CollationKey[] _keys) {

        boolean bool = false;
        while (bool == false) {
            bool = true;
            for (int i = 0; i < _keys.length - 1; i++) {
                if (_keys[i].compareTo(_keys[i + 1]) > 0) {
                    CollationKey CK = _keys[i];
                    _keys[i] = _keys[i + 1];
                    _keys[i + 1] = CK;
                    bool = false;
                }
            }
        }

        // for (int i = 0; i < _keys.length; i++) {
        // base.log.add(_keys[i].getSourceString());
        // }
    }
项目:freeVM    文件:CollationKeyTest.java   
private void sort(CollationKey[] _keys) {
    boolean bool = false;
    while (bool == false) {
        for (int i = 0; i < _keys.length - 1; i++) {
            bool = true;
            if (_keys[i].compareTo(_keys[i + 1]) > 0) {
                CollationKey CK = _keys[i];
                _keys[i] = _keys[i + 1];
                _keys[i + 1] = CK;
                bool = false;
            }
        }
    }

    for (int i = 0; i < _keys.length; i++) {
        // base.log.add(_keys[i].getSourceString());
    }
}
项目:WBSAirback    文件:NetworkComparator.java   
public int compare(Object value1, Object value2) {
    if(value1 instanceof String && value2 instanceof String) {
        String _key1 = String.valueOf(value1).trim();
        String _key2 = String.valueOf(value2).trim();
        if(_key1.startsWith("bond") && !_key2.startsWith("bond")) {
            return 1;
        } else if(_key2.startsWith("bond") && !_key1.startsWith("bond")) {
            return -1;
        } else if(_key1.startsWith("eth") && !_key2.startsWith("eth")) {
            return 1;
        } else if(_key2.startsWith("eth") && !_key1.startsWith("eth")) {
            return -1;
        }
        return _key1.compareTo(_key2);
    } else {
        Collator collator = Collator.getInstance();
    CollationKey key1 = collator.getCollationKey(value1.toString());
    CollationKey key2 = collator.getCollationKey(value2.toString());
    return key1.compareTo(key2);
    }
}
项目:spliceengine    文件:WorkHorseForCollatorDatatypes.java   
/** @see SQLChar#stringCompare(SQLChar, SQLChar) */
int stringCompare(SQLChar str1, SQLChar str2)
throws StandardException
{
    CollationKey ckey1 = str1.getCollationKey();
    CollationKey ckey2 = str2.getCollationKey();

    /*
    ** By convention, nulls sort High, and null == null
    */
    if (ckey1 == null || ckey2 == null)
    {
        if (ckey1 != null)  // str2 == null
            return -1;
        if (ckey2 != null)  // this == null
            return 1;
        return 0;           // both == null
    }

    return ckey1.compareTo(ckey2);
}
项目:spliceengine    文件:SQLChar.java   
public void    copyState
    (
     String otherValue,
     char[] otherRawData,
     int otherRawLength,
     CollationKey otherCKey,
     InputStream    otherStream,
     Clob otherClobValue,
     LocaleFinder otherLocaleFinder
     )
{
    value = otherValue;
    rawData = otherRawData;
    rawLength = otherRawLength;
    cKey = otherCKey;
    stream = otherStream;
    _clobValue = otherClobValue;
    localeFinder = otherLocaleFinder;
    isNull = evaluateNull();
}
项目:OpenJSharp    文件:ExecutableMemberDocImpl.java   
/**
 * Generate a key for sorting.
 */
@Override
CollationKey generateKey() {
    String k = name() + flatSignature() + typeParametersString();
    // ',' and '&' are between '$' and 'a':  normalize to spaces.
    k = k.replace(',', ' ').replace('&', ' ');
    // System.out.println("COLLATION KEY FOR " + this + " is \"" + k + "\"");
    return env.doclocale.collator.getCollationKey(k);
}
项目:OpenJSharp    文件:DocImpl.java   
/**
 * return a key for sorting.
 */
CollationKey key() {
    if (collationkey == null) {
        collationkey = generateKey();
    }
    return collationkey;
}
项目:openjdk-jdk10    文件:Utils.java   
private DocCollator(Locale locale, int strength) {
    instance = Collator.getInstance(locale);
    instance.setStrength(strength);

    keys = new LinkedHashMap<String, CollationKey>(MAX_SIZE + 1, 0.75f, true) {
        private static final long serialVersionUID = 1L;
        @Override
        protected boolean removeEldestEntry(Entry<String, CollationKey> eldest) {
            return size() > MAX_SIZE;
        }
    };
}
项目:openjdk-jdk10    文件:ExecutableMemberDocImpl.java   
/**
 * Generate a key for sorting.
 */
@Override
CollationKey generateKey() {
    String k = name() + flatSignature() + typeParametersString();
    // ',' and '&' are between '$' and 'a':  normalize to spaces.
    k = k.replace(',', ' ').replace('&', ' ');
    // System.out.println("COLLATION KEY FOR " + this + " is \"" + k + "\"");
    return env.doclocale.collator.getCollationKey(k);
}
项目:openjdk-jdk10    文件:DocImpl.java   
/**
 * return a key for sorting.
 */
CollationKey key() {
    if (collationkey == null) {
        collationkey = generateKey();
    }
    return collationkey;
}
项目:openjdk-jdk10    文件:APITest.java   
public final void TestCollationKey( )
{
    logln("testing CollationKey begins...");
    Collator col = null;
    try {
        col = Collator.getInstance(Locale.ROOT);
    } catch (Exception foo) {
        errln("Error : " + foo.getMessage());
        errln("Default collation creation failed.");
    }
    if (col == null) {
        return;
    }

    String test1 = "Abcda", test2 = "abcda";
    logln("Use tertiary comparison level testing ....");
    CollationKey sortk1 = col.getCollationKey(test1);
    CollationKey sortk2 = col.getCollationKey(test2);
    doAssert(sortk1.compareTo(sortk2) > 0,
                "Result should be \"Abcda\" >>> \"abcda\"");
    CollationKey sortk3 = sortk2;
    CollationKey sortkNew = sortk1;
    doAssert(sortk1 != sortk2, "The sort keys should be different");
    doAssert(sortk1.hashCode() != sortk2.hashCode(), "sort key hashCode() failed");
    doAssert(sortk2.compareTo(sortk3) == 0, "The sort keys should be the same");
    doAssert(sortk1 == sortkNew, "The sort keys assignment failed");
    doAssert(sortk1.hashCode() == sortkNew.hashCode(), "sort key hashCode() failed");
    doAssert(sortkNew != sortk3, "The sort keys should be different");
    doAssert(sortk1.compareTo(sortk3) > 0, "Result should be \"Abcda\" >>> \"abcda\"");
    doAssert(sortk2.compareTo(sortk3) == 0, "Result should be \"abcda\" == \"abcda\"");
    long    cnt1, cnt2;
    byte byteArray1[] = sortk1.toByteArray();
    byte byteArray2[] = sortk2.toByteArray();
    doAssert(byteArray1 != null && byteArray2 != null, "CollationKey.toByteArray failed.");
    logln("testing sortkey ends...");
}
项目:grammaticus    文件:TextUtil.java   
private CollationKey getCollationKey(String comp) {
    CollationKey key = cKeyMap.get(comp);
    if (key == null) {
        key = collator.getCollationKey(comp);
        cKeyMap.put(comp, key);
    }
    return key;
}
项目:openjdk9    文件:Utils.java   
private DocCollator(Locale locale, int strength) {
    instance = Collator.getInstance(locale);
    instance.setStrength(strength);

    keys = new LinkedHashMap<String, CollationKey>(MAX_SIZE + 1, 0.75f, true) {
        private static final long serialVersionUID = 1L;
        @Override
        protected boolean removeEldestEntry(Entry<String, CollationKey> eldest) {
            return size() > MAX_SIZE;
        }
    };
}
项目:openjdk9    文件:ExecutableMemberDocImpl.java   
/**
 * Generate a key for sorting.
 */
@Override
CollationKey generateKey() {
    String k = name() + flatSignature() + typeParametersString();
    // ',' and '&' are between '$' and 'a':  normalize to spaces.
    k = k.replace(',', ' ').replace('&', ' ');
    // System.out.println("COLLATION KEY FOR " + this + " is \"" + k + "\"");
    return env.doclocale.collator.getCollationKey(k);
}
项目:openjdk9    文件:DocImpl.java   
/**
 * return a key for sorting.
 */
CollationKey key() {
    if (collationkey == null) {
        collationkey = generateKey();
    }
    return collationkey;
}
项目:openjdk9    文件:APITest.java   
public final void TestCollationKey( )
{
    logln("testing CollationKey begins...");
    Collator col = null;
    try {
        col = Collator.getInstance(Locale.ROOT);
    } catch (Exception foo) {
        errln("Error : " + foo.getMessage());
        errln("Default collation creation failed.");
    }
    if (col == null) {
        return;
    }

    String test1 = "Abcda", test2 = "abcda";
    logln("Use tertiary comparison level testing ....");
    CollationKey sortk1 = col.getCollationKey(test1);
    CollationKey sortk2 = col.getCollationKey(test2);
    doAssert(sortk1.compareTo(sortk2) > 0,
                "Result should be \"Abcda\" >>> \"abcda\"");
    CollationKey sortk3 = sortk2;
    CollationKey sortkNew = sortk1;
    doAssert(sortk1 != sortk2, "The sort keys should be different");
    doAssert(sortk1.hashCode() != sortk2.hashCode(), "sort key hashCode() failed");
    doAssert(sortk2.compareTo(sortk3) == 0, "The sort keys should be the same");
    doAssert(sortk1 == sortkNew, "The sort keys assignment failed");
    doAssert(sortk1.hashCode() == sortkNew.hashCode(), "sort key hashCode() failed");
    doAssert(sortkNew != sortk3, "The sort keys should be different");
    doAssert(sortk1.compareTo(sortk3) > 0, "Result should be \"Abcda\" >>> \"abcda\"");
    doAssert(sortk2.compareTo(sortk3) == 0, "Result should be \"abcda\" == \"abcda\"");
    long    cnt1, cnt2;
    byte byteArray1[] = sortk1.toByteArray();
    byte byteArray2[] = sortk2.toByteArray();
    doAssert(byteArray1 != null && byteArray2 != null, "CollationKey.toByteArray failed.");
    logln("testing sortkey ends...");
}
项目:ThriftyPaxos    文件:CompareModeDefault.java   
private CollationKey getKey(String a) {
    synchronized (collationKeys) {
        CollationKey key = collationKeys.get(a);
        if (key == null) {
            key = collator.getCollationKey(a);
            collationKeys.put(a, key);
        }
        return key;
    }
}
项目:brailleback    文件:BrailleBackPreferencesActivity.java   
private CollationKey getCollationKey(TableInfo tableInfo) {
    CollationKey key = mCollationKeyMap.get(tableInfo);
    if (key == null) {
        key = mCollator.getCollationKey(
            tableInfo.getLocale().getDisplayName());
        mCollationKeyMap.put(tableInfo, key);
    }
    return key;
}
项目:gemfirexd-oss    文件:SQLChar.java   
/**
 * This method gets called for the collation sensitive char classes ie
 * CollatorSQLChar, CollatorSQLVarchar, CollatorSQLLongvarchar,
 * CollatorSQLClob. These collation sensitive chars need to have the 
 * collation key in order to do string comparison. And the collation key
 * is obtained using the Collator object that these classes already have.
 * 
 * @return CollationKey obtained using Collator on the string
 * @throws StandardException
 */
protected CollationKey getCollationKey() throws StandardException
{
    char tmpCharArray[];

    if (cKey != null)
        return cKey;

    if (rawLength == -1)
    {
        /* materialize the string if input is a stream */
        tmpCharArray = getCharArray();
        if (tmpCharArray == null)
            return null;
    }

    int lastNonspaceChar = rawLength;

    while (lastNonspaceChar > 0 && 
           rawData[lastNonspaceChar - 1] == '\u0020')
        lastNonspaceChar--;         // count off the trailing spaces.

    RuleBasedCollator rbc = getCollatorForCollation();      
    cKey = rbc.getCollationKey(new String(rawData, 0, lastNonspaceChar));

    return cKey;
}
项目:lookaside_java-1.8.0-openjdk    文件:ExecutableMemberDocImpl.java   
/**
 * Generate a key for sorting.
 */
@Override
CollationKey generateKey() {
    String k = name() + flatSignature() + typeParametersString();
    // ',' and '&' are between '$' and 'a':  normalize to spaces.
    k = k.replace(',', ' ').replace('&', ' ');
    // System.out.println("COLLATION KEY FOR " + this + " is \"" + k + "\"");
    return env.doclocale.collator.getCollationKey(k);
}
项目:lookaside_java-1.8.0-openjdk    文件:DocImpl.java   
/**
 * return a key for sorting.
 */
CollationKey key() {
    if (collationkey == null) {
        collationkey = generateKey();
    }
    return collationkey;
}
项目:jsr308-langtools    文件:ExecutableMemberDocImpl.java   
/**
 * Generate a key for sorting.
 */
@Override
CollationKey generateKey() {
    String k = name() + flatSignature() + typeParametersString();
    // ',' and '&' are between '$' and 'a':  normalize to spaces.
    k = k.replace(',', ' ').replace('&', ' ');
    // System.out.println("COLLATION KEY FOR " + this + " is \"" + k + "\"");
    return env.doclocale.collator.getCollationKey(k);
}
项目:jsr308-langtools    文件:DocImpl.java   
/**
 * return a key for sorting.
 */
CollationKey key() {
    if (collationkey == null) {
        collationkey = generateKey();
    }
    return collationkey;
}
项目:gemfirexd-oss    文件:SQLChar.java   
/**
 * This method gets called for the collation sensitive char classes ie
 * CollatorSQLChar, CollatorSQLVarchar, CollatorSQLLongvarchar,
 * CollatorSQLClob. These collation sensitive chars need to have the 
 * collation key in order to do string comparison. And the collation key
 * is obtained using the Collator object that these classes already have.
 * 
 * @return CollationKey obtained using Collator on the string
 * @throws StandardException
 */
protected CollationKey getCollationKey() throws StandardException
{
    char tmpCharArray[];

    if (cKey != null)
        return cKey;

    if (rawLength == -1)
    {
        /* materialize the string if input is a stream */
        tmpCharArray = getCharArray();
        if (tmpCharArray == null)
            return null;
    }

    int lastNonspaceChar = rawLength;

    while (lastNonspaceChar > 0 && 
           rawData[lastNonspaceChar - 1] == '\u0020')
        lastNonspaceChar--;         // count off the trailing spaces.

    RuleBasedCollator rbc = getCollatorForCollation();      
    cKey = rbc.getCollationKey(new String(rawData, 0, lastNonspaceChar));

    return cKey;
}
项目:form-follows-function    文件:ExecutableMemberDocImpl.java   
/**
 * Generate a key for sorting.
 */
CollationKey generateKey() {
    String k = name() + flatSignature() + typeParametersString();
    // ',' and '&' are between '$' and 'a':  normalize to spaces.
    k = k.replace(',', ' ').replace('&', ' ');
    // System.out.println("COLLATION KEY FOR " + this + " is \"" + k + "\"");
    return env.doclocale.collator.getCollationKey(k);
}
项目:form-follows-function    文件:DocImpl.java   
/**
 * return a key for sorting.
 */
CollationKey key() {
    if (collationkey == null) {
        collationkey = generateKey();
    }
    return collationkey;
}
项目:form-follows-function    文件:ExecutableMemberDocImpl.java   
/**
 * Generate a key for sorting.
 */
@Override
CollationKey generateKey() {
    String k = name() + flatSignature();
    // ',' and '&' are between '$' and 'a':  normalize to spaces.
    k = k.replace(',', ' ').replace('&', ' ');
    // System.out.println("COLLATION KEY FOR " + this + " is \"" + k + "\"");
    return env.doclocale.collator.getCollationKey(k);
}
项目:form-follows-function    文件:ProgramElementDocImpl.java   
/**
 * Generate a key for sorting.
 */
@Override
CollationKey generateKey() {
    String k = name();
    // System.out.println("COLLATION KEY FOR " + this + " is \"" + k + "\"");
    return env.doclocale.collator.getCollationKey(k);
}
项目:form-follows-function    文件:DocImpl.java   
/**
 * return a key for sorting.
 */
CollationKey key() {
    if (collationkey == null) {
        collationkey = generateKey();
    }
    return collationkey;
}
项目:infobip-open-jdk-8    文件:ExecutableMemberDocImpl.java   
/**
 * Generate a key for sorting.
 */
@Override
CollationKey generateKey() {
    String k = name() + flatSignature() + typeParametersString();
    // ',' and '&' are between '$' and 'a':  normalize to spaces.
    k = k.replace(',', ' ').replace('&', ' ');
    // System.out.println("COLLATION KEY FOR " + this + " is \"" + k + "\"");
    return env.doclocale.collator.getCollationKey(k);
}
项目:infobip-open-jdk-8    文件:DocImpl.java   
/**
 * return a key for sorting.
 */
CollationKey key() {
    if (collationkey == null) {
        collationkey = generateKey();
    }
    return collationkey;
}