KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jac > samples > contacts > Create


1
2 package org.objectweb.jac.samples.contacts;
3
4 import java.util.Random JavaDoc;
5
6 public class Create {
7    
8     /**
9      * A benchmark to create a bunch of contacts easily. Useful if
10      * you don't want to create contacts one by one to test the sample.
11      */

12     public static void main( String JavaDoc[] params ) {
13         int n = new Integer JavaDoc(params[0]).intValue();
14         String JavaDoc firstNames[] = new String JavaDoc[] {
15             "Laurent", "Renaud", "Maxime", "Matthieu", "Jérôme",
16             "Clément", "Thibault", "Carole", "Sonia", "Marie", "Mathilde",
17             "Frédéric", "Jean-Baptiste", "Nicolas", "Nathalie", "Grégoire",
18             "Marek", "Ania", "Sébastien", "Xavier", "Marta", "Annie",
19             "Philippe", "Béatrice", "Vincent" };
20         System.out.println( "Creating "+n+" contacts..." );
21         ContactRepository cr = new ContactRepository();
22         new FilteredContacts(cr);
23         Random JavaDoc rnd = new Random JavaDoc();
24         for (int i=0; i<n; i++) {
25             System.out.print( ""+i+" " );
26             cr.addContact(
27                 new Person("Contact"+i,
28                            firstNames[rnd.nextInt(firstNames.length)],
29                            "",
30                            "contact"+i+"@contacts.org"
31                 ));
32         }
33     }
34 }
35
Popular Tags