public class NameGenerator
extends java.lang.Object
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 ....
Modifier and Type | Class and Description |
---|---|
static class |
NameGenerator.Name
A single generated name with its component parts.
|
static class |
NameGenerator.Test
Inner class for testing.
|
Constructor and Description |
---|
NameGenerator() |
Modifier and Type | Method and Description |
---|---|
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.
|
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()
Copyright ? 2002 Clarity Systems Group, LLC. All Rights Reserved.