|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mentawai.list.BaseListData
public class BaseListData
A base implementation for a ListData that will load files and sort. The files should be i18n files inside a given directory (or the default). Sorting is supported and can be by id, by value or by the order they appear in the file.
| Field Summary | |
|---|---|
static int |
ORDER_BY_FILE
Sort the list according to the order they appear inside the filename (don't sort) |
static int |
ORDER_BY_ID
Sort the list according to the id (key) values, which can be integers |
static int |
ORDER_BY_STRING_ID
Sort the list according to the id (key) values, which can be strings |
static int |
ORDER_BY_VALUE
Sort the list according to item values, which are strings |
| Constructor Summary | |
|---|---|
BaseListData(String listname)
Creates a new BaseListData, looking for files inside the default directory "/lists", and using the default sort order ORDER_BY_VALUE. |
|
BaseListData(String listname,
int ordertype)
Creates a new BaseListData, looking for files inside the default directory "/lists". |
|
BaseListData(String listname,
int ordertype,
String listDir)
Creates a new BaseListData |
|
| Method Summary | |
|---|---|
String |
getName()
The name of this list, for example "genders" |
String |
getValue(int id)
Returns the string value of the list data item with the given id with the default locale. |
String |
getValue(int id,
Locale loc)
Returns the string value of the list data item with the given id in the given locale. |
String |
getValue(String id)
Returns the string value for the list data item with the default locale. |
String |
getValue(String id,
Locale loc)
Given an id and a locale return the list item value. |
List<ListItem> |
getValues()
Returns a list of ListItem for the default locale. |
List<ListItem> |
getValues(Locale loc)
Return a list of ListItem objects so you can print the whole list for this locale. |
int |
size()
The size of the list, for example a "genders" list should have 2 items. |
protected void |
sort(List<ListItem> list,
int ordertype)
Sort the list acording to the order type. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int ORDER_BY_ID
public static final int ORDER_BY_STRING_ID
public static final int ORDER_BY_VALUE
public static final int ORDER_BY_FILE
| Constructor Detail |
|---|
public BaseListData(String listname,
int ordertype,
String listDir)
throws IOException
listname - The name of the listordertype - How this list should be sortedlistDir - The directory where to look for list files.
IOException
public BaseListData(String listname,
int ordertype)
throws IOException
listname - The name of the listordertype - How this list should be sorted.
IOException
public BaseListData(String listname)
throws IOException
listname - The name of the list
IOException| Method Detail |
|---|
public String getName()
getName in interface ListDatapublic int size()
size in interface ListDatapublic List<ListItem> getValues(Locale loc)
getValues in interface ListDataloc - The locale of the list
public List<ListItem> getValues()
ListData
getValues in interface ListData
public String getValue(String id,
Locale loc)
getValue in interface ListDataid - The id of the list itemloc - The locale of the list from where to get the value.
public String getValue(String id)
ListData
getValue in interface ListDatapublic String getValue(int id)
ListData
getValue in interface ListDataid - The id of the list data item
public String getValue(int id,
Locale loc)
ListData
getValue in interface ListDataid - The id of the list data item.loc - The locale of the list data item.
protected void sort(List<ListItem> list,
int ordertype)
list - The list of ListItems to sort.ordertype - The order type (how to sort)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||