com.claritysys.data
Class PhoneGenerator

java.lang.Object
  extended by com.claritysys.data.PhoneGenerator

public class PhoneGenerator
extends java.lang.Object

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
 

Version:
$Revision: 2348 $

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

PhoneGenerator

public PhoneGenerator()
Method Detail

nextNumber

public PhoneGenerator.PhoneNumber nextNumber()
Fetch the next number with the same area code and prefix.

Returns:
the next number with the same area code and prefix.

nextNewNumber

public PhoneGenerator.PhoneNumber nextNewNumber()
Return the next number with a new area code and prefix.

Returns:
the next number with a new area code and prefix.

reset

public void reset()
Reset the area code and prefix so that the next call to nextNumber or nextNumberWithExtension will generate a new one.



Copyright ? 2002 Clarity Systems Group, LLC. All Rights Reserved.