org.deegree_impl.io
Class GenericSQLIDGenerator

java.lang.Object
  extended byorg.deegree_impl.io.GenericSQLIDGenerator
All Implemented Interfaces:
IDGenerator

class GenericSQLIDGenerator
extends java.lang.Object
implements IDGenerator

Primary key generator for generic JDBC-connections.

NOTE: At the moment, every application has to take care of locking the table to prevent problems in multithreaded or multihosted applications.

Version:
$Revision: 1.2 $ $Date: 2004/03/11 12:52:42 $
Author:
Markus Schneider

Field Summary
(package private)  java.sql.Connection con
           
(package private)  java.lang.String fieldName
           
(package private)  int fieldType
           
(package private)  boolean isNumeric
           
(package private)  java.lang.String tableName
           
 
Constructor Summary
(package private) GenericSQLIDGenerator(java.sql.Connection con, java.lang.String tableName, java.lang.String fieldName, int fieldType, boolean isNumeric)
          Constructs a new GenericSQLIDGenerator.
 
Method Summary
 java.lang.Object generateUniqueId()
          Generates a new id, suitable as a primary key for the next dataset.
private  java.lang.String incrementId(java.lang.String lastId)
          Returns the successor to the given id (string).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

con

java.sql.Connection con

fieldType

int fieldType

isNumeric

boolean isNumeric

tableName

java.lang.String tableName

fieldName

java.lang.String fieldName
Constructor Detail

GenericSQLIDGenerator

GenericSQLIDGenerator(java.sql.Connection con,
                      java.lang.String tableName,
                      java.lang.String fieldName,
                      int fieldType,
                      boolean isNumeric)
Constructs a new GenericSQLIDGenerator.

Parameters:
con -
fieldType -
Method Detail

incrementId

private java.lang.String incrementId(java.lang.String lastId)
Returns the successor to the given id (string). Valid characters in the id-string are: 0-9, a-z, A-Z. Every other character may result in an exception.

Parameters:
lastId -
Returns:

generateUniqueId

public java.lang.Object generateUniqueId()
                                  throws java.sql.SQLException
Generates a new id, suitable as a primary key for the next dataset.

Specified by:
generateUniqueId in interface IDGenerator
Returns:
Id, the object type depends on the database field used as primary key
Throws:
java.sql.SQLException