Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.struts.util
Class LabelValueBean  view LabelValueBean download LabelValueBean.java

java.lang.Object
  extended byorg.apache.struts.util.LabelValueBean
All Implemented Interfaces:
java.lang.Comparable, java.io.Serializable

public class LabelValueBean
extends java.lang.Object
implements java.lang.Comparable, java.io.Serializable

A simple JavaBean to represent label-value pairs. This is most commonly used when constructing user interface elements which have a label to be displayed to the user, and a corresponding value to be returned to the server. One example is the <html:options> tag.

Note: this class has a natural ordering that is inconsistent with equals.

Version:
$Rev: 54929 $ $Date: 2004-10-16 17:38:42 +0100 (Sat, 16 Oct 2004) $

Field Summary
static java.util.Comparator CASE_INSENSITIVE_ORDER
          Comparator that can be used for a case insensitive sort of LabelValueBean objects.
private  java.lang.String label
          The property which supplies the option label visible to the end user.
private  java.lang.String value
          The property which supplies the value returned to the server.
 
Constructor Summary
LabelValueBean()
          Default constructor.
LabelValueBean(java.lang.String label, java.lang.String value)
          Construct an instance with the supplied property values.
 
Method Summary
 int compareTo(java.lang.Object o)
          Compare LabelValueBeans based on the label, because that's the human viewable part of the object.
 boolean equals(java.lang.Object obj)
          LabelValueBeans are equal if their values are both null or equal.
 java.lang.String getLabel()
           
 java.lang.String getValue()
           
 int hashCode()
          The hash code is based on the object's value.
 void setLabel(java.lang.String label)
           
 void setValue(java.lang.String value)
           
 java.lang.String toString()
          Return a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

CASE_INSENSITIVE_ORDER

public static final java.util.Comparator CASE_INSENSITIVE_ORDER
Comparator that can be used for a case insensitive sort of LabelValueBean objects.


label

private java.lang.String label
The property which supplies the option label visible to the end user.


value

private java.lang.String value
The property which supplies the value returned to the server.

Constructor Detail

LabelValueBean

public LabelValueBean()
Default constructor.


LabelValueBean

public LabelValueBean(java.lang.String label,
                      java.lang.String value)
Construct an instance with the supplied property values.

Method Detail

getLabel

public java.lang.String getLabel()

setLabel

public void setLabel(java.lang.String label)

getValue

public java.lang.String getValue()

setValue

public void setValue(java.lang.String value)

compareTo

public int compareTo(java.lang.Object o)
Compare LabelValueBeans based on the label, because that's the human viewable part of the object.

Specified by:
compareTo in interface java.lang.Comparable

toString

public java.lang.String toString()
Return a string representation of this object.


equals

public boolean equals(java.lang.Object obj)
LabelValueBeans are equal if their values are both null or equal.


hashCode

public int hashCode()
The hash code is based on the object's value.