1 14 package org.compiere.util; 15 16 import java.io.Serializable ; 17 import java.util.Comparator ; 18 19 25 public abstract class NamePair implements Comparator , Serializable , Comparable 26 { 27 31 protected NamePair (String name) 32 { 33 m_name = name; 34 if (m_name == null) 35 m_name = ""; 36 } 38 39 private String m_name; 40 41 45 public String getName() 46 { 47 return m_name; 48 } 50 54 public abstract String getID(); 55 56 62 public int compare (Object o1, Object o2) 63 { 64 String s1 = o1 == null ? "" : o1.toString(); 65 String s2 = o2 == null ? "" : o2.toString(); 66 return s1.compareTo (s2); } 69 75 public int compareTo (Object o) 76 { 77 return compare (this, o); 78 } 80 84 public String toString() 85 { 86 return m_name; 87 } 89 93 public String toStringX() 94 { 95 StringBuffer sb = new StringBuffer (getID()); 96 sb.append("=").append(m_name); 97 return sb.toString(); 98 } 100 } | Popular Tags |