2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libjava / java / util / jar / JarEntry.java
blob4d527965f13132f297061871e29cea5145b78bb3
1 /* JarEntry.java - Represents an entry in a jar file
2 Copyright (C) 2000 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
38 package java.util.jar;
40 import java.io.IOException;
41 import java.security.cert.Certificate;
42 import java.util.zip.ZipEntry;
44 /**
45 * Extension to a ZipEntry that contains manifest attributes and certificates.
46 * Both the Atrributes and the Certificates can be null when not set.
47 * Note that the <code>getCertificates()</code> method only returns a
48 * valid value after all of the data of the entry has been read.
49 * <p>
50 * There are no public methods to set the attributes or certificate of an
51 * Entru. Only JarEntries created by the classes in <code>java.util.jar</code>
52 * will have these properties set.
54 * @since 1.2
55 * @author Mark Wielaard (mark@klomp.org)
58 public class JarEntry extends ZipEntry
60 // (Package local) fields
62 Attributes attr;
63 Certificate certs[];
65 // Constructors
67 /**
68 * Creates a new JarEntry with the specified name and no attributes or
69 * or certificates. Calls <code>super(name)</code> so all other (zip)entry
70 * fields are null or -1.
72 * @param name the name of the new jar entry
73 * @exception NullPointerException when the supplied name is null
74 * @exception IllegalArgumentException when the supplied name is longer
75 * than 65535 bytes
77 public JarEntry(String name) throws NullPointerException,
78 IllegalArgumentException
80 super(name);
81 attr = null;
82 certs = null;
85 /**
86 * Creates a new JarEntry with the specified ZipEntry as template for
87 * all properties of the entry. Both attributes and certificates will be
88 * null.
90 * @param entry the ZipEntry whose fields should be copied
92 public JarEntry(ZipEntry entry)
94 super(entry);
95 attr = null;
96 certs = null;
99 /**
100 * Creates a new JarEntry with the specified JarEntry as template for
101 * all properties of the entry.
103 * @param entry the jarEntry whose fields should be copied
105 public JarEntry(JarEntry entry)
107 super(entry);
110 attr = entry.getAttributes();
112 catch (IOException _)
115 certs = entry.getCertificates();
118 // Methods
121 * Returns a copy of the Attributes set for this entry.
122 * When no Attributes are set in the manifest null is returned.
124 * @return a copy of the Attributes set for this entry
125 * @exception IOException This will never be thrown. It is here for
126 * binary compatibility.
128 public Attributes getAttributes() throws IOException
130 if (attr != null)
132 return (Attributes) attr.clone();
134 else
136 return null;
141 * Returns a copy of the certificates set for this entry.
142 * When no certificates are set or when not all data of this entry has
143 * been read null is returned.
144 * <p>
145 * To make sure that this call returns a valid value you must read all
146 * data from the JarInputStream for this entry.
147 * When you don't need the data for an entry but want to know the
148 * certificates that are set for the entry then you can skip all data by
149 * calling <code>skip(entry.getSize())</code> on the JarInputStream for
150 * the entry.
152 * @return a copy of the certificates set for this entry
154 public Certificate[] getCertificates()
156 if (certs != null)
158 return (Certificate[])certs.clone();
160 else
162 return null;