/**
   * Load the cached menu entries. If the cache is not set it will return null (beware of
   * NullPointerExceptions)
   */
  @SuppressWarnings("unchecked")
  public static DelayedRequester load(Context ctx) throws IOException {
    FileInputStream fis = ctx.openFileInput(CACHE_ID);
    ObjectInputStream ois = new ObjectInputStream(fis);
    DelayedRequester req = new DelayedRequester();
    try {
      String db = (String) ois.readObject();
      if (!db.equals(Configure.getDatabaseCode(ctx))) {
        // The record is not for the current database
        ois.close();
        return null;
      }
      int tempId = ois.readInt();
      int size = ois.readInt();

      for (int i = 0; i < size; i++) {
        int cmdCode = ois.readInt();
        byte[] byteData = (byte[]) ois.readObject();
        Model data = Model.fromByteArray(byteData);
        boolean hasView = ois.readBoolean();
        ModelView view = null;
        if (hasView) {
          byteData = (byte[]) ois.readObject();
          view = ModelView.fromByteArray(byteData);
          ArchParser p = new ArchParser(view);
          p.buildTree();
        }
        Command cmd = new Command(cmdCode, data, view);
        req.queue.add(cmd);
      }
      req.updateNotification(ctx);
    } catch (ClassNotFoundException cnfe) {
      // Should never happen
    } catch (ClassCastException cce) {
      // Cache structure altered
      req = null;
    }
    ois.close();
    return req;
  }