KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > deploy > shared > AbstractArchive


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.deployment.deploy.shared;
25
26 import java.io.OutputStream JavaDoc;
27 import java.io.InputStream JavaDoc;
28 import java.io.IOException JavaDoc;
29 import java.util.Enumeration JavaDoc;
30 import java.util.jar.Manifest JavaDoc;
31 import java.util.Vector JavaDoc;
32
33 import com.sun.enterprise.deployment.deploy.shared.WritableArchive;
34 import com.sun.enterprise.deployment.deploy.shared.Archive;
35
36 /**
37  * This abstract class contains all common implementation of the
38  * Archive/WritableArchive interfaces for all types of archives.
39  *
40  * @author Jerome Dochez
41  */

42 public abstract class AbstractArchive implements WritableArchive {
43
44     /**
45      * @return the archive uri
46      */

47     public abstract String JavaDoc getArchiveUri();
48
49     /**
50      * @return the size of the archive
51      */

52      public abstract long getArchiveSize() throws NullPointerException JavaDoc, SecurityException JavaDoc;
53                 
54     /**
55      * @return an @see java.util.Enumeration of entries in this abstract
56      * archive, providing the list of embedded archive to not count their
57      * entries as part of this archive
58      */

59     public abstract Enumeration JavaDoc entries(Enumeration JavaDoc embeddedArchives);
60     
61     /**
62      * @return true if this archive exists
63      */

64     public abstract boolean exists();
65     
66     /**
67      * deletes the archive
68      */

69     public abstract boolean delete();
70     
71     /**
72      * rename the archive
73      *
74      * @param name the archive name
75      */

76     public abstract boolean renameTo(String JavaDoc name);
77     
78     /**
79      * @return true if this archive abstraction supports overwriting of elements
80      */

81     public boolean supportsElementsOverwriting() {
82         return false;
83     }
84     
85     /**
86      * @return the sub archive
87      */

88     public Archive getSubArchive(String JavaDoc name) throws IOException JavaDoc {
89         return getEmbeddedArchive(name);
90     }
91     
92     /**
93      * close a sub archive
94      */

95     public abstract void closeEntry(AbstractArchive sub) throws IOException JavaDoc;
96     
97     public abstract AbstractArchive getEmbeddedArchive(String JavaDoc name)
98         throws IOException JavaDoc;
99
100     /**
101      * Returns an enumeration of the module file entries with the
102      * specified prefix. All elements in the enumeration are of
103      * type String. Each String represents a file name relative
104      * to the root of the module.
105      *
106      * @param prefix the prefix of entries to be included
107      * @return an enumeration of the archive file entries.
108      */

109     public Enumeration JavaDoc entries(String JavaDoc prefix) {
110         Enumeration JavaDoc allEntries = entries();
111         Vector JavaDoc entries = new Vector JavaDoc();
112         while (allEntries.hasMoreElements()) {
113             String JavaDoc name = (String JavaDoc) allEntries.nextElement();
114             if (name != null && name.startsWith(prefix)) {
115                 entries.add(name);
116             }
117         }
118         return entries.elements();
119     }
120 }
121
Popular Tags