FileDocCategorySizeDatePackage
OutputJarArchive.javaAPI DocGlassfish v2 API7237Fri May 04 22:31:36 BST 2007com.sun.enterprise.deployment.deploy.shared

OutputJarArchive

public class OutputJarArchive extends AbstractArchive
Provides an implementation of the AbstractArchive that maps to a Jar file @see java.util.jar.JarFile
author
Jerome Dochez

Fields Summary
private String
archiveUri
protected ZipOutputStream
jos
private Manifest
manifest
private Vector
entries
Constructors Summary
Methods Summary
public voidclose()
close the abstract archive

        if (jos!=null) {
            jos.flush();
            jos.finish();
            jos.close();
            jos=null;
        }
    
public voidcloseEntry(AbstractArchive os)
close a previously returned @see java.io.OutputStream returned by an addEntry call

param
the output stream to close

        if (os instanceof OutputJarArchive) {
            ((OutputJarArchive) os).jos.flush();
            ((OutputJarArchive) os).jos.finish();
        }
        jos.closeEntry();
    
public voidcloseEntry()
closes the current entry

        if (jos!=null) {
            jos.flush();
            jos.closeEntry();
        } 
    
public voidcreate(java.lang.String path)
creates a new abstract archive with the given path

param
the path to create the archive

        archiveUri = path;
        File file = new File(path);
        // if teh file exists, we delete it first
        if (file.exists()) {
            file.delete();
        }
        FileOutputStream fos = new FileOutputStream(file);
        BufferedOutputStream bos = new BufferedOutputStream(fos);
        jos = new ZipOutputStream(bos);
    
public booleandelete()

        throw new UnsupportedOperationException("Cannot read from a JAR archive open for writing");        
    
public java.util.Enumerationentries()

return
an @see java.util.Enumeration of entries in this abstract archive

        return entries.elements();
    
public java.util.Enumerationentries(java.util.Enumeration embeddedArchives)

return
an @see java.util.Enumeration of entries in this abstract archive, providing the list of embedded archive to not count their entries as part of this archive

  	return entries();
     
public booleanexists()

        throw new UnsupportedOperationException("Cannot read from a JAR archive open for writing");        
    
public longgetArchiveSize()
Get the size of the archive

return
-1 because this is getting created

        return -1;
    
public java.lang.StringgetArchiveUri()

return
the archive uri

    
    
               
       
        return archiveUri;
    
public AbstractArchivegetEmbeddedArchive(java.lang.String name)

        OutputStream os = putNextEntry(name);
        ZipOutputStream jos = new ZipOutputStream(os);
        OutputJarArchive ja = new OutputJarArchive();
        ja.archiveUri = name;
        ja.jos = jos;
        return ja;
    
public java.io.InputStreamgetEntry(java.lang.String name)

return
a @see java.io.InputStream for an existing entry in the current abstract archive
param
the entry name

        throw new UnsupportedOperationException("Cannot read from a JAR archive open for writing");        
    
public java.util.jar.ManifestgetManifest()

return
the manifest information for this abstract archive

        if (manifest!=null) {
            manifest = new Manifest();
        }
        return manifest;
    
public java.net.URIgetURI()

        try {
            return ArchiveFactory.prepareArchiveURI(getArchiveUri());
        } catch(java.net.URISyntaxException e) {
            return null;
        } catch (UnsupportedEncodingException uee) {
            return null;
        } catch (IOException ioe) {
            return null;
        }
    
public voidopen(java.lang.String path)
Open an abstract archive

param
the path to the archive

        throw new UnsupportedOperationException("Cannot read jar files");        
    
public java.io.OutputStreamputNextEntry(java.lang.String name)

returns
an @see java.io.OutputStream for a new entry in this current abstract archive.
param
the entry name

        if (jos!=null) {
            ZipEntry ze = new ZipEntry(name);
            jos.putNextEntry(ze);
            entries.add(name);
        } 
        return jos;      
    
public booleanrenameTo(java.lang.String name)

        throw new UnsupportedOperationException("Cannot read from a JAR archive open for writing");