dscopesi.djar
Class DJarArchive

java.lang.Object
  |
  +--dscopesi.djar.DJarArchive

public class DJarArchive
extends java.lang.Object

A Bean that implements a Jar(or Zip) archive. Use it with a DJarDirTree and a DJarEntryTable for powerful functionality.

Version:
1.0 2/4/1999
Author:
Dario Scopesi dario.scopesi@usa.net
See Also:
DJarDirTree, DJarEntryTable, DJarAttribsViewer

Constructor Summary
DJarArchive()
          Constructs a DJarArchive that is not bound to a file.
 
Method Summary
 void addDJarListener(DJarListener l)
          Adds a listener of DJarEvent
 long extract(java.util.Enumeration entries, java.io.File destination, boolean extractWithPath)
          Extracts multiple entries.
 boolean extract(java.util.jar.JarEntry e, java.io.File destination, boolean extractWithPath)
          Extracts the single entry.
 long extract(java.lang.String archivePath, java.io.File destination, boolean extractWithPath, boolean scanSubFolders)
          Extracts all the entries that are in a folder of the archive
protected  void fireDataChanged(DJarEvent e)
          Fires a DJarEvent to all listeners
 javax.swing.tree.TreeNode getDirectoryTree()
          Returns the root nod of the directory tree of the archive
 java.util.Enumeration getEntries()
          Returns all the entries in the archive (an Enumeration of JarEntry)
 java.util.Vector getEntriesInPath(java.lang.String path, boolean scanSubFolders)
          Given a path in the archive, returns all the entries in that path.
 java.util.jar.JarEntry getEntry(java.lang.String name)
          Returns the named entry
static java.lang.String getEntryFileName(java.util.jar.JarEntry entry)
          Removes tha path from a JarEntry name
 java.util.jar.JarFile getFile()
          The JarFile in use
 java.lang.String getFileName()
          The name of the JarFile in use
protected  void readDirectoryTree()
          Scans all the archive to build the tree
 void removeDJarListener(DJarListener l)
          Removes a listener of DJarEvent
 void setFile(java.io.File file)
          Open the file as a JarFile, scan it and refreshes everything
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DJarArchive

public DJarArchive()
Constructs a DJarArchive that is not bound to a file. Use setFile to open a file.
See Also:
setFile
Method Detail

getFile

public java.util.jar.JarFile getFile()
The JarFile in use

setFile

public void setFile(java.io.File file)
             throws java.io.IOException
Open the file as a JarFile, scan it and refreshes everything

getFileName

public java.lang.String getFileName()
The name of the JarFile in use

removeDJarListener

public void removeDJarListener(DJarListener l)
Removes a listener of DJarEvent
See Also:
DJarEvent

addDJarListener

public void addDJarListener(DJarListener l)
Adds a listener of DJarEvent
See Also:
DJarEvent

fireDataChanged

protected void fireDataChanged(DJarEvent e)
Fires a DJarEvent to all listeners

getEntries

public java.util.Enumeration getEntries()
Returns all the entries in the archive (an Enumeration of JarEntry)
See Also:
JarEntry

getEntry

public java.util.jar.JarEntry getEntry(java.lang.String name)
Returns the named entry

getDirectoryTree

public javax.swing.tree.TreeNode getDirectoryTree()
Returns the root nod of the directory tree of the archive

readDirectoryTree

protected void readDirectoryTree()
Scans all the archive to build the tree

getEntriesInPath

public java.util.Vector getEntriesInPath(java.lang.String path,
                                         boolean scanSubFolders)
Given a path in the archive, returns all the entries in that path.
Returns:
a Vector of JarEntry
See Also:
JarEntry

getEntryFileName

public static java.lang.String getEntryFileName(java.util.jar.JarEntry entry)
Removes tha path from a JarEntry name

extract

public boolean extract(java.util.jar.JarEntry e,
                       java.io.File destination,
                       boolean extractWithPath)
                throws java.io.IOException
Extracts the single entry.
Parameters:
e - the entry to extract
destination - the destination path in the file system
extractWithPath - extracts the entry with its full path (create if necessary)
Returns:
true if succesful

extract

public long extract(java.util.Enumeration entries,
                    java.io.File destination,
                    boolean extractWithPath)
             throws java.io.IOException
Extracts multiple entries.
Parameters:
entries - the entries to extract
destination - the destination path in the file system
extractWithPath - extracts the entries with their full path (create if necessary)
Returns:
the number of entries extracted

extract

public long extract(java.lang.String archivePath,
                    java.io.File destination,
                    boolean extractWithPath,
                    boolean scanSubFolders)
             throws java.io.IOException
Extracts all the entries that are in a folder of the archive
Parameters:
archivePath - the path to the entries to extract
destination - the destination path in the file system
extractWithPath - extracts the entries with their full path (create if necessary)
scanSubFolders - extracts entries from subfolders of archivePath, too
Returns:
the number of entries extracted