de.fhdarmstadt.fbi.dtree.testdata
Class DataGenerator

java.lang.Object
  extended byde.fhdarmstadt.fbi.dtree.testdata.DataGenerator

public class DataGenerator
extends java.lang.Object

The DataGenerator can be used to generate test data for a given SimplePattern. This generator enumerates all possible patterns and allows indexed access to the generated patterns.

This generator cannot be used to generate negative matches for a certain pattern.

See Also:
SimplePattern

Constructor Summary
DataGenerator(SimplePattern pattern, Alphabet alphabet)
          Creates a new DataGenerator for the given simple pattern.
 
Method Summary
 java.lang.String generateString(int pos)
          Generate the string for the given position.
protected  java.lang.Character[] getAlphabet()
          Returns the alphabet used for the generation process.
 int getConstantLength()
          Returns the size of the constant elements in the used pattern.
 int getMaxLength()
          Returns the maximum length of the generated patterns.
 long getMaxNumberOfPattern()
          Returns the maximum number of patterns, which are generatable using the current settings.
 int getMinLength()
          Returns the minimum length of the generated patterns.
 RegularPattern getPattern()
          Returns the regular pattern used in the data generator.
 void setMaxLength(int maxLength)
          Defines the maximum length of the generated pattern.
 void setMinLength(int minLength)
          Defines the minimum length of the generated pattern.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataGenerator

public DataGenerator(SimplePattern pattern,
                     Alphabet alphabet)
Creates a new DataGenerator for the given simple pattern. The pattern is cloned during the construction process to make it immutable.

Parameters:
pattern - the pattern, never null
alphabet - the alphabet
Throws:
java.lang.NullPointerException - if either the alphabet or the pattern is null
java.lang.IllegalArgumentException - if the alphabet is invalid.
Method Detail

getPattern

public RegularPattern getPattern()
Returns the regular pattern used in the data generator.

Returns:
the pattern used, never null.

getMaxLength

public int getMaxLength()
Returns the maximum length of the generated patterns.

Returns:
the maximum length

setMaxLength

public void setMaxLength(int maxLength)
Defines the maximum length of the generated pattern. Setting this value triggers the pattern recomputation.

Parameters:
maxLength - the maximum length of the generated patterns
Throws:
java.lang.IllegalArgumentException - if the given length is lower than the defined minimum length.

getMinLength

public int getMinLength()
Returns the minimum length of the generated patterns.

Returns:
the minimum length

setMinLength

public void setMinLength(int minLength)
Defines the minimum length of the generated pattern. Setting this value triggers the pattern recomputation.

Parameters:
minLength - the minimum length of the generated patterns
Throws:
java.lang.IllegalArgumentException - if the given length is lower than the length of the constants or greater than the defined maximum length.

getAlphabet

protected java.lang.Character[] getAlphabet()
Returns the alphabet used for the generation process.

Returns:
the alphabet as array.

getConstantLength

public int getConstantLength()
Returns the size of the constant elements in the used pattern.

Returns:
the constant size.

getMaxNumberOfPattern

public long getMaxNumberOfPattern()
Returns the maximum number of patterns, which are generatable using the current settings.

Returns:
the maximum number of patterns.

generateString

public java.lang.String generateString(int pos)
Generate the string for the given position.

Parameters:
pos - the position with the enumerated set of results.
Returns:
the generated string, never null.
Throws:
java.lang.IndexOutOfBoundsException - if the given position is negative or greater or equal to the maximum number of generatable patterns.