package test;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import uk.ac.ic.doc.automed.util.ObjectToolKit;

/**
 * TestSchemaSerialisation.java
 *
 * @author Duc M Le  <a href="mailto:dmle@doc.ic.ac.uk"><i>dmle@doc.ic.ac.uk</i></a>
 * Created on 23 August 2006
 * Department of Computing, Imperial College
 */

public class TestSchemaSerialisation {
  
  /**
   * Creates a new instance of TestSchemaSerialisation
   */
  public TestSchemaSerialisation() throws Exception {
    HashMap domainSpec = new HashMap();
    domainSpec.put("id", new double[] {1, 10, 2});
    domainSpec.put("yob", new double[] {1971, 1980, 3});
    
    String ser = new String(ObjectToolKit.getObjectSerialisation(domainSpec));
    HashMap dser = (HashMap) ObjectToolKit.getObjectFromSerialisation(ser.getBytes());
    
    System.out.println("Original domain spec:");
    displayMap(domainSpec);
    System.out.println("Serialised domain spec: \n" + ser);
    System.out.println("Derialised domain spec:");
    displayMap(dser);
  }
  
  private void displayMap(Map m) {
    for (Iterator it = m.keySet().iterator(); it.hasNext();) {
      Object key = it.next();
      Object val = m.get(key);
      System.out.println("key: " + key + "; val: "+val);
    }
  }
  
  public static void main(String[] args) throws Exception {
    TestSchemaSerialisation tss = new TestSchemaSerialisation();
  }
}
