001: /**
002: * JOnAS : Java(TM) OpenSource Application Server
003: * Copyright (C) 1999-2004 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: Archive.java 6657 2005-04-27 12:28:21Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.objectweb.jonas_lib.genbase.archive;
025:
026: import java.io.File;
027: import java.io.IOException;
028: import java.io.InputStream;
029: import java.util.List;
030: import java.util.jar.Manifest;
031:
032: /**
033: * An <code>Archive</code> is a Wrapper around a Jar file (ear, war, jar) or
034: * around a directory structured lik a Jar file (unpacked jar file for example).
035: *
036: * @author Guillaume Sauthier
037: */
038: public interface Archive {
039:
040: /**
041: * add the content of the given directory into the root of the archive.
042: *
043: * @param directory directory to add
044: */
045: void addDirectory(File directory);
046:
047: /**
048: * add the content of the given directory into the given directory of the
049: * archive.
050: *
051: * @param dirName archive directory name.
052: * @param directory directory to add.
053: */
054: void addDirectoryIn(String dirName, File directory);
055:
056: /**
057: * add a lonely file into the root directory of the archive.
058: *
059: * @param file the file to be added.
060: */
061: void addFile(File file);
062:
063: /**
064: * add a file into the root directory of the archive with a specified name.
065: *
066: * @param file the file to be added.
067: * @param name filename
068: */
069: void addFile(File file, String name);
070:
071: /**
072: * add a lonely file into the given directory of the archive.
073: *
074: * @param dirName archive directory name.
075: * @param file the file to be added.
076: */
077: void addFileIn(String dirName, File file);
078:
079: /**
080: * Returns the File corresponding to the root of the archive.
081: *
082: * @return the File corresponding to the root of the archive.
083: */
084: File getRootFile();
085:
086: /**
087: * Returns the Manifest of the Archive.
088: *
089: * @return the Manifest of the Archive.
090: */
091: Manifest getManifest();
092:
093: /**
094: * Returns an InputStream corresponding to the given filename.
095: *
096: * @param filename file name source of the InputStream
097: *
098: * @return the InputStream corresponding to the given filename.
099: *
100: * @throws IOException When InputStream cannot be retrieved for filename.
101: */
102: InputStream getInputStream(String filename) throws IOException;
103:
104: /**
105: * Returns a List of all files contained in this archive. Original files in
106: * jar, added Files are all included as String in this Enumeration.
107: *
108: * @return a List of all files contained in this archive.
109: */
110: List getContainedFiles();
111:
112: /**
113: * Returns true if archive is packed or false if archive is unpacked.
114: *
115: * @return true if archive is packed or false if archive is unpacked.
116: */
117: boolean isPacked();
118:
119: /**
120: * Returns the name of the Archive.
121: *
122: * @return the name of the Archive.
123: */
124: String getName();
125:
126: /**
127: * Close this archive
128: * @throws IOException if close fail
129: */
130: void close() throws IOException;
131: }
|