|
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.SQLNumberGenerator
public class SQLNumberGenerator
this class is a helper class that provides new IDs or document/product numbers 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". Note that these numbers are only save to be used when created and used within a properly synchronized transaction.
TransactionalNumberGenerator| Field Summary | |
|---|---|
protected Connection |
con
|
protected String |
countField
|
protected DateFormat |
dateFormat
|
protected String |
intervalField
|
protected String |
itemField
|
protected NumberFormat |
numberFormat
|
protected String |
separator
|
protected String |
table
|
| Constructor Summary | |
|---|---|
SQLNumberGenerator(Connection con)
uses default values for the protected data members |
|
SQLNumberGenerator(Connection con,
String table,
String itemField,
String intervalField,
String countField,
String separator,
DateFormat dateFormat)
|
|
SQLNumberGenerator(Connection con,
String table,
String itemField,
String intervalField,
String countField,
String separator,
DateFormat dateFormat,
NumberFormat numberFormat)
constructs a generator by initializing all configuration data. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Connection con
protected String table
protected String itemField
protected String intervalField
protected String countField
protected String separator
protected DateFormat dateFormat
protected NumberFormat numberFormat
| Constructor Detail |
|---|
public SQLNumberGenerator(Connection con)
public SQLNumberGenerator(Connection con,
String table,
String itemField,
String intervalField,
String countField,
String separator,
DateFormat dateFormat)
public SQLNumberGenerator(Connection con,
String table,
String itemField,
String intervalField,
String countField,
String separator,
DateFormat dateFormat,
NumberFormat numberFormat)
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 iddateFormat - the default format to be used when only a date is given for an interval| Method Detail |
|---|
public Connection getConnection()
public DateFormat getDateFormat()
public void setDateFormat(DateFormat dateFormat)
public NumberFormat getNumberFormat()
public void setNumberFormat(NumberFormat numberFormat)
public int getCount(String item,
Date date)
throws SQLException
SQLException
public int getCount(String item,
Date date,
DateFormat format)
throws SQLException
SQLException
public int getCount(String item,
String interval)
throws SQLException
SQLException
public void setCount(String item,
Date date,
int count)
throws SQLException
SQLException
public void setCount(String item,
Date date,
DateFormat format,
int count)
throws SQLException
SQLException
public void setCount(String item,
String interval,
int count)
throws SQLException
SQLException
public int deleteCount(String item,
Date interval)
throws SQLException
SQLException
public int deleteCount(String item,
String interval)
throws SQLException
SQLException
public TransactionalNumberGenerator createTransactionalNumberGenerator(String item,
String interval,
DBTransaction tx)
public String generateNewNumberFor(String item)
throws SQLException
SQLException
public String generateNewNumberFor(String item,
Date date)
throws SQLException
SQLException
public String generateNewNumberFor(String item,
Date date,
DateFormat format)
throws SQLException
SQLException
public String generateNewNumberFor(String item,
String interval)
throws SQLException
SQLException
public String generateNewNumberFor(String item,
String interval,
NumberFormat nf)
throws SQLException
SQLException
public int generateNewCountFor(String item)
throws SQLException
SQLException
public int generateNewCountFor(String item,
Date date)
throws SQLException
SQLException
public 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 | |||||||||