org.apache.struts.util

Class LabelValueBean

Implemented Interfaces:
Comparable, Serializable

public class LabelValueBean
extends java.lang.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 Comparator
CASE_INSENSITIVE_ORDER
Comparator that can be used for a case insensitive sort of LabelValueBean objects.
private String
label
The property which supplies the option label visible to the end user.
private String
value
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

int
compareTo(Object o)
Compare LabelValueBeans based on the label, because that's the human viewable part of the object.
boolean
equals(Object obj)
LabelValueBeans are equal if their values are both null or equal.
String
getLabel()
String
getValue()
int
hashCode()
The hash code is based on the object's value.
void
setLabel(String label)
void
setValue(String value)
String
toString()
Return a string representation of this object.

Field Details

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 Details

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 Details

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-2007 - The Apache Software Foundation