net.sf.seaf.util
Class Generator

java.lang.Object
  extended by net.sf.seaf.util.Generator

public class Generator
extends Object

Utility class for random values generation.


Field Summary
static double[] LETTER_FREQS
          Frequencies of letters in English language.
 
Constructor Summary
Generator()
          Default constructor.
 
Method Summary
 Calendar date()
          Generate random date with the given year.
 Calendar date(int year)
          Generate random date with the given year.
 Calendar date(int year, int month)
          Generate random date with the given year and month.
 int englishLetterCode()
          Generate random letter 0-based index using the letter frequencies of English.
 long number(int length)
          Generate random number with the specified length.
 long number(int min, int max)
          Generate random number with length in the specified interval, inclusive.
 int numberExcl(int min, int max)
          Generate random number with value between minimum and maximum (exclusive).
 int numberIncl(int min, int max)
          Generate random number with value between minimum and maximum (inclusive).
 String phone()
          Generate random phone number.
 String sentence(int min, int max)
          Generate random sentence of the specified length in characters.
 Calendar time()
          Generate random time.
 String word(int length)
          Generate random word with the specified length.
 String word(int min, int max)
          Generate random word with length in the specified interval, inclusive.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LETTER_FREQS

public static final double[] LETTER_FREQS
Frequencies of letters in English language.

Constructor Detail

Generator

public Generator()
Default constructor.

Method Detail

numberExcl

public int numberExcl(int min,
                      int max)
Generate random number with value between minimum and maximum (exclusive).

Parameters:
min - minimum value, inclusive
max - maximum value, exclusive
Returns:
random number

numberIncl

public int numberIncl(int min,
                      int max)
Generate random number with value between minimum and maximum (inclusive).

Parameters:
min - minimum value, inclusive
max - maximum value, inclusive
Returns:
random number

number

public long number(int length)
Generate random number with the specified length.

Parameters:
length - length of number to be generated in digits
Returns:
random number

number

public long number(int min,
                   int max)
Generate random number with length in the specified interval, inclusive.

Parameters:
min - minimum length in digits, inclusive
max - maximum length in digits, inclusive
Returns:
random number

phone

public String phone()
Generate random phone number.

Returns:
random phone number

date

public Calendar date(int year,
                     int month)
Generate random date with the given year and month.

Parameters:
year - full year
month - month from 0 to 11
Returns:
random date

date

public Calendar date(int year)
Generate random date with the given year.

Parameters:
year - full year
Returns:
random date

date

public Calendar date()
Generate random date with the given year.

Returns:
random date

time

public Calendar time()
Generate random time.

Returns:
random time

englishLetterCode

public int englishLetterCode()
Generate random letter 0-based index using the letter frequencies of English.

Returns:
random letter 0-based index

word

public String word(int length)
Generate random word with the specified length.

Parameters:
length - length of word to be generated in characters
Returns:
random word

word

public String word(int min,
                   int max)
Generate random word with length in the specified interval, inclusive.

Parameters:
min - minimum length in characters, inclusive
max - maximum length in characters, inclusive
Returns:
random word

sentence

public String sentence(int min,
                       int max)
Generate random sentence of the specified length in characters.

Parameters:
min - minimum length in characters
max - maximum length in characters
Returns:
random sentence


Copyright © 2008-2011 SEAF. All Rights Reserved.