All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.zeroturnaround.zip.ZipEntryOrInfoAdapter Maven / Gradle / Ivy

Go to download

The project is intended to have a small, easy and fast library to process ZIP archives. Either create, modify or explode them. On disk or in memory.

There is a newer version: 1.17
Show newest version
package org.zeroturnaround.zip;

import java.io.IOException;
import java.io.InputStream;
import java.util.zip.ZipEntry;

class ZipEntryOrInfoAdapter implements ZipEntryCallback, ZipInfoCallback {

  private final ZipEntryCallback entryCallback;
  private final ZipInfoCallback infoCallback;

  public ZipEntryOrInfoAdapter(ZipEntryCallback entryCallback, ZipInfoCallback infoCallback) {
    if (entryCallback != null && infoCallback != null || entryCallback == null && infoCallback == null) {
      throw new IllegalArgumentException("Only one of ZipEntryCallback and ZipInfoCallback must be specified together");
    }
    this.entryCallback = entryCallback;
    this.infoCallback = infoCallback;
  }

  public void process(ZipEntry zipEntry) throws IOException {
    infoCallback.process(zipEntry);
  }

  public void process(InputStream in, ZipEntry zipEntry) throws IOException {
    if (entryCallback != null) {
      entryCallback.process(in, zipEntry);
    }
    else {
      process(zipEntry);
    }
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy