Compiere 3.1

org.compiere.util
Class NamePair

java.lang.Object
  extended by org.compiere.util.NamePair
All Implemented Interfaces:
Serializable, Comparable<NamePair>, Comparator<NamePair>
Direct Known Subclasses:
BankInfo, KeyNamePair, ProductInfo, ValueNamePair

public abstract class NamePair
extends Object
implements Comparator<NamePair>, Serializable, Comparable<NamePair>

Name Pair Interface

Version:
$Id: NamePair.java,v 1.3 2006/07/30 00:52:23 jjanke Exp $
Author:
Jorg Janke
See Also:
Serialized Form

Constructor Summary
  NamePair()
           
protected NamePair(String name)
          Protected Constructor
 
Method Summary
 int compare(NamePair p1, NamePair p2)
          Comparator Interface (based on Name/ID value)
 int compareTo(NamePair o)
          Comparable Interface (based on Name/ID value)
abstract  String getID()
          Returns Key or Value as String
 String getName()
          Returns display value
static int indexOfKey(ArrayList<NamePair> options, String key)
          Returns the index of the first option found for the key, or -1 if not found.
static int indexOfValue(ArrayList<NamePair> options, String value)
          Returns the index of the first option found for the key, or -1 if not found.
 boolean isSortByName()
          Get Sort By Name
 void setName(String name)
          Set Name
 void setSortByName(boolean sortByName)
          Set Sort By Name
 String toString()
          To String - returns name
 String toStringX()
          To String - detail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

NamePair

public NamePair()

NamePair

protected NamePair(String name)
Protected Constructor

Parameters:
name - (Display) Name of the Pair
Method Detail

getName

public String getName()
Returns display value

Returns:
name

setName

public void setName(String name)
Set Name

Parameters:
name - name

isSortByName

public boolean isSortByName()
Get Sort By Name

Returns:
true if by name

setSortByName

public void setSortByName(boolean sortByName)
Set Sort By Name

Parameters:
sortByName - true if by name, false by ID

getID

public abstract String getID()
Returns Key or Value as String

Returns:
String or null

compare

public int compare(NamePair p1,
                   NamePair p2)
Comparator Interface (based on Name/ID value)

Specified by:
compare in interface Comparator<NamePair>
Parameters:
p1 - Value 1
p2 - Value 2
Returns:
compareTo value

compareTo

public int compareTo(NamePair o)
Comparable Interface (based on Name/ID value)

Specified by:
compareTo in interface Comparable<NamePair>
Parameters:
o - the Object to be compared.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

toString

public String toString()
To String - returns name

Overrides:
toString in class Object
Returns:
Name

toStringX

public String toStringX()
To String - detail

Returns:
String in format ID=Name

indexOfKey

public static int indexOfKey(ArrayList<NamePair> options,
                             String key)
Returns the index of the first option found for the key, or -1 if not found.

Parameters:
key -
Returns:

indexOfValue

public static int indexOfValue(ArrayList<NamePair> options,
                               String value)
Returns the index of the first option found for the key, or -1 if not found.

Parameters:
value -
Returns:

Compiere 3.1

Compiere® is a registered trademark of ComPiere, Inc. ©2004-2008 HumanFlash.com All rights reserved.