|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.claritysys.data.CompanyNameGenerator
public class CompanyNameGenerator
Class to generate random company names.
To use, create an instance of CompanyNameGenerator and call nextName() one or more times.
Example:
CompanyNameGenerator gen = new CompanyNameGenerator (); for (int i = 0; i < count; i++) { System.out.println (gen.nextName ()); }
Sample output from the above code:
GARDEN MATERIALS HI-TECH CONNECTION FOCUS GROUP EAGLE EYE HAIR DESIGN BENEFICIAL HAIR DESIGN AFFORDABLE COMMUNICATIONS ISAACS SYSTEMS MILLENIUM PEST CONTROL ALLIED SERVICES CARPET SERVICES
The names are built from two lists, one of nouns and one of suffixes. The lists are loaded as resources using getClass().getResourceAsStream. The file names are bname-noun.txt and bname-suffix.txt, and should be in the same package as this class.
At present the company names are sample from the phone book from A to M.
You can also supply your own custom list by using the constructor that takes two Lists as arguments.
Nested Class Summary | |
---|---|
static class |
CompanyNameGenerator.Test
Inner class for testing. |
Constructor Summary | |
---|---|
CompanyNameGenerator()
Create a new company name generator using the included name list files. |
|
CompanyNameGenerator(java.util.List nouns,
java.util.List suffixes)
Create a new company name generator using the provided lists. |
Method Summary | |
---|---|
static java.lang.String |
makeURL(java.lang.String name)
Convert the given (fake) company name into a fake WWW domain name by removing any non-characters and adding on "www." and ".com". |
java.lang.String |
nextName()
Generate and return the next randomly synthesized Company name. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CompanyNameGenerator(java.util.List nouns, java.util.List suffixes)
nouns
- A List of String nouns.suffixes
- a List of String suffixes.CompanyNameGenerator()
public CompanyNameGenerator()
If you don't like the names it generates you can modify the resource files or use the constructor that takes the two lists as arguments.
CompanyNameGenerator(List,List)
Method Detail |
---|
public java.lang.String nextName()
public static java.lang.String makeURL(java.lang.String name)
name
- The company name.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |