|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.claritysys.data.NameGenerator
public class NameGenerator
Class to generate random but reasonable people names, both male and female.
To use, create an instance of NameGenerator and invoke nextName() one or more times. Unlike some of the other random data generators which return a single String, NameGenerator returns a NameGenerator.Name object which allows you to access the component parts of the name.
Example usage:
NameGenerator gen = new NameGenerator (); for (int i = 0; i < count; i++) { System.out.println (gen.nextName ()); System.out.println (); }
Output from above code:
MR PERRY J BOOKER TITLE: MANAGER DPT: MANAGEMENT INFORMATION SYSTEMS EMAIL: pbooker@companyname.com MS PAT COURTNEY JACOBSON TITLE: VP DPT: INFORMATION TECHNOLOGY EMAIL: pjacobson@companyname.com MRS NANCY S MCCORMICK DDS TITLE: SR VICE PRESIDENT DPT: ENGINEERING EMAIL: nmccormick@companyname.com
The names, titles, and departments are constructed from lists which are hard-coded as String arrays in this program. If somebody feels inspired they could move them to a resource file ....
Nested Class Summary | |
---|---|
static class |
NameGenerator.Name
A single generated name with its component parts. |
static class |
NameGenerator.Test
Inner class for testing. |
Constructor Summary | |
---|---|
NameGenerator()
|
Method Summary | |
---|---|
static java.lang.String[] |
getDepartments()
|
static java.lang.String[] |
getFemaleFirstNames()
|
static java.lang.String[] |
getLastNames()
|
static java.lang.String[] |
getMaleFirstNames()
|
static java.lang.String[] |
getSuffixes()
|
static java.lang.String[] |
getTitles()
|
NameGenerator.Name |
nextName()
Return the next random name. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public NameGenerator()
Method Detail |
---|
public NameGenerator.Name nextName()
public static java.lang.String[] getMaleFirstNames()
public static java.lang.String[] getFemaleFirstNames()
public static java.lang.String[] getLastNames()
public static java.lang.String[] getSuffixes()
public static java.lang.String[] getTitles()
public static java.lang.String[] getDepartments()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |