⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 codesetelementcomparator.java

📁 一个实用工具类
💻 JAVA
字号:
/* * Copyright (C) butor.com. All rights reserved. * * This software is published under the terms of the GNU Library General * Public License (GNU LGPL), a copy of which has been included with this * distribution in the LICENSE.txt file.  */package org.butor.codeSet.lowlevel;/** * ---------------------------------------------------------------- * 2000/12/11,AS: Creation * 2001/07/17,AS: Added field f_locale to compare strings by locale. *						The locale is determined in setLanguage(). */ import org.butor.comparator.IComparator;import org.butor.comparator.SortComparator;import org.butor.comparator.SortElement;import org.butor.comparator.StringComparator;import java.util.Locale;/** * Used to compare two CodeTableElement for sort *  * @author Aiman Sawan */public class CodeSetElementComparator extends SortComparator {	public static final int ELEMENT_ID = 0;	public static final int ELEMENT_SHORT_DESC = 1;	public static final int ELEMENT_LONG_DESC = 2;	protected int f_field = ELEMENT_LONG_DESC;	protected Locale f_locale = Locale.ENGLISH;/** * compareElements method comment. */public int compareElements(Object o1, Object o2) {	CodeSetElement e1 = (CodeSetElement)o1; 	CodeSetElement e2 = (CodeSetElement)o2;	String s1;	String s2;		switch (f_field) {		case ELEMENT_ID: {			s1 = e1.getCode();			s2 = e2.getCode();		} case ELEMENT_SHORT_DESC: {			s1 = e1.getShortDesc(f_locale);			s2 = e2.getShortDesc(f_locale);		} default: {			s1 = e1.getLongDesc(f_locale);			s2 = e2.getLongDesc(f_locale);		}	}		StringComparator stringComparator = new StringComparator(f_locale);	stringComparator.setOrder(f_order);	return stringComparator.compare(new SortElement(0, s1), new SortElement(1, s2));}/** * CodeTableElementComparator constructor comment. * @param order int */public CodeSetElementComparator(int order) {	super(order);	setCompareField(ELEMENT_LONG_DESC);}/** * Insert the method's description here. * Creation date: (12/08/2000 %r) * @param colName java.lang.String */public void setCompareField(int field) {	f_field = field;}/** * Insert the method's description here. * Creation date: (12/08/2000 %r) * @param colName java.lang.String */public void setLocale(Locale locale) {	f_locale = locale;}/** * CodeTableElementComparator constructor comment. */public CodeSetElementComparator() {	super(IComparator.SORT_DESC);}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -