public abstract class ListDataItem
extends java.lang.Object
implements java.lang.Comparable
ListDataItem
can be used as an abstract starting
point for data item objects stored in a ListInsightData
.
Note that its use is optional - as it provides methods for handling
case-insensitivity, it is more for convenience and code reuse.
It is still the responsibility of the given ListInsightData
implementation to sort its underlying data items before passing it
to the ListInsightView
via getListModel()
.
Note that data items that do extend this class can also make use of
the ListDataItemCellRenderer
as a basic default cell
renderer.
Constructor and Description |
---|
ListDataItem() |
Modifier and Type | Method and Description |
---|---|
static int |
compareInsensitive(java.lang.String name1,
java.lang.String name2)
Compares its two Strings for case insensitive order.
|
static int |
compareSensitive(java.lang.String name1,
java.lang.String name2)
Compares its two Strings for case sensitive order.
|
int |
compareTo(java.lang.Object object)
Compares this object with the specified object for order.
|
java.lang.String |
getAccessibleText()
Gets the tet to use for accessibility purposes
|
abstract java.lang.String |
getDisplayText()
Fetches a displayable text for this item that can be used as
the visible text within a list cell.
|
abstract javax.swing.Icon |
getIcon()
Fetches an icon associated with this type of data item that
can pictorially provide some information for this data item.
|
abstract java.lang.String |
getName()
Fetches the display name of this data item.
|
public abstract javax.swing.Icon getIcon()
public abstract java.lang.String getDisplayText()
ListDataItemCellRenderer
, this display text is
what is rendered visibly.public abstract java.lang.String getName()
For example, let's suppose a data item represents a Java method. Its
internal name might be "String.substring()", while its display name
as returned by this method getName()
might be
"substring", while its displayable text might be
"substring() returns String".
When sorting ListDataItems
using its
Comparable
implementation, it is the display name as
returned by getName()
that is used for sorting purposes,
not the displayable text.
public int compareTo(java.lang.Object object)
Although this method is not declared final, it is recommended that subclasses do not override it unless they define another abstract class which overrides this routine for ALL subsequent data items. It could be pretty confusing (and unpredictable) otherwise if there are different data item classes with different compareTo() implementations.
compareTo
in interface java.lang.Comparable
object
- the Object to be compared.java.lang.ClassCastException
- if the specified object's type prevents it
from being compared to this Object.public static int compareInsensitive(java.lang.String name1, java.lang.String name2)
Note that this method should only be used for sorting purposes, not for equivalency purposes. This method will return "ACTION" < "action". For true case-insensitive comparison where "ACTION" == "action", use String.compareToIgnoreCase().
name1
- the first String to be comparedname2
- the second String to be comparedpublic static int compareSensitive(java.lang.String name1, java.lang.String name2)
name1
- the first String to be comparedname2
- the second String to be comparedpublic java.lang.String getAccessibleText()