KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas_lib > genbase > archive > Archive


1 /**
2  * JOnAS : Java(TM) OpenSource Application Server
3  * Copyright (C) 1999-2004 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: Archive.java,v 1.2 2005/04/27 12:28:21 benoitf Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas_lib.genbase.archive;
27
28 import java.io.File JavaDoc;
29 import java.io.IOException JavaDoc;
30 import java.io.InputStream JavaDoc;
31 import java.util.List JavaDoc;
32 import java.util.jar.Manifest JavaDoc;
33
34 /**
35  * An <code>Archive</code> is a Wrapper around a Jar file (ear, war, jar) or
36  * around a directory structured lik a Jar file (unpacked jar file for example).
37  *
38  * @author Guillaume Sauthier
39  */

40 public interface Archive {
41
42     /**
43      * add the content of the given directory into the root of the archive.
44      *
45      * @param directory directory to add
46      */

47     void addDirectory(File JavaDoc directory);
48
49     /**
50      * add the content of the given directory into the given directory of the
51      * archive.
52      *
53      * @param dirName archive directory name.
54      * @param directory directory to add.
55      */

56     void addDirectoryIn(String JavaDoc dirName, File JavaDoc directory);
57
58     /**
59      * add a lonely file into the root directory of the archive.
60      *
61      * @param file the file to be added.
62      */

63     void addFile(File JavaDoc file);
64
65     /**
66      * add a file into the root directory of the archive with a specified name.
67      *
68      * @param file the file to be added.
69      * @param name filename
70      */

71     void addFile(File JavaDoc file, String JavaDoc name);
72
73     /**
74      * add a lonely file into the given directory of the archive.
75      *
76      * @param dirName archive directory name.
77      * @param file the file to be added.
78      */

79     void addFileIn(String JavaDoc dirName, File JavaDoc file);
80
81     /**
82      * Returns the File corresponding to the root of the archive.
83      *
84      * @return the File corresponding to the root of the archive.
85      */

86     File JavaDoc getRootFile();
87
88     /**
89      * Returns the Manifest of the Archive.
90      *
91      * @return the Manifest of the Archive.
92      */

93     Manifest JavaDoc getManifest();
94
95     /**
96      * Returns an InputStream corresponding to the given filename.
97      *
98      * @param filename file name source of the InputStream
99      *
100      * @return the InputStream corresponding to the given filename.
101      *
102      * @throws IOException When InputStream cannot be retrieved for filename.
103      */

104     InputStream JavaDoc getInputStream(String JavaDoc filename) throws IOException JavaDoc;
105
106     /**
107      * Returns a List of all files contained in this archive. Original files in
108      * jar, added Files are all included as String in this Enumeration.
109      *
110      * @return a List of all files contained in this archive.
111      */

112     List JavaDoc getContainedFiles();
113
114     /**
115      * Returns true if archive is packed or false if archive is unpacked.
116      *
117      * @return true if archive is packed or false if archive is unpacked.
118      */

119     boolean isPacked();
120
121     /**
122      * Returns the name of the Archive.
123      *
124      * @return the name of the Archive.
125      */

126     String JavaDoc getName();
127
128     /**
129      * Close this archive
130      * @throws IOException if close fail
131      */

132     void close() throws IOException JavaDoc;
133 }
Popular Tags