pl.kernelpanic.dbmonster.generator
Class StringKeyGenerator

java.lang.Object
  extended bypl.kernelpanic.dbmonster.generator.StringKeyGenerator
All Implemented Interfaces:
Initializable, KeyGenerator

public class StringKeyGenerator
extends Object
implements KeyGenerator, Initializable

The string key generator uses sort of string magic known from Perl. in short it starts from i.e. "aaaaa" and increment it by one: "aaaab", "aaaac"....

Version:
$Id: StringKeyGenerator.html,v 1.1 2007/06/21 08:38:14 sbahloul Exp $
Author:
Piotr Maj <piotr.maj@kernelpanic.pl>

Field Summary
static char[] CHARS
          Chars.
static String DEFAULT_VALUE
          Default value.
 
Constructor Summary
StringKeyGenerator()
           
 
Method Summary
 List generate()
          Generates a primary key.
 String getColumnName()
          Returns a column name.
 List getColumns()
          Returns columns.
 Key getKey()
          Returns the key
 String getStartValue()
          Returns the start value.
 void initialize(DBMonsterContext ctx)
          Initializes a class with DBMonsterContext.
 void setColumnName(String name)
          Sets the column name and sets up the column.
 void setKey(Key k)
          Sets the key.
 void setStartValue(String sv)
          Sets the start value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_VALUE

public static final String DEFAULT_VALUE
Default value.

See Also:
Constant Field Values

CHARS

public static final char[] CHARS
Chars.

Constructor Detail

StringKeyGenerator

public StringKeyGenerator()
Method Detail

setKey

public final void setKey(Key k)
Sets the key.

Specified by:
setKey in interface KeyGenerator
Parameters:
k - the key.

getKey

public Key getKey()
Description copied from interface: KeyGenerator
Returns the key

Specified by:
getKey in interface KeyGenerator

getColumns

public final List getColumns()
Returns columns.

Specified by:
getColumns in interface KeyGenerator
Returns:
a list of columns

generate

public final List generate()
                    throws Exception
Generates a primary key.

Specified by:
generate in interface KeyGenerator
Returns:
a list of generated Columns.
Throws:
Exception - if generation fails

initialize

public final void initialize(DBMonsterContext ctx)
                      throws Exception
Description copied from interface: Initializable
Initializes a class with DBMonsterContext.

Specified by:
initialize in interface Initializable
Parameters:
ctx - context
Throws:
Exception - if initialization fails
See Also:
Initializable.initialize(DBMonsterContext)

getColumnName

public final String getColumnName()
Returns a column name.

Returns:
the name of the column.

setColumnName

public final void setColumnName(String name)
Sets the column name and sets up the column.

Parameters:
name - the name of the column.

getStartValue

public final String getStartValue()
Returns the start value.

Returns:
start value.

setStartValue

public final void setStartValue(String sv)
Sets the start value

Parameters:
sv - The startValue to set.


Copyright © 2003-2005 .:. kernelpanic.pl .:.. All Rights Reserved.