uk.org.ogsadai.client.dbcreate2
Class TravelDataCreator

java.lang.Object
  |
  +--uk.org.ogsadai.client.dbcreate2.TravelDataCreator

public class TravelDataCreator
extends java.lang.Object

This class generates the data used in the test databases.

Author:
The OGSA-DAI Project Team

Field Summary
private static java.lang.String COPYRIGHT_NOTICE
           
private static java.lang.String[] COUNTRIES
           
private static java.lang.String[] DESTINATION_NAME
           
private static java.lang.String[] FIRST_NAMES
           
private static java.lang.String[] LAST_NAMES
           
private static byte[] mRandomBytes
          Holds a random byte array of size SIZE
private static java.lang.String[] PLACES
           
private static java.lang.String[] ROADS
           
private static int SEED
          Seed value for random number generator - do not modify.
private static int SIZE
           
private static java.lang.String[] TOWNS
           
 
Constructor Summary
TravelDataCreator()
           
 
Method Summary
private  java.lang.String chooseDate(long i, int minYear, int maxYear)
          Returns a date string between minYear and maxYear, corresponding to the specified index in the test data
private static java.lang.String chooseFromArray(java.lang.String[] stringArray, int i)
          Picks a value from a String array depending on value of i
private static int chooseFromByteArray(long i)
          Picks a value from the random byte array depending on the value of i
private  int[] chooseNumbers(long i, int length)
          Returns an array of integers between 0 and 9, corresponding to the specified index in the test data.
private  java.lang.String chooseTime(long i)
          Returns a time of the day corresponding to the specified index in the test data
 java.lang.String generateAddress(int i)
          Returns a address corresponding to the specified index in the test data.
 byte[] generateBytes(int i, int length)
          Returns a randomly generated byte array corresponding to the specified index in the test data.
 java.lang.String generateCountry(int i)
          Picks a country from the list corresponding to the specified index in the test data.
 java.lang.String generateDepartureDate(long i)
          Generates a departure date in the years 2000 to 2010.
 java.lang.String generateDepartureTime(long i)
          Generates a departure time corresponding to the specified index within the test data.
 java.lang.String generateDescription(int i)
          Generates a text description corresponding to the specified index
 int generateDestination(long i, int maxValue)
          Generates an integer n where 1 <= n <= maxValue, corresponding to the specified index in the test data.
 java.lang.String generateDestinationName(int i)
          Picks the name of a destination from a list corresponding to the specified index in the test data
 java.lang.String generateDOB(int i)
          Generates a date of birth corresponding to the specified index in the test data.
 java.lang.String generateName(int i)
          Returns a name corresponding to the specified index in the test data.
 java.lang.String generatePhone(int i)
          Returns a phone number corresponding to the specified index in the test data
 double generatePrice(long i)
          Generates a price with corresponding to the specified index in the test data
 java.lang.String generateTimestamp(long i)
          Generates a time stamp corresponding to the specified index in the test data
 int generateTraveller(long i, int maxValue)
          Generates an integer n where 1 <= n <= maxValue, depending on the specified index in the test data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPYRIGHT_NOTICE

private static final java.lang.String COPYRIGHT_NOTICE
See Also:
Constant Field Values

SEED

private static final int SEED
Seed value for random number generator - do not modify.

See Also:
Constant Field Values

mRandomBytes

private static byte[] mRandomBytes
Holds a random byte array of size SIZE


SIZE

private static final int SIZE
See Also:
Constant Field Values

FIRST_NAMES

private static final java.lang.String[] FIRST_NAMES

LAST_NAMES

private static final java.lang.String[] LAST_NAMES

TOWNS

private static final java.lang.String[] TOWNS

ROADS

private static final java.lang.String[] ROADS

DESTINATION_NAME

private static final java.lang.String[] DESTINATION_NAME

PLACES

private static final java.lang.String[] PLACES

COUNTRIES

private static final java.lang.String[] COUNTRIES
Constructor Detail

TravelDataCreator

public TravelDataCreator()
Method Detail

generatePhone

public java.lang.String generatePhone(int i)
Returns a phone number corresponding to the specified index in the test data

Parameters:
i - index within test data
Returns:
a String containing the phone number.

generateName

public java.lang.String generateName(int i)
Returns a name corresponding to the specified index in the test data.

Parameters:
i - index within test data
Returns:
a String containing a name.

generateAddress

public java.lang.String generateAddress(int i)
Returns a address corresponding to the specified index in the test data.

Parameters:
i - index within test data
Returns:
a String containing the address.

generateDOB

public java.lang.String generateDOB(int i)
Generates a date of birth corresponding to the specified index in the test data.

Parameters:
i - index within test data
Returns:
String a date in the format YYYY-MM-DD

generateTraveller

public int generateTraveller(long i,
                             int maxValue)
Generates an integer n where 1 <= n <= maxValue, depending on the specified index in the test data.

Parameters:
maxValue - the upper bound
i - index within test data
Returns:
an integer

generateDestination

public int generateDestination(long i,
                               int maxValue)
Generates an integer n where 1 <= n <= maxValue, corresponding to the specified index in the test data.

Parameters:
i - index within test data
maxValue - the upper bound
Returns:
a random integer

generateDestinationName

public java.lang.String generateDestinationName(int i)
Picks the name of a destination from a list corresponding to the specified index in the test data

Parameters:
i - index within test data
Returns:
String

generateCountry

public java.lang.String generateCountry(int i)
Picks a country from the list corresponding to the specified index in the test data.

Parameters:
i - index within test data
Returns:
a String containing a country name

generateDescription

public java.lang.String generateDescription(int i)
Generates a text description corresponding to the specified index

Parameters:
i - index within test data
Returns:
String

generateBytes

public byte[] generateBytes(int i,
                            int length)
Returns a randomly generated byte array corresponding to the specified index in the test data.

Parameters:
i - index within test data
length - the length of the byte array
Returns:
byte array with random entries

generateDepartureDate

public java.lang.String generateDepartureDate(long i)
Generates a departure date in the years 2000 to 2010.

Parameters:
i - index within test data
Returns:
date String in the format YYYY-MM-DD

generateDepartureTime

public java.lang.String generateDepartureTime(long i)
Generates a departure time corresponding to the specified index within the test data.

Parameters:
i - index within test data
Returns:
String time of the day in format HH:MM:SS

generateTimestamp

public java.lang.String generateTimestamp(long i)
Generates a time stamp corresponding to the specified index in the test data

Parameters:
i - index within test data
Returns:
String a time stamp in the format YYYY-MM-DD HH:MM:SS

generatePrice

public double generatePrice(long i)
Generates a price with corresponding to the specified index in the test data

Parameters:
i - index within test data
Returns:
double

chooseFromArray

private static java.lang.String chooseFromArray(java.lang.String[] stringArray,
                                                int i)
Picks a value from a String array depending on value of i

Parameters:
stringArray -
i - index within test data
Returns:
String a value from the input String array

chooseFromByteArray

private static int chooseFromByteArray(long i)
Picks a value from the random byte array depending on the value of i

Parameters:
i - index within test data
Returns:
byte

chooseNumbers

private int[] chooseNumbers(long i,
                            int length)
Returns an array of integers between 0 and 9, corresponding to the specified index in the test data.

Parameters:
i - index within test data
length - the length of the returned array
Returns:
int[] an integer array of length length

chooseDate

private java.lang.String chooseDate(long i,
                                    int minYear,
                                    int maxYear)
Returns a date string between minYear and maxYear, corresponding to the specified index in the test data

Parameters:
i - index within test data
minYear -
maxYear -
Returns:
String a date in format YYYY-MM-DD where maxYear >= YYYY >= minYear

chooseTime

private java.lang.String chooseTime(long i)
Returns a time of the day corresponding to the specified index in the test data

Parameters:
i - index within test data
Returns:
String a time of the day in format HH:MM:SS