public class DBListData extends Object implements ListData, Runnable
| Constructor and Description |
|---|
DBListData(String name) |
DBListData(String name,
String orderBy) |
DBListData(String name,
String keyColumn,
String valueColumn,
String tableName,
String orderByColumn)
If your database table is not localized, in other words, if it does not care about locales and have only one list in one locale, use this constructor.
|
DBListData(String name,
String keyColumn,
String valueColumn,
String localeColumn,
String tableName,
String orderByColumn)
If your database table is localized, in other words, if it has a locale column to define the locale, use this constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected String |
buildSQL(boolean isLocalized) |
protected Locale |
getLocaleFromString(String loc)
Override this method to map whatever you have in your database to a Java locale.
|
String |
getName()
Returns the name of this list.
|
String |
getValue(int key)
Returns the string value of the list data item with the given id with the default locale.
|
String |
getValue(int key,
Locale loc)
Returns the string value of the list data item with the given id in the given locale.
|
String |
getValue(String key)
Returns the string value for the list data item with the default locale.
|
String |
getValue(String key,
Locale loc)
Returns the string value of the list data item with the given id in the given locale.
|
List<ListItem> |
getValues()
Returns a list of ListItem for the default locale.
|
List<ListItem> |
getValues(Locale loc)
Returns a list of ListItem in the given locale.
|
boolean |
isLocalized() |
void |
load(Connection conn)
Call this method passing a db connection to load the lists from database!
The SQL statement that will be constructed:
"select " + keyColumn + "," + valueColumn + "," + localeColumn + " from " + tableName + " order by " + orderByColumn;
or if localeColumn is null and a single locale (unique) is provided
"select " + keyColumn + "," + valueColumn + " from " + tableName + " order by " + orderByColumn;
|
void |
load(ConnectionHandler connHandler) |
void |
loadUsingJPA()
load the lists from database from JPA Entity Manager
warning: you NEED a defined persistence unit !
|
void |
refresh(Connection conn)
The only difference of this method to the load(conn) method is that it
will clear everything before loading...
|
void |
refresh(ConnectionHandler connHandler) |
void |
run() |
void |
setWhere(String where) |
int |
size()
Returns the size of this list.
|
void |
startAutoRefresh(ConnectionHandler connHandler,
long time) |
void |
stopAutoRefresh() |
public DBListData(String name, String keyColumn, String valueColumn, String localeColumn, String tableName, String orderByColumn)
name - keyColumn - valueColumn - localeColumn - tableName - orderByColumn - public DBListData(String name, String keyColumn, String valueColumn, String tableName, String orderByColumn)
name - keyColumn - valueColumn - tableName - orderByColumn - public DBListData(String name)
public boolean isLocalized()
public void setWhere(String where)
public void startAutoRefresh(ConnectionHandler connHandler, long time)
public void stopAutoRefresh()
public int size()
ListDatapublic String getValue(String key, Locale loc)
ListDatapublic String getValue(String key)
ListDatapublic String getValue(int key)
ListDatapublic String getValue(int key, Locale loc)
ListDatapublic List<ListItem> getValues(Locale loc)
ListDatapublic List<ListItem> getValues()
ListDatapublic String getName()
ListDataprotected Locale getLocaleFromString(String loc)
loc - public void load(ConnectionHandler connHandler)
protected String buildSQL(boolean isLocalized)
public void load(Connection conn)
conn - SQLExceptionpublic void loadUsingJPA()
public void refresh(ConnectionHandler connHandler) throws SQLException
SQLExceptionpublic void refresh(Connection conn) throws SQLException
conn - SQLExceptionCopyright © 2015. All Rights Reserved.