|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.sql.IDSQLGenerator
public class IDSQLGenerator
an IDSQLGenerator is a helper class that provides new IDs as counters based on flexible intervals. An example would be to generate counters based on years, hence using a SimpleDateFormat formatter of the form "yyyy".
| Constructor Summary | |
|---|---|
IDSQLGenerator(Connection con,
String table,
String itemField,
String intervalField,
String countField,
String separator)
constructs a generator by initializing all configuration data. |
|
| Method Summary | |
|---|---|
protected int |
generateNewCountFor(String item,
String interval)
returns the counter for the given item and interval after updating the database. |
String |
generateNewIDFor(String item,
Date date,
DateFormat format)
|
String |
generateNewIDFor(String item,
String interval)
returns a String constructed from the interval, the separator and the calculated counter |
int |
getCount(String item,
String interval)
|
void |
setCount(String item,
String interval,
int count)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public IDSQLGenerator(Connection con,
String table,
String itemField,
String intervalField,
String countField,
String separator)
con - the database connection to be usedtable - the name of the table containing the counting dataitemField - the name of the column to be queried for the item to be counted (as String)intervalField - the name of the column holding the time interval as a String (for most flexibility)countField - the name of the column holding the counter as an integerseparator - the characters to be used to separate the intervalField from the counter
for returning the id| Method Detail |
|---|
public int getCount(String item,
String interval)
throws SQLException
SQLException
public void setCount(String item,
String interval,
int count)
throws SQLException
SQLException
public String generateNewIDFor(String item,
Date date,
DateFormat format)
throws SQLException
SQLException
public String generateNewIDFor(String item,
String interval)
throws SQLException
SQLException
protected int generateNewCountFor(String item,
String interval)
throws SQLException
SQLException
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||