pl.kernelpanic.dbmonster.generator
Class DictionaryGenerator

java.lang.Object
  extended bypl.kernelpanic.dbmonster.generator.BasicDataGenerator
      extended bypl.kernelpanic.dbmonster.generator.DictionaryGenerator
All Implemented Interfaces:
DataGenerator, Initializable

public class DictionaryGenerator
extends BasicDataGenerator
implements Initializable

The dictionary generator uses external dictionary as the source of test data.

Dictionary is a flat text file. Each line in this file is a dictionary item. Items must be unique! A file may be compressed using ZIP or GZIP algorithm. The extension of the file (.txt, .zip, .gz) decides which compression method is used.

Dictionary files must be encoded in UTF-8.

Properties

dictFile Absolute or relative to the schema file path to the dictionary.
unique boolean value which indicates whether generated value should be unique or random (default: false - random item is used).

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

Field Summary
 
Fields inherited from class pl.kernelpanic.dbmonster.generator.BasicDataGenerator
column, nulls
 
Constructor Summary
DictionaryGenerator()
           
 
Method Summary
 Object generate()
          Generates the value using a dictionary.
 String getDictFile()
          Returns the dictionary name.
 boolean getUnique()
          Returns the unique parameter.
 void initialize(DBMonsterContext ctx)
          Initializes the generator.
 void reset()
          Resets the generator.
 void setDictFile(String name)
          Sets the dictionary name.
 void setUnique(boolean b)
          Sets the unique parameter.
 
Methods inherited from class pl.kernelpanic.dbmonster.generator.BasicDataGenerator
getColumn, getNulls, setColumn, setNulls
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DictionaryGenerator

public DictionaryGenerator()
Method Detail

initialize

public final void initialize(DBMonsterContext ctx)
                      throws Exception
Initializes the generator.

Specified by:
initialize in interface Initializable
Parameters:
ctx - context
Throws:
Exception - thrown when this generator cannot be initialized.

generate

public final Object generate()
                      throws Exception
Generates the value using a dictionary.

Specified by:
generate in interface DataGenerator
Returns:
value
Throws:
Exception - if generattion fails

setDictFile

public final void setDictFile(String name)
Sets the dictionary name.

Parameters:
name - the name of the file.

getDictFile

public final String getDictFile()
Returns the dictionary name.

Returns:
a dictionary file name

setUnique

public final void setUnique(boolean b)
Sets the unique parameter.

Parameters:
b - unique

getUnique

public final boolean getUnique()
Returns the unique parameter.

Returns:
true if generated value are unique, false if generated value are random.

reset

public final void reset()
Resets the generator.

Specified by:
reset in interface DataGenerator


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