KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > thoughtworks > xstream > Blah


1 package com.thoughtworks.xstream;
2
3 import com.thoughtworks.acceptance.objects.OpenSourceSoftware;
4 import com.thoughtworks.acceptance.objects.SampleLists;
5 import com.thoughtworks.acceptance.objects.Software;
6
7 public class Blah {
8
9     private static long last;
10
11     private static void time(String JavaDoc msg) {
12         long now = System.currentTimeMillis();
13         if (last == 0) {
14             last = now;
15         }
16         System.out.println((now - last) + " " + msg);
17         last = now;
18     }
19
20     public static void main(String JavaDoc[] args) {
21
22         time("Starting");
23         SampleLists sampleLists = new SampleLists();
24         for (int i = 0; i < 1000; i++) {
25             sampleLists.bad.add(new Software("aaa", "bbbb"));
26             sampleLists.bad.add(new OpenSourceSoftware("aaa", "bbbb", "cccc"));
27             sampleLists.bad.add(sampleLists);
28         }
29         time("Build object");
30
31         XStream xstream = new XStream();
32         xstream.alias("sample-lists", SampleLists.class);
33         xstream.alias("software", Software.class);
34         xstream.alias("oss-software", OpenSourceSoftware.class);
35         time("Initialized");
36
37         String JavaDoc xml = xstream.toXML(sampleLists);
38         time("Serialized");
39
40         xstream.fromXML(xml);
41         time("Deserialized");
42
43     }
44 }
45
Popular Tags