當前位置: 首頁>>代碼示例>>Java>>正文


Java CollationKey類代碼示例

本文整理匯總了Java中java.text.CollationKey的典型用法代碼示例。如果您正苦於以下問題:Java CollationKey類的具體用法?Java CollationKey怎麽用?Java CollationKey使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CollationKey類屬於java.text包,在下文中一共展示了CollationKey類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: InsertionSort

import java.text.CollationKey; //導入依賴的package包/類
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;
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:18,代碼來源:CollationKeyTestImpl.java

示例2: compareString

import java.text.CollationKey; //導入依賴的package包/類
@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;
}
 
開發者ID:vdr007,項目名稱:ThriftyPaxos,代碼行數:18,代碼來源:CompareModeDefault.java

示例3: stringCompare

import java.text.CollationKey; //導入依賴的package包/類
/** @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);
}
 
開發者ID:gemxd,項目名稱:gemfirexd-oss,代碼行數:22,代碼來源:WorkHorseForCollatorDatatypes.java

示例4: compareStrings

import java.text.CollationKey; //導入依賴的package包/類
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;
}
 
開發者ID:lucko,項目名稱:LuckPerms,代碼行數:27,代碼來源:CollationKeyCache.java

示例5: getComparable

import java.text.CollationKey; //導入依賴的package包/類
@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();
}
 
開發者ID:jub77,項目名稱:grafikon,代碼行數:18,代碼來源:LocalizedStringListPM.java

示例6: sort

import java.text.CollationKey; //導入依賴的package包/類
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());
        // }
    }
 
開發者ID:freeVM,項目名稱:freeVM,代碼行數:20,代碼來源:CollationKeyTest_ArrHash.java

示例7: sort

import java.text.CollationKey; //導入依賴的package包/類
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());
    }
}
 
開發者ID:freeVM,項目名稱:freeVM,代碼行數:19,代碼來源:CollationKeyTest.java

示例8: compare

import java.text.CollationKey; //導入依賴的package包/類
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);
	}
}
 
開發者ID:WhiteBearSolutions,項目名稱:WBSAirback,代碼行數:22,代碼來源:NetworkComparator.java

示例9: evaluateNull

import java.text.CollationKey; //導入依賴的package包/類
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();
}
 
開發者ID:splicemachine,項目名稱:spliceengine,代碼行數:21,代碼來源:SQLChar.java

示例10: generateKey

import java.text.CollationKey; //導入依賴的package包/類
/**
 * 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);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:12,代碼來源:ExecutableMemberDocImpl.java

示例11: key

import java.text.CollationKey; //導入依賴的package包/類
/**
 * return a key for sorting.
 */
CollationKey key() {
    if (collationkey == null) {
        collationkey = generateKey();
    }
    return collationkey;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:10,代碼來源:DocImpl.java

示例12: DocCollator

import java.text.CollationKey; //導入依賴的package包/類
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;
        }
    };
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:13,代碼來源:Utils.java

示例13: TestCollationKey

import java.text.CollationKey; //導入依賴的package包/類
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...");
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:37,代碼來源:APITest.java

示例14: TestCollationKey

import java.text.CollationKey; //導入依賴的package包/類
public void TestCollationKey()
{
    String source = "-abcdefghijklmnopqrstuvwxyz#&^[email protected]";
    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);
    CollationKey CollationKey1 = myCollator.getCollationKey(subs);
    CollationKey CollationKey2 = myCollator.getCollationKey(subt);
    int result = CollationKey1.compareTo(CollationKey2);  // Tertiary
    int revResult = CollationKey2.compareTo(CollationKey1);  // Tertiary
    report(("CollationKey(" + subs + ")"), ("CollationKey(" + subt + ")"), result, revResult);
    myCollator.setStrength(Collator.SECONDARY);
    CollationKey1 = myCollator.getCollationKey(subs);
    CollationKey2 = myCollator.getCollationKey(subt);
    result = CollationKey1.compareTo(CollationKey2);  // Secondary
    revResult = CollationKey2.compareTo(CollationKey1);   // Secondary
    report(("CollationKey(" + subs + ")") , ("CollationKey(" + subt + ")"), result, revResult);
    myCollator.setStrength(Collator.PRIMARY);
    CollationKey1 = myCollator.getCollationKey(subs);
    CollationKey2 = myCollator.getCollationKey(subt);
    result = CollationKey1.compareTo(CollationKey2);  // Primary
    revResult = CollationKey2.compareTo(CollationKey1);   // Primary
    report(("CollationKey(" + subs + ")"), ("CollationKey(" + subt + ")"), result, revResult);
    String addOne = subs + "\uE000";
    CollationKey1 = myCollator.getCollationKey(subs);
    CollationKey2 = myCollator.getCollationKey(addOne);
    result = CollationKey1.compareTo(CollationKey2);
    if (result != -1)
        errln("CollationKey(" + subs + ")" + ".LT." + "CollationKey(" + addOne + ") Failed.");
    result = CollationKey2.compareTo(CollationKey1);
    if (result != 1)
        errln("CollationKey(" + addOne + ")" + ".GT." + "CollationKey(" + subs + ") Failed.");
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:39,代碼來源:MonkeyTest.java

示例15: getCollationKey

import java.text.CollationKey; //導入依賴的package包/類
private CollationKey getCollationKey(String comp) {
    CollationKey key = cKeyMap.get(comp);
    if (key == null) {
        key = collator.getCollationKey(comp);
        cKeyMap.put(comp, key);
    }
    return key;
}
 
開發者ID:salesforce,項目名稱:grammaticus,代碼行數:9,代碼來源:TextUtil.java


注:本文中的java.text.CollationKey類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。