org.apache.struts.util

Class LabelValueBean

public class LabelValueBean extends Object implements Comparable, 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 ComparatorCASE_INSENSITIVE_ORDER
Comparator that can be used for a case insensitive sort of LabelValueBean objects.
Stringlabel
The property which supplies the option label visible to the end user.
Stringvalue
The property which supplies the value returned to the server.
Constructor Summary
LabelValueBean()
Default constructor.
LabelValueBean(String label, String value)
Construct an instance with the supplied property values.
Method Summary
intcompareTo(Object o)
Compare LabelValueBeans based on the label, because that's the human viewable part of the object.
booleanequals(Object obj)
LabelValueBeans are equal if their values are both null or equal.
StringgetLabel()
StringgetValue()
inthashCode()
The hash code is based on the object's value.
voidsetLabel(String label)
voidsetValue(String value)
StringtoString()
Return a string representation of this object.

Field Detail

CASE_INSENSITIVE_ORDER

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

label

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

value

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

Constructor Detail

LabelValueBean

public LabelValueBean()
Default constructor.

LabelValueBean

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

Parameters: label The label to be displayed to the user. value The value to be returned to the server.

Method Detail

compareTo

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

See Also: Comparable

equals

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

See Also: java.lang.Object#equals(java.lang.Object)

getLabel

public String getLabel()

getValue

public String getValue()

hashCode

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

See Also: java.lang.Object#hashCode()

setLabel

public void setLabel(String label)

setValue

public void setValue(String value)

toString

public String toString()
Return a string representation of this object.
Copyright B) 2000-2009 - The Apache Software Foundation