Exemple #1
0
 public static void main(String[] args) throws IOException, ClassNotFoundException {
   // Create a simple object graph
   DataStructure ds = new DataStructure();
   ds.message = "hello world";
   ds.data = new int[] {1, 2, 3, 4};
   ds.other = new DataStructure();
   ds.other.message = "nested structure";
   ds.other.data = new int[] {9, 8, 7};
   // Display the original object graph
   System.out.println("Original data structure: " + ds);
   // Output it to a file
   File f = new File("datastructure.ser");
   System.out.println("Storing to a file...");
   Serializer.store(ds, f);
   // Read it back from the file, and display it again
   ds = (DataStructure) Serializer.load(f);
   System.out.println("Read from the file: " + ds);
   // Create a deep clone and display that.  After making the copy
   // modify the original to prove that the clone is "deep".
   DataStructure ds2 = (DataStructure) Serializer.deepclone(ds);
   ds.other.message = null;
   ds.other.data = null; // Change original
   System.out.println("Deep clone: " + ds2);
 }
 /**
  * This adds a new job to the list.
  *
  * @param params
  * @param stats
  */
 public EvAJob addJob(InterfaceGOParameters params, AbstractStatistics stats) {
   EvAJob job = new EvAJob((InterfaceGOParameters) Serializer.deepClone(params), stats);
   stats.addDataListener(job);
   addJob(job, true);
   return job;
 }