01: package org.databene.domain.person;
02:
03: import org.databene.benerator.IllegalGeneratorStateException;
04: import org.databene.benerator.LightweightGenerator;
05: import org.databene.benerator.csv.RegionalCSVGenerator;
06: import org.databene.region.Region;
07:
08: /**
09: * (c) Copyright 2006 by Volker Bergmann
10: * Created: 09.06.2006 21:13:09
11: */
12: public class GivenNameGenerator extends LightweightGenerator<String> {
13:
14: private RegionalCSVGenerator<String> realGenerator;
15:
16: public GivenNameGenerator() {
17: this (Region.getDefault(), Gender.MALE);
18: }
19:
20: public GivenNameGenerator(Region region, Gender gender) {
21: if (gender == Gender.FEMALE)
22: realGenerator = new RegionalCSVGenerator<String>(
23: "org/databene/domain/person/givenName_female",
24: region, ".csv");
25: else if (gender == Gender.MALE)
26: realGenerator = new RegionalCSVGenerator<String>(
27: "org/databene/domain/person/givenName_male",
28: region, ".csv");
29: else
30: throw new IllegalArgumentException("Gender: " + gender);
31: }
32:
33: public Class<String> getGeneratedType() {
34: return String.class;
35: }
36:
37: public void setRegion(Region region) {
38: realGenerator.setRegion(region);
39: }
40:
41: public String generate() throws IllegalGeneratorStateException {
42: return realGenerator.generate();
43: }
44:
45: // java.lang.Object overrides --------------------------------------------------------------------------------------
46:
47: public String toString() {
48: return getClass().getSimpleName() + '['
49: + realGenerator.getRegion() + ']';
50: }
51: }
|