public <B> void read(DataInputStream in, ModeSettingsConverter<Location, B> converter)
      throws IOException {
    Version version = Version.read(in);
    version.checkCurrent();

    lastMaximizedLocation = new HashMap<String, Location>();
    lastMaximizedMode = new HashMap<String, Path>();

    int count = in.readInt();
    for (int i = 0; i < count; i++) {
      String key = in.readUTF();
      String value = in.readUTF();
      lastMaximizedMode.put(key, new Path(value));
    }

    count = in.readInt();
    for (int i = 0; i < count; i++) {
      String key = in.readUTF();
      Location location = converter.convertToWorld(converter.readProperty(in));
      lastMaximizedLocation.put(key, location);
    }
  }
  public <B> void write(DataOutputStream out, ModeSettingsConverter<Location, B> converter)
      throws IOException {
    Version.write(out, Version.VERSION_1_0_8);
    if (lastMaximizedMode == null) {
      out.writeInt(0);
    } else {
      int count = 0;
      for (Path check : lastMaximizedMode.values()) {
        if (check != null) {
          count++;
        }
      }

      out.writeInt(count);
      for (Map.Entry<String, Path> entry : lastMaximizedMode.entrySet()) {
        if (entry.getValue() != null) {
          out.writeUTF(entry.getKey());
          out.writeUTF(entry.getValue().toString());
        }
      }
    }

    if (lastMaximizedLocation == null) {
      out.writeInt(0);
    } else {
      int count = 0;
      for (Location location : lastMaximizedLocation.values()) {
        if (location != null) {
          count++;
        }
      }

      out.writeInt(count);
      for (Map.Entry<String, Location> entry : lastMaximizedLocation.entrySet()) {
        if (entry.getValue() != null) {
          out.writeUTF(entry.getKey());
          converter.writeProperty(converter.convertToSetting(entry.getValue()), out);
        }
      }
    }
  }