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


Java RuleBasedCollator.compare方法代碼示例

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


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

示例1: compare

import java.text.RuleBasedCollator; //導入方法依賴的package包/類
public int compare(Object o1, Object o2) {
	try{
		RuleBasedCollator r_collator= new RuleBasedCollator(((RuleBasedCollator)Collator.getInstance()).getRules().replaceAll("<'\u005f'", "<' '<'\u005f'"));
		return r_collator.compare(((EnrollmentRecord)o1).getUser().getSortName(),((EnrollmentRecord)o2).getUser().getSortName());
	}catch(ParseException e){
		  return Collator.getInstance().compare(((EnrollmentRecord)o1).getUser().getSortName(),((EnrollmentRecord)o2).getUser().getSortName());
	}
}
 
開發者ID:sakaiproject,項目名稱:sakai,代碼行數:9,代碼來源:FacadeUtils.java

示例2: compare

import java.text.RuleBasedCollator; //導入方法依賴的package包/類
public int compare(Object o1, Object o2) {
 QuestionPoolFacade i1 = (QuestionPoolFacade)o1;
 QuestionPoolFacade i2 = (QuestionPoolFacade)o2;
 if (i1 == null && i2 != null) {
  return 1;
 }
 if (i2 == null && i1 != null) {
  return -1;
 }
 if (i2 == null && i1 == null) {
  return 0;
 }
 if (i1.getTitle() == null && i2.getTitle() != null) {
  return 1;
 }
 if (i2.getTitle() == null && i1.getTitle() != null) {
  return -1;
 }
 if (i2.getTitle() == null && i1.getTitle() == null) {
  return 0;
 }
 RuleBasedCollator collator_ini = (RuleBasedCollator)Collator.getInstance();
 try {
RuleBasedCollator collator= new RuleBasedCollator(collator_ini.getRules().replaceAll("<'\u005f'", "<' '<'\u005f'"));
return collator.compare(i1.getTitle(), i2.getTitle());
 } catch (ParseException e) {}
 return Collator.getInstance().compare(i1.getTitle(), i2.getTitle());
}
 
開發者ID:sakaiproject,項目名稱:sakai,代碼行數:29,代碼來源:QuestionPoolBean.java

示例3: compare

import java.text.RuleBasedCollator; //導入方法依賴的package包/類
public int compare(Object o1, Object o2) {
 SelectItem i1 = (SelectItem)o1;
 SelectItem i2 = (SelectItem)o2;
try{
	RuleBasedCollator r_collator= new RuleBasedCollator(((RuleBasedCollator)Collator.getInstance()).getRules().replaceAll("<'\u005f'", "<' '<'\u005f'"));
	return r_collator.compare(i1.getLabel(), i2.getLabel());
}catch(ParseException e){
	  return Collator.getInstance().compare(i1.getLabel(),i2.getLabel());
}
}
 
開發者ID:sakaiproject,項目名稱:sakai,代碼行數:11,代碼來源:SectionBean.java

示例4: compare

import java.text.RuleBasedCollator; //導入方法依賴的package包/類
public int compare(Object o1, Object o2) {
	SelectItem i1 = (SelectItem) o1;
	SelectItem i2 = (SelectItem) o2;
	RuleBasedCollator collator_ini = (RuleBasedCollator)Collator.getInstance();
	try {
		RuleBasedCollator collator= new RuleBasedCollator(collator_ini.getRules().replaceAll("<'\u005f'", "<' '<'\u005f'"));
		return collator.compare(i1.getLabel(), i2.getLabel());
	} catch (ParseException e) {}
	return Collator.getInstance().compare(i1.getLabel(), i2.getLabel());
}
 
開發者ID:sakaiproject,項目名稱:sakai,代碼行數:11,代碼來源:ItemAuthorBean.java

示例5: subCompare

import java.text.RuleBasedCollator; //導入方法依賴的package包/類
private int subCompare(String s1, String s2)
{
 //we do not want to use null values for sorting
 if(s1 == null)
 {
  s1 = "";
 }

 if(s2 == null)
 {
  s2 = "";
 }

 // Deal with n/a case
 if (s1.toLowerCase().startsWith("n/a")
	  && !s2.toLowerCase().startsWith("n/a"))
  return 1;

 if (s2.toLowerCase().startsWith("n/a") &&
	  !s1.toLowerCase().startsWith("n/a"))
  return -1;


 String finalS1 = s1.replaceAll("<.*?>", "");
 String finalS2 = s2.replaceAll("<.*?>", "");
 RuleBasedCollator collator_ini = (RuleBasedCollator)Collator.getInstance();
 try {
RuleBasedCollator collator= new RuleBasedCollator(collator_ini.getRules().replaceAll("<'\u005f'", "<' '<'\u005f'"));
return collator.compare(finalS1.toLowerCase(), finalS2.toLowerCase());
 } catch (ParseException e) {}
 return Collator.getInstance().compare(finalS1.toLowerCase(), finalS2.toLowerCase());	  
}
 
開發者ID:sakaiproject,項目名稱:sakai,代碼行數:33,代碼來源:BeanSortComparator.java

示例6: checkEquality

import java.text.RuleBasedCollator; //導入方法依賴的package包/類
/**
 * If the character in val matches the character in pat, then it does not
 * matter if the database is UCS_BASIC or territory based, we simply return 
 * TRUE from the method. 
 * If the characters do not match and we are running with UCS_BASIC 
 * collation, then we will return FALSE. 
 * But if the database is territory based, then we want to use the Collator 
 * for the territory to determine if the Collator treats the 2 characters 
 * as equal (ie if their collation elements match, then the 2 characters 
 * are equal even if they  are not the same character).
 * 
 * @param val value to compare.
 * @param vLoc character position in val.
 * @param pat pattern to look for in val.
 * @param pLoc character position in pat.
 * @param collator null if we are dealing with UCS_BASIC character string
 *   types. If not null, then we use it to determine the equality of the
 *   2 characters in pat and val if they are not same.
 * @return TRUE if the character in val and vLoc match based on straight
 *   equality or collation element based equality. Otherwise we will 
 *   return FALSE.
 */
private static boolean checkEquality(char[] val, int vLoc,
		char[] pat, int pLoc, RuleBasedCollator collator) {

	if (val[vLoc] == pat[pLoc]) { 
        // same character, so two strings consisting of this 
        // single character must be equal regardless of territory 
        return true; 
    } else if (collator == null) { 
        // not same character, must be unequal in UCS_BASIC 
        return false; 
    } 

	//Check if the Collator for this database's territory considers these
	//2 characters as equal based on their collation elements
    String s1 = new String(val, vLoc, 1); 
    String s2 = new String(pat, pLoc, 1); 

    return collator.compare(s1, s2) == 0; 
}
 
開發者ID:gemxd,項目名稱:gemfirexd-oss,代碼行數:42,代碼來源:Like.java

示例7: sortObjectStringAlanList

import java.text.RuleBasedCollator; //導入方法依賴的package包/類
/**
 * @param locale
 * @param list
 * @param method
 * @param parametre
 * @return
 */
public static List sortObjectStringAlanList(Locale locale, List list, String method, Object[] parametre) {
	if (list != null && list.size() > 1) {
		if (locale == null)
			locale = FacesContext.getCurrentInstance().getViewRoot().getLocale();
		TreeMap sortMap = new TreeMap();
		String alan1 = "";
		String alan2 = "";
		HashMap degerMap = new HashMap();
		for (int k = 0; k < list.size(); k++) {
			sortMap.put(new Long(k), list.get(k));
			degerMap.put(new Long(k), getMethodObject(list.get(k), method, parametre));
		}
		list = new ArrayList(sortMap.values());
		RuleBasedCollator collator = null;
		if (locale.getLanguage().equals(Constants.TR_LOCALE.getLanguage()))
			collator = getTrRuleBasedCollator();
		else if (locale.getLanguage().equals(Constants.RU_LOCALE.getLanguage()))
			collator = getRuRuleBasedCollator();
		Object object1 = null;
		Object object2 = null;
		if (collator != null) {
			for (int j = 0; j < list.size() - 1; j++) {
				object1 = sortMap.get(new Long(j));
				alan1 = (String) degerMap.get(new Long(j));
				for (int k = j + 1; k < list.size(); k++) {
					object2 = sortMap.get(new Long(k));
					alan2 = (String) degerMap.get(new Long(k));
					if (alan1 != null && alan2 != null && collator.compare(alan1, alan2) == 1) {
						sortMap.put(new Long(j), object2);
						sortMap.put(new Long(k), object1);
						degerMap.put(new Long(j), alan2);
						degerMap.put(new Long(k), alan1);
						alan1 = alan2;
						object1 = object2;
					}
				}
			}
		} else {
			Collator coll = Collator.getInstance(locale);
			for (int j = 0; j < list.size() - 1; j++) {
				object1 = sortMap.get(new Long(j));
				alan1 = (String) degerMap.get(new Long(j));
				for (int k = j + 1; k < list.size(); k++) {
					object2 = sortMap.get(new Long(k));
					alan2 = (String) degerMap.get(new Long(k));
					if (alan1 != null && alan2 != null && coll.compare(alan1, alan2) == 1) {
						sortMap.put(new Long(j), object2);
						sortMap.put(new Long(k), object1);
						degerMap.put(new Long(j), alan2);
						degerMap.put(new Long(k), alan1);
						alan1 = alan2;
						object1 = object2;
					}
				}
			}
		}
		list = new ArrayList(sortMap.values());
	}
	return list;
}
 
開發者ID:aliaksoy,項目名稱:ServisTakip,代碼行數:68,代碼來源:AbhUtil.java


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