|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.claritysys.data.PhoneGenerator
public class PhoneGenerator
Generates fake phone numbers for testing purposes.
While numbers could be totally randomly picked, generally you have a set of similar area code and prefixes for the same person.
To use, create an instance of PhoneGenerator then invoke nextNewNumber
, nextNumber
, or to
get a sequence of random phone numbers.
Example:
// Generate groups of 4 numbers having the name area code and prefix. PhoneGenerator gen = new PhoneGenerator (); for (int i = 0; i < count; i++) { System.out.println (gen.nextNumber ()); if (i % 4 == 0) { System.out.println (); gen.reset (); } }
Sample output:
(358) 194-4549 (358) 917-5857 (358) 917-8755 (358) 917-1203 (358) 917-9490 (358) 572-2284 (358) 572-9957 (358) 572-4731 (358) 572-8766 (358) 618-3093
Nested Class Summary | |
---|---|
static class |
PhoneGenerator.PhoneNumber
Represents a randomly generated phone number and its parts. |
static class |
PhoneGenerator.Test
Inner test class. |
Constructor Summary | |
---|---|
PhoneGenerator()
|
Method Summary | |
---|---|
PhoneGenerator.PhoneNumber |
nextNewNumber()
Return the next number with a new area code and prefix. |
PhoneGenerator.PhoneNumber |
nextNumber()
Fetch the next number with the same area code and prefix. |
void |
reset()
Reset the area code and prefix so that the next call to nextNumber or nextNumberWithExtension will generate a new one. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PhoneGenerator()
Method Detail |
---|
public PhoneGenerator.PhoneNumber nextNumber()
public PhoneGenerator.PhoneNumber nextNewNumber()
public void reset()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |