Diamond Control Suite 3.0

diamondedge.util
Class ListFormat

java.lang.Object
  extended by diamondedge.util.ListFormat

public class ListFormat
extends Object

This class allows a mapping to be specified between the actual data value and the value displayed to the user. When used with DsGrid as the Format for a cell the user will be presented with a ComboBox of the display values. The value stored in the cell will be the data value.


Constructor Summary
ListFormat()
           
 
Method Summary
 void add(Connection con, String sql)
          A ResultSet will be created based on the given connection and SQL query and will then be loaded into the ListFormat.
 void add(int index, Object dataValue, Object displayValue)
          Add a mapping between the actual data value and the value displayed to the user.
 void add(Object dataValue, Object displayValue)
          Add a mapping between the actual data value and the value displayed to the user.
 void add(ResultSet rs)
          Loads data from the ResultSet into the ListFormat.
 void clear()
           
 boolean containsDataValue(Object dataValue)
           
 boolean containsDisplayValue(Object displayValue)
           
 Object get(int index)
          Returns the display value at the given index.
 Object get(Object dataValue)
          Returns the display value that corresponds to the dataValue argument specified when the member referred to was added to the collection
 Object getDataValue(int index)
          Returns the dataValue at specified index
 int getIndex(Object dataValue)
          Returns a 0-based index for the dataValue
static ListFormat getMonthNames(Locale l)
          Returns a ListFormat with entries for each month name.
static ListFormat getWeekdayNames(Locale l)
          Returns a ListFormat with entries for the name of each day of the week.
 Object remove(int index)
          Remove an element based on its position in the List.
 boolean remove(Object displayValue)
          Remove the specified element, displayValue, from the List.
 Object removeDataValue(Object dataValue)
          Remove an element based on its dataValue.
 Object set(int index, Object displayValue)
          Changes the display value at the specified position in the list
 Object set(Object dataValue, Object displayValue)
          Changes the display value for the specified data value.
 void setDataValueType(Class dataValueType)
          Sets the type all data values are coerced to.
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListFormat

public ListFormat()
Method Detail

size

public int size()

setDataValueType

public void setDataValueType(Class dataValueType)
Sets the type all data values are coerced to. This is useful if you load the ListFormat with data values of one type but want to lookup the value using a different data type for the data value. Set DataValueType to null to turn off all coercion.


getIndex

public int getIndex(Object dataValue)
Returns a 0-based index for the dataValue


get

public Object get(int index)
Returns the display value at the given index.

Parameters:
index - specifies the position that the value was added

get

public Object get(Object dataValue)
Returns the display value that corresponds to the dataValue argument specified when the member referred to was added to the collection


getDataValue

public Object getDataValue(int index)
Returns the dataValue at specified index


set

public Object set(int index,
                  Object displayValue)
Changes the display value at the specified position in the list


set

public Object set(Object dataValue,
                  Object displayValue)
Changes the display value for the specified data value.


add

public void add(Object dataValue,
                Object displayValue)
Add a mapping between the actual data value and the value displayed to the user.

Parameters:
dataValue - value used in the underlying data model
displayValue - value to be displayed to the user

add

public void add(int index,
                Object dataValue,
                Object displayValue)
Add a mapping between the actual data value and the value displayed to the user.

Parameters:
dataValue - value used in the underlying data model
displayValue - value to be displayed to the user

add

public void add(ResultSet rs)
         throws SQLException
Loads data from the ResultSet into the ListFormat. Column 0 will be the dataValue and column 1 will be the displayValue. The data is loaded from the current cursor position of the ResultSet. After the data is loaded the ResultSet will be at the last row.

Throws:
SQLException

add

public void add(Connection con,
                String sql)
         throws SQLException
A ResultSet will be created based on the given connection and SQL query and will then be loaded into the ListFormat.

Throws:
SQLException
See Also:
add(ResultSet)

remove

public Object remove(int index)
Remove an element based on its position in the List.


removeDataValue

public Object removeDataValue(Object dataValue)
Remove an element based on its dataValue.


remove

public boolean remove(Object displayValue)
Remove the specified element, displayValue, from the List.


clear

public void clear()

containsDataValue

public boolean containsDataValue(Object dataValue)

containsDisplayValue

public boolean containsDisplayValue(Object displayValue)

getMonthNames

public static ListFormat getMonthNames(Locale l)
Returns a ListFormat with entries for each month name. The data values are 0-based Integer instances.

Parameters:
l - locale to be used to generate the month names. If null, it will use the default locale.

getWeekdayNames

public static ListFormat getWeekdayNames(Locale l)
Returns a ListFormat with entries for the name of each day of the week. The data values are 1-based Integer instances.

Parameters:
l - locale to be used to generate the day names. If null, it will use the default locale.

Diamond Control Suite 3.0

Diamond Edge and Diamond Control Suite are trademarks or registered trademarks of Diamond Edge, Inc. Copyright 1999-2005 Diamond Edge, Inc. All Rights Reserved.