public static Object unserialize(Data data){
  try {
    Class clazz=(Class)Class.forName((String)data.get("class"));
    if (clazz.isEnum()) {
      return Enum.valueOf(clazz,data.get("value"));
    }
 else     if (clazz == Vector3D.class) {
      return new Vector3D(data.get("x"),data.get("y"),data.get("z"));
    }
 else     if (clazz == Vector2D.class) {
      return new Vector2D(data.get("x"),(double)data.get("y"));
    }
 else {
      return unserialize(clazz,data);
    }
  }
 catch (  Exception e) {
    throw new DataException(e);
  }
}

public static Object unserialize ( Data data ) { try { Class clazz = ( Class ) Class . forName ( ( String ) data . get ( "class" ) ) ; if ( clazz . isEnum ( ) ) { return Enum . valueOf ( clazz , data . get ( "value" ) ) ; } else if ( clazz == Vector3D . class ) { return new Vector3D ( data . get ( "x" ) , data . get ( "y" ) , data . get ( "z" ) ) ; } else if ( clazz == Vector2D . class ) { return new Vector2D ( data . get ( "x" ) , ( double ) data . get ( "y" ) ) ; } else { return unserialize ( clazz , data ) ; } } catch ( Exception e ) { throw new DataException ( e ) ; } }
loads an object from its stored data , with an unknown class . the class of the object must be stored within the data .
