/plugins/Archive/tags/archive-0_3_3/archive/ArchiveCommand.java

# · Java · 50 lines · 19 code · 13 blank · 18 comment · 4 complexity · 98bd2eb1cc15345d8d29cd718fd1927c MD5 · raw file

  1. /*
  2. * ArchiveCommand.java
  3. * Copyright (c) 2001, 2002 Andre Kaplan
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version 2
  8. * of the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. */
  19. package archive;
  20. import com.ice.tar.TarInputStream;
  21. import java.io.IOException;
  22. import java.io.InputStream;
  23. import java.util.Hashtable;
  24. import java.util.zip.ZipInputStream;
  25. public abstract class ArchiveCommand {
  26. abstract Hashtable getDirectories(String archiveProtocol, String archivePath)
  27. throws IOException;
  28. abstract InputStream createInputStream(String path) throws IOException;
  29. public static ArchiveCommand getCommand(InputStream in) {
  30. if (in instanceof TarInputStream) {
  31. return new TarCommand((TarInputStream) in);
  32. } else if (in instanceof ZipInputStream) {
  33. return new ZipCommand((ZipInputStream) in);
  34. } else {}
  35. return null;
  36. }
  37. }