FileDocCategorySizeDatePackage
StaticWeaveDirectoryOutputHandler.javaAPI DocGlassfish v2 API4537Tue May 22 16:54:44 BST 2007oracle.toplink.essentials.internal.weaving

StaticWeaveDirectoryOutputHandler

public class StaticWeaveDirectoryOutputHandler extends AbstractStaticWeaveOutputHandler
The class provides a set of methods to pack passed-in entries into the sepcified archive file. the class handle directory output.

Fields Summary
private URL
source
private URL
target
Constructors Summary
public StaticWeaveDirectoryOutputHandler(URL source, URL target)
Construct an instance of StaticWeaveDirectoryOutputHandler.

param
source
param
target

    
    
                  
       
        this.source=source;
        this.target=target;
    
Methods Summary
public voidaddDirEntry(java.lang.String dirPath)
create directory into target directory.

param
dirPath
throws
IOException

       File file = new File(this.target.getPath()+File.separator+dirPath).getAbsoluteFile();
       if (!file.exists()){
           file.mkdirs();
       }
    
public voidaddEntry(java.util.jar.JarEntry targetEntry, byte[] entryBytes)
Write entry bytes into target, this method is usually invoked if class has been tranformed

param
targetEntry
param
entryBytes
throws
IOException

        File target  = new File(this.target.getPath()+targetEntry.getName()).getAbsoluteFile();
        if(!target.exists()) {
            target.createNewFile();
        }
        (new FileOutputStream(target)).write(entryBytes);
    
public voidaddEntry(java.io.InputStream jis, java.util.jar.JarEntry entry)
Write entry into target, this method usually copy original class into target.

param
jis
param
entry
throws
IOException

    
        File target  = new File(this.target.getPath()+entry.getName()).getAbsoluteFile();
        if(!target.exists()) {
            target.createNewFile();
        }
        if((new File(this.source.toURI())).isDirectory()){
            File sourceEntry = new File(this.source.getPath()+entry.getName());
            FileInputStream fis = new FileInputStream(sourceEntry);
            byte[] classBytes = new byte[fis.available()];
            fis.read(classBytes);
            (new FileOutputStream(target)).write(classBytes);
        }else{
            readwriteStreams(jis,(new FileOutputStream(target)));
        }