📄 namepair.java
字号:
/******************************************************************************
* The contents of this file are subject to the Compiere License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* You may obtain a copy of the License at http://www.compiere.org/license.html
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Original Code is Compiere ERP & CRM Business Solution
* The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
* Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
* created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
* Contributor(s): ______________________________________.
*****************************************************************************/
package org.compiere.util;
import java.io.Serializable;
import java.util.Comparator;
/**
* Name Pair Interface
*
* @author Jorg Janke
* @version $Id: NamePair.java,v 1.4 2002/06/24 05:02:27 jjanke Exp $
*/
public abstract class NamePair implements Comparator, Serializable, Comparable
{
/**
* Protected Constructor
* @param name (Display) Name of the Pair
*/
protected NamePair (String name)
{
m_name = name;
if (m_name == null)
m_name = "";
} // NamePair
/** The Name */
private String m_name;
/**
* Returns display value
* @return name
*/
public String getName()
{
return m_name;
} // getName
/**
* Returns Key or Value as String
* @return String or null
*/
public abstract String getID();
/**
* Comparator Interface (based on toString value)
* @param o1 Object 1
* @param o2 Object 2
* @return compareTo value
*/
public int compare (Object o1, Object o2)
{
String s1 = o1 == null ? "" : o1.toString();
String s2 = o2 == null ? "" : o2.toString();
return s1.compareTo (s2); // sort order ??
} // compare
/**
* Comparable Interface (based on toString value)
* @param o the Object to be compared.
* @return a negative integer, zero, or a positive integer as this object
* is less than, equal to, or greater than the specified object.
*/
public int compareTo (Object o)
{
return compare (this, o);
} // compareTo
/**
* To String - returns name
* @return Name
*/
public String toString()
{
return m_name;
} // toString
/**
* To String - detail
* @return String in format ID=Name
*/
public String toStringX()
{
StringBuffer sb = new StringBuffer (getID());
sb.append("=").append(m_name);
return sb.toString();
} // toStringX
} // NamePair
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -