Example #1
0
  /**
   * Sets the compression level. There is no guarantee of the exact position of the change, but if
   * you call this when needsInput is true the change of compression level will occur somewhere near
   * before the end of the so far given input.
   *
   * @param lvl the new compression level.
   */
  public void setLevel(int lvl) {
    if (lvl == DEFAULT_COMPRESSION) lvl = 6;
    else if (lvl < NO_COMPRESSION || lvl > BEST_COMPRESSION) throw new IllegalArgumentException();

    if (level != lvl) {
      level = lvl;
      engine.setLevel(lvl);
    }
  }