Esempio n. 1
0
 /**
  * Returns the {@code Manifest} object associated with this {@code JarFile}
  * or {@code null} if no MANIFEST entry exists.
  *
  * @return the MANIFEST.
  * @throws IOException
  *             if an error occurs reading the MANIFEST file.
  * @throws IllegalStateException
  *             if the jar file is closed.
  * @see Manifest
  */
 public Manifest getManifest() // throws IOException {
 {
     if (closed)
     {
         // archive.35=JarFile has been closed
         throw new java.lang.IllegalStateException("JarFile has been closed"); //$NON-NLS-1$
     }
     if (manifest != null)
     {
         return(manifest);
     }
     try {
         java.io.InputStream isJ = base.getInputStream(manifestEntry);
         if (verifier != null)
         {
             verifier.addMetaEntry(manifestEntry.getName(),
                                   org.apache.harmony.luni.util.InputStreamHelper.readFullyAndClose(isJ));
             isJ = base.getInputStream(manifestEntry);
         }
         try {
             manifest = new Manifest(isJ, verifier != null);
         } finally {
             isJ.close();
         }
         manifestEntry = null;  // Can discard the entry now.
     } catch (java.lang.NullPointerException) {
         manifestEntry = null;
     }
     return(manifest);
 }
Esempio n. 2
0
        /**
         * Returns all the ZipEntry's that relate to files in the
         * JAR's META-INF directory.
         *
         * @return the list of ZipEntry's or {@code null} if there are none.
         */
        private java.util.zip.ZipEntry[] getMetaEntriesImpl()
        {
            List <java.util.zip.ZipEntry>        list       = new ArrayList <java.util.zip.ZipEntry>(8);
            Enumeration <java.util.zip.ZipEntry> allEntries = entries();

            while (allEntries.hasMoreElements())
            {
                java.util.zip.ZipEntry ze = allEntries.nextElement();
                if (ze.getName().startsWith(META_DIR) &&
                    ze.getName().length() > META_DIR.length())
                {
                    list.add(ze);
                }
            }
            if (list.size() == 0)
            {
                return(null);
            }
            java.util.zip.ZipEntry[] result = new java.util.zip.ZipEntry[list.size()];
            list.toArray(result);
            return(result);
        }
Esempio n. 3
0
 /**
  * Creates a new zip entry with fields taken from the specified zip entry.
  *
  * <p />Assumes the entry represents a directory if and only if the
  * name ends with a forward slash "/".
  *
  * @param entry the entry to get fields from
  * @throws ZipException on error
  */
 public ZipArchiveEntry(java.util.zip.ZipEntry entry) : base(entry)  //throws ZipException
 {
     setName(entry.getName());
     byte[] extra = entry.getExtra();
     if (extra != null)
     {
         setExtraFields(ExtraFieldUtils.parse(extra, true,
                                              //ExtraFieldUtils.
                                              UnparseableExtraField.READ));
     }
     else
     {
         // initializes extra data to an empty byte array
         setExtra();
     }
     setMethod(entry.getMethod());
 }