Package ucar.unidata.util
Class TwoFacedObject
java.lang.Object
ucar.unidata.util.TwoFacedObject
- All Implemented Interfaces:
Comparable
A generic Object wrapper that holds two objects. The first
is used as the label and for comparisons in lists.
- Version:
- $Revision: 1.20 $ $Date: 2006/06/23 20:17:32 $
- Author:
- Metapps development team
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor with null id and labelTwoFacedObject
(Object label) Create a TwoFacedObject where both id and label are identical.TwoFacedObject
(Object label, int id) Create a TwoFacedObject with label and integer idTwoFacedObject
(Object label, Object id) Create a TwoFacedObject. -
Method Summary
Modifier and TypeMethodDescriptionint
Compare this object to another.static boolean
static List
createList
(int[] ids, String[] names) Create a list of tfos from the given int ids and namesstatic List
createList
(String[] ids, String[] names) Create a list of tfos from the given int ids and namesboolean
See if this TwoFacedObject is equal to another object.static TwoFacedObject
Finf the tfo with the given id in the liststatic String
Find the label for the object in the listgetId()
Get the Id object.static List
Create a list of ids from the given list of objects.static Object
Get the id object of this possible TwoFacedObject.static String
Get a String representation for the id of this TwoFacedObject.static List
getIdStrings
(List objects) Get a String representation for the objects in te lsitgetLabel()
Get the Label object.int
hashCode()
Get the hashcode for this TwoFacedObjectvoid
Sets the value of the Id object.void
Sets the value of the Label object.static void
toString()
String representation of this object.
-
Field Details
-
debug
public static boolean debugdebug flag
-
-
Constructor Details
-
TwoFacedObject
public TwoFacedObject()Default constructor with null id and label -
TwoFacedObject
Create a TwoFacedObject where both id and label are identical.- Parameters:
label
- label and object
-
TwoFacedObject
Create a TwoFacedObject with label and integer id- Parameters:
label
- labelid
- id
-
TwoFacedObject
Create a TwoFacedObject.- Parameters:
label
- object to use for labeling.id
- other face of this object
-
-
Method Details
-
toString
String representation of this object. -
equals
See if this TwoFacedObject is equal to another object. -
hashCode
public int hashCode()Get the hashcode for this TwoFacedObject -
getId
Get the Id object.- Returns:
- the id for this TwoFacedObject.
-
setId
Sets the value of the Id object.- Parameters:
newId
-
-
getLabel
Get the Label object.- Returns:
- the label for this TwoFacedObject.
-
setLabel
Sets the value of the Label object.- Parameters:
newLabel
-
-
getIdString
Get a String representation for the id of this TwoFacedObject.- Parameters:
o
- object in question.- Returns:
- the toString() of the id if this is a TwoFacedObject, otherwise the toString() method of o.
-
getIdObject
Get the id object of this possible TwoFacedObject.- Parameters:
o
- object in question.- Returns:
- the id if this is a TwoFacedObject, otherwise o.
-
createList
Create a list of tfos from the given int ids and names- Parameters:
ids
- idsnames
- names- Returns:
- list of tfos
-
createList
Create a list of tfos from the given int ids and names- Parameters:
ids
- idsnames
- names- Returns:
- list of tfos
-
getIdList
Create a list of ids from the given list of objects. For any TwoFaceObject in objects, the id is added to the resulting list, otherwise the object is added- Parameters:
objects
- list of objects- Returns:
- list of tfos
-
findId
Finf the tfo with the given id in the list- Parameters:
id
- id to look forl
- list of tfos- Returns:
- the tfo or null if none found
-
findLabel
Find the label for the object in the list- Parameters:
id
- object to search forl
- list of TwoFacedObjects objects- Returns:
- the label
-
contains
-
getIdStrings
Get a String representation for the objects in te lsit- Parameters:
objects
- objects in question.- Returns:
- List of fbhe toString() of the id if these are TwoFacedObjects, otherwise the toString() method of o.
-
compareTo
Compare this object to another.- Specified by:
compareTo
in interfaceComparable
- Parameters:
o
- object in question.- Returns:
- spec from Comparable interface.
-
sort
-