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

📄 objectkeycomparator.java

📁 java 写的一个新闻发布系统
💻 JAVA
字号:
package org.jahia.content;import java.util.Comparator;import org.jahia.utils.*;/** * Title:        Jahia * Description:  This class is used to define a comparator to be used in all * sorts of sorted Java collections such as TreeSets, SortedLists, etc... * Copyright:    Copyright (c) 2002 * Company:      Jahia Ltd * @author Serge Huber * @version 1.0 */public class ObjectKeyComparator implements Comparator {    public ObjectKeyComparator() {    }    public int compare(Object o1, Object o2) {        if ((o1 instanceof ObjectKey) && (o2 instanceof ObjectKey)) {            ObjectKey key1 = (ObjectKey) o1;            ObjectKey key2 = (ObjectKey) o2;            return key1.getKey().compareTo(key2.getKey());        } else {            JahiaConsole.println("ObjectKeyComparator.compare",                                 "Comparator called on non ObjectKey objects, returning -1...");            return -1; // default is keep order        }    }    /**     * Must only return true if the passed object is a comparator and has the     * same order as this one, so we simply test if it is an instance of this     * comparator class...     */    public boolean equals(Object obj) {        if (obj instanceof ObjectKeyComparator) {            return true;        } else {            return false;        }    }}

⌨️ 快捷键说明

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