ArchiveAccessor V 1.0


Support Classes


List of Classes:


up public class Base64
extends
Object

The Base64 class is a standard class for passing binary data as the ASCII. Methods contained in this class are as follows:

Base64
public Base64()
Creates an instance of the class.
binToAsc
public static byte[] binToAsc(byte bin[])
Converts an array of binary bytes to an array of ASCII bytes. ASCII characters used are A-Z, a-z, 0-9, /, and +. The '=' is used for padding the ASCII to a multiple of 4 bytes.
Parameters:
bin - binary data
Returns:
  equivalent ASCII data

up public final class FilenameFilter
extends
Object
implements
FilenameFilter

The FilenameFilter class implements filtering filenames. Methods contained in this class are as follows:

FilenameFilter
public FilenameFilter(String aWildcards)
Creates an instance of the class.
Parameters:
aWildcards - file name wildcards
 
accept
public boolean accept(File aDir,
                      String aName)
Tests if a specified file matches a file name filter.
Parameters:
aDir - directory in which a file is found
aName - file name
Returns:
true if a file name matches a file name filter; otherwise, false

up public class Folder
extends
FolderBucket

The Folder class adds file operations to a folder bucket. Methods contained in this class are as follows:

Folder
public Folder()
Creates a folder bucket with no contents.
 
Folder
public Folder(String aName) throws IOException, SecurityException
Creates a folder bucket with a list of file names of a folder.
Parameters:
aName - folder name
Throws: IOException
May be thrown when reading from a folder.
Throws: SecurityException
If a security manager exists, its checkRead method is called with a pathname of this folder to see if an application allows reading access to a folder.
 
Folder
public Folder(String aName,
              String aFilter) throws IOException, SecurityException
Creates a folder bucket with a filtered list of file names of a folder.
Parameters:
aName - folder name
aFilter - file name filter
Throws: IOException
May be thrown when reading from a folder.
Throws: SecurityException
If a security manager exists, its checkRead method is called with a path name of this folder to see if an application allows reading access to the folder.
 
setName
public void setName(String aName)
Sets a folder name.
Parameters:
aName - folder name
 
getName
public String getName()
Gets a folder name.
Returns:
folder name
 
open
public void open(String aName)
Opens a folder.
Parameters:
aName - folder name
Overrides:
open in class FolderBucket
 
rename
public void rename(String aNewName) throws IOException
Renames a folder.
Parameters:
aNewName - new name of a folder
Throws: SecurityException
If a security manager exists, its checkWrite method is called both with a path name of this folder and with a path name of a destination target object to see if an application allows writing to both folders.
 
putFileName
public void putFileName(String aFileName)
Puts a file name in a folder bucket.
Parameters:
aFileName - file name to be put in a folder bucket
 
writeFile
public void writeFile(String aFileName,
                      byte aData[]) throws IOException
Writes a file to a folder.
Parameters:
aFileName - file name to be written in a folder
aData - byte array associated with a file name
Throws: IOException
If an I/O error occurs.
 
makeSubFolder
public void makeSubFolder(String aSubFolderName)
Makes a folder.
Parameters:
aSubFolderName - subdirectory name to be created

up public class FolderBucket
extends
Object
implements Clonable, Serializable

The FolderBucket class holds a folder list of files. Methods contained in this class are as follows:

FolderBucket
public FolderBucket()
Creates a bucket with no contents.
 
FolderBucket
public FolderBucket(String aFolder) throws IOException, SecurityException
Creates a bucket with a folder list of files.
Parameters:
aFolder - folder name
Throws: IOException
May be thrown when reading from the input stream.
Throws: SecurityException
If a security manager exists, its checkRead method is called with a path name of this folder to see if an application allows reading access to a folder.
 
FolderBucket
public FolderBucket(String aFolder,
                     String aFilter) throws IOException, SecurityException
Creates a bucket with a folder filtered list of files.
Parameters:
aFolder - folder name
aFilter - file name filter
Throws: IOException
May be thrown when reading from the input stream.
Throws: SecurityException
If a security manager exists, its checkRead method is called with a path name of this folder to see if an application allows reading access to a folder.
 
open
public void open(String aFolder)
Opens a folder bucket.
 
clone
public synchronized Object clone()
Clones a folder bucket.
Overrides:
clone in class Object
 
get
public synchronized byte[] get(String name) throws IOException
Returns a byte array associated with a given file name.
Parameters:
name -  /-separated path name completed with file extensions
Returns:
associated byte array or null
 
modified
public synchronized long modified(String aName)
Returns the time when an entry was last modified.
Parameters:
aName -  /-separated path name completed with file extensions
Returns:
time in milliseconds or 0
 
put
public synchronized void put(String aName,
                              long aTime)
Associates a name and a value.
Parameters:
aName -  /-separated path name completed with file extensions
aTime - time when a file represented by this name was last modified
 
resources
public Enumeration resources()
Returns enumeration of file names.
 
remove
public synchronized void remove(String aName)
Removes a file name from a folder bucket.
Parameters:
aName -   /-separated path name completed with file extensions
 
size
public synchronized int size()
Returns a number of file names in a folder bucket.
Returns:
number of file names in a folder bucket
 

up public class JarBucket
extends
ZipBucket

The JarBucket class holds contents of a Jar bucket. Methods contained in this class are as follows:

JarBucket
public JarBucket()
Creates a bucket with no contents.
 
JarBucket
public JarBucket(InputStream is) throws IOException, ZipException
Creates a bucket with contents of a Jar file.
Parameters:
is - input stream for a Jar file
Throws: IOException
May be thrown when reading from the input stream.
Throws: ZipException
May be thrown when processing contents of a Jar file.
 
jar
public synchronized void jar(OutputStream os) throws IOException, ZipException
Writes a bucket in a Jar file format.
Parameters:
os - output stream for a Jar file
Throws: IOException
May be thrown while writing to the output stream.
Throws: ZipException
May be thrown when processing contents of a Jar file.
 
clone
public synchronized Object clone()
Clones a bucket.
Overrides:
clone in class ZipBucket
 
getObject
public Object getObject(String name) throws IOException, ClassNotFoundException
Either deserializes an existing object or, if there is no such object, creates a new object by using a null constructor of a class with the same name.
Parameters:
name - dot-separated name with no file extension
Throws: IOException
error occurred while deserializing
Throws: ClassNotFoundException
no object or class with that name
 
get
public synchronized byte[] get(String name)
Returns a byte array associated with a given file name.
Parameters:
name -   /-separated path name completed  with file extensions
Returns:
  associated byte array or null
Overrides:
get in class ZipBucket
 
putObject
public synchronized void putObject(String name,
                                    Object obj) throws IOException
Serializes an object and saves it as a named resource file in a Jar file. This is the exact reverse of java.beans.Beans.instantiate. Security hashes are included in the manifest.
Parameters:
name - dot-separated name with no file extension; the '.'s are replaced by '/' and ".ser" is appended
obj - object to be saved
Throws: IOException
error occurred while adding an object
 
put
public void put(String name,
                 byte value[])
Associates a name and a value. Security hashes are included in the manifest.
Parameters:
name -  /-separated path name completed with file extensions
value - associated byte array
Overrides:
put in class ZipBucket
 
remove
public synchronized void remove(String name)
Removes a file and its manifest entry from a Jar bucket.
Parameters:
name -  /-separated path name completed with file extensions
Overrides:
remove in class ZipBucket
clear
public synchronized void clear()
Empties a jar bucket.
Overrides:
clear in class ZipBucket
 
setManifest
public synchronized void setManifest(Manifest aManifest)
Sets a new manifest.
Parameters:
aManifest - new manifest
 
getManifest
public synchronized Manifest getManifest()
Returns the manifest.
Returns:
manifest
 
setCreateManifest
public synchronized void setCreateManifest(boolean aSwitch)
Turns on/off creating the manifest file.
Parameters:
aSwitch - switch to create the manifest file
 
isCreateManifest
public synchronized boolean isCreateManifest()
Returns a switch for creating the manifest file.
Returns:
switch for creating the manifest file
 
getManifestName
public String getManifestName()
Returns a name of the manifest file.
Returns:
manifest file name

up public class JarFile
extends
JarBucket

The JarFile class adds file operations to a Jar bucket. Methods contained in this class are as follows:

JarFile
public JarFile()
Creates a bucket with no contents.
 
JarFile
public JarFile(String fileName) throws IOException, ZipException
Creates a bucket with contents of a Jar file.
Parameters:
pfileName - Jar file name
Throws: IOException
May be thrown when reading from a Jar file.
Throws: ZipException
May be thrown when processing contents of a Jar file.
 
setFileName
public void setFileName(String aFileName)
Sets a name of a Jar file.
Parameters:
aFileName - Jar file name
 
getFileName
public String getFileName()
Gets a Jar file name.
Returns:
  Jar file name
 
saveAs
public void saveAs(String pfileName) throws IOException, ZipException
Writes a bucket to a Jar file.
Parameters:
pfileName - Jar file name
Throws: IOException
May be thrown while writing to a Jar file.
Throws: ZipException
May be thrown when processing contents of a Jar file.
 
save
public void save() throws IOException, ZipException
Updates a Jar file.
Throws: IOException
May be thrown while writing to a Jar file.
Throws: ZipException
May be thrown when processing contents of a Jar file.
 
putFile
public void putFile(String pfileName) throws IOException
Puts a file in a bucket.
Parameters:
pfileName - file name to be put in a bucket
Throws: IOException
May be thrown when reading a file.
 
putFile
public void putFile(String pfileName,
                     String as) throws IOException
Puts a file in a bucket.
Parameters:
pfileName - file name to be read
as - file name added to a bucket
Throws: IOException
May be thrown when reading a file.

up public class Manifest
extends
Object
implements Serializable, Clonable

The Manifest class represents the manifest of a Jar file. Methods contained in this class are:

Manifest
public Manifest()
Creates the manifest.
 
Manifest
public Manifest(String txt[])
Creates the manifest from an array of strings.
 
Manifest
public Manifest(byte data[])
Creates the manifest from an array of bytes.
 
clone
public synchronized Object clone()
Clones the manifest.
Overrides:
clone in class Object
 
clear
public synchronized void clear()
Empties the manifest.
 
get
public synchronized String[] get()
Returns an array of strings comprising the manifest.
 
getBytes
public byte[] getBytes()
Returns the manifest as an array of bytes.
 
get
public synchronized ManifestSection get(String name)
Returns a named manifest section. Null is returned if there is no matching section.
 
force
public synchronized ManifestSection force(String name)
Returns a named manifest section. The section is created if necessary.
 
remove
public synchronized void remove(String name)
Removes a named manifest section.
 
add
public synchronized void add(ManifestSection ms)
Adds a manifest section unless a name starts with META-INF/ or /META-INF/.
 
sections
public Enumeration sections()
Returns enumeration of the sections of the manifest.

up public class ManifestSection
extends Object
implements Serializable, Clonable

The ManifestSection class represents a section of the manifest from a Jar file. Methods contained in this class are:

ManifestSection
public ManifestSection()
A null constructor required for serialization.
 
ManifestSection
public ManifestSection(String id)
A normal constructor initializes a section name.
Parameters:
id - path name
 
ManifestSection
public ManifestSection(String header[])
Loads a pre-existing manifest section.
Parameters:
header - an array of strings in   form "name: value" or " value"
 
clone
public synchronized Object clone()
Clones a section.
Overrides:
clone in class Object
 
equals
public synchronized boolean equals(Object o)
Returns true if section names are equal.
Parameters:
o - another ManifestSection
Overrides:
equals in class Object
 
remove
public synchronized void remove(String name)
Removes an item from a section.
Parameters:
name - item name
 
add
public synchronized void add(String name,
                              String value)
Adds an item to a section.
Parameters:
name - item name
value - value assigned to an item
 
get
public synchronized String get(String name)
Returns an item value in a section or null.
Parameters:
name - item name
Returns:
  assigned value
 
get
public synchronized String[] get()
Returns contents of a section as an array of strings.
 
base64Hash
public static String base64Hash(String algorithm,
                                 byte data[]) throws NoSuchAlgorithmException
Returns a security hash as the base64 ASCII string.
Parameters:
algorithm - security hash algorithm name
data - data to be hashed
Throws: NoSuchAlgorithmException
unimplemented security hash
 
addHash
public void addHash(byte data[])
Adds MD5 and SHA security hashes to a section.
Parameters:
data - data associated with a section
 
validate
public boolean validate(byte data[]) throws NoSuchAlgorithmException
Validates the security hash.
Parameters:
data - data associated with a section
Returns:
true when valid
Throws: NoSuchAlgorithmException
unimplemented security hash

up public final class Matching
extends Object

The Matching class implements a pattern matching method. Methods contained in this class are:

Matching
public Matching()
Creates an instance of the class.
 
match
public static boolean match(String aTarget,
                             String aPattern)
There is a requested pattern matching method. The following pattern allows :
'*' - match 0 or more chars, '#' - match 1 chars, '[]' - define  set of chars. A set can contain a range, e.g. pattern *#[0-9][0-9] define any string having two digits at the end and any character before (length at least 3)
Parameters:
aTarget - source string to be matched
aPattern - pattern string

up public final class Reads
extends
Object

This is a fast variable-length reader. It reads into a series of buffers, each buffer being twice as large as the last one. At the end, it allocates a single buffer which is exactly equal in length to the total bytes read. It  copies everything into this final buffer then. Methods contained in this class are:

Reads
public Reads()
Creates an instance of the class.
 
read
public static byte[] read(InputStream is) throws IOException
Reads all bytes from an input stream.
Parameters:
is - input stream to read from
Returns: IOException
buffer of read bytes

up public class ZipBucket
extends Object
implements Clonable, Serializable

The ZipBucket class holds contents of a Zip file. Methods contained in this class are:

ZipBucket
public ZipBucket()
Creates a bucket with no contents.
 
ZipBucket
public ZipBucket(InputStream is) throws IOException, ZipException
Creates a bucket with contents of a  Zip file.
Parameters:
is - input stream for a Zip file
Throws: IOException
May be thrown when reading from the input stream.
Throws: ZipException
May be thrown when processing contents of a Zip file.
 
zip
public synchronized void zip(OutputStream os) throws IOException, ZipException
Writes a bucket in the  Zip file format.
Parameters:
os - output stream for a Zip file
Throws: IOException
May be thrown while writing to the output stream.
Throws: ZipException
May be thrown when processing contents of a Zip file.
 
clone
public synchronized Object clone()
Clones a Zip bucket.
Overrides:
clone in class Object
 
get
public synchronized byte[] get(String name)
Returns a byte array associated with a given file name.
Parameters:
name -   /-separated path name completed with file extensions
Returns:
associated byte array or null
 
clear
public synchronized void clear()
Empties a bucket.
 
modified
public synchronized long modified(String name)
Returns the time when an entry was last modified.
Parameters:
name -  /-separated path name completed with file extensions
Returns:
time in milliseconds or 0
 
put
public void put(String name,
                 byte value[])
Associates a name and a value.
Parameters:
name -  /-separated path name completed with file extensions
value - associated byte array
 
resources
public Enumeration resources()
Returns enumeration of  file names.
 
remove
public synchronized void remove(String name)
Removes a file from a Zip bucket.
Parameters:
name -  /-separated path name completed with file extensions
 
size
public synchronized int size()
Returns a number of files in a Zip bucket.
Returns:
number of files in a Zip bucket
 
setUseCompression
public synchronized void setUseCompression(boolean aSwitch)
Turns on/off using a ZIP compression.
Parameters:
aSwitch - switch for using a   ZIP compression
 
isUseCompression
public synchronized boolean isUseCompression()
Returns a switch for using a ZIP compression.
Returns:
switch for using a ZIP compression

up public class ZipFile
extends ZipBucket

The ZipFile class adds file operations to a ZIP bucket. Methods contained in this class are:

ZipFile
public ZipFile()
Creates a bucket with no contents.
 
ZipFile
public ZipFile(String pfileName) throws IOException, ZipException
Creates a bucket with contents of a Zip file.
Parameters:
pfileName - Zip file name
Throws: IOException
May be thrown when reading from a Zip file.
Throws: ZipException
May be thrown when processing contents of a Zip file.
 
setFileName
public void setFileName(String aFileName)
Sets a Zip file name.
Parameters:
aFileName - Zip file name
 
getFileName
public String getFileName()
Gets a Zip file name.
Returns:
Zip file name
 
saveAs
public void saveAs(String pfileName) throws IOException, ZipException
Writes a bucket to a Zip file.
Parameters:
pfileName - Zip file name
Throws: IOException
May be thrown while writing to a Zip file.
Throws: ZipException
May be thrown when processing contents of a Zip file.
 
save
public void save() throws IOException, ZipException
Updates a Zip file.
Throws: IOException
May be thrown while writing to a Zip file.
Throws: ZipException
May be thrown when processing contents of a Zip file.
 
putFile
public void putFile(String pfileName) throws IOException
Puts a file in a bucket.
Parameters:
pfileName - file name to be put in a bucket
Throws: IOException
May be thrown when reading a file.
 
putFile
public void putFile(String pfileName,
                     String as) throws IOException
Puts a file in a bucket.
Parameters:
pfileName - file name to be read
as - file name added to a bucket
Throws: IOException
May be thrown when reading a file.

up public abstract class FileBucketAccessor
extends Object
implements Clonable, Serializable

FileBucketAccessor is a generic class that introduces functionality of a bean that implements access to a bucket of files. Methods contained in this class are:

FileBucketAccessor
public FileBucketAccessor()
Constructor
 
setArchiveName
public void setArchiveName(String aName) throws IllegalArgumentException
Sets a file bucket name. s the PropertyChange event if the name of a file bucket is actually changing.
Parameters: Fire
aName - file bucket name
Throws: IllegalArgumentException
May be thrown when a name is null.
 
setAutomaticSave
public void setAutomaticSave(boolean aSwitch)
Turns on/off a switch that indicates whether a file bucket is automatically saved when being closed or not. Fires the PropertyChange event if the switch for automatic saving is actually changing.
Parameters:
aSwitch - true or false
 
isAutomaticSave
public boolean isAutomaticSave()
Returns a switch that indicates whether a file bucket is automatically saved when being closed or not.
 
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener aListener)
     throws IllegalArgumentException
Registers a new listener of the PropertyChange event.
Parameters:
aListener - object to be registered as a listener of the PropertyChange event
Throws: IllegalArgumentException
May be thrown when a listener object is null.
 
removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener aListener)
            throws IllegalArgumentException
Removes a listener of the PropertyChange event.
Parameters:
aListener - object to be removed as a listener of the PropertyChange event
Throws: IllegalArgumentException
May be thrown when a listener object is null.
 
open
public abstract void open(String aFileName) throws FileBucketAccessorException
Opens a file bucket.
Throws: FileBucketAccessorException
May be thrown  when
- file bucket name is null or empty,
- reading from a file bucket,
- processing contents of a file bucket,
- opening a new archive file, but a current file is not saved,
- file bucket does not exist. 
 
create
public abstract void create() throws FileBucketAccessorException
Prepares a new file bucket.
Throws: FileBucketAccessorException
May be thrown when
- current  archive is not closed,
- archive name is not set,
- writing to an archive,
- processing contents of an archive,
- I/O error occurs.
 
create
public abstract void create(String aFileName)throws FileBucketAccessorException
Prepares a new file bucket from an existing one.
Parameters:
aFileName - archive name copy of which is created
Throws: FileBucketAccessorException
May be thrown when
- archive name is not set,
- reading from an archive,
- writing to an archive,
- processing contents of an archive.
 
exists
public abstract boolean exists(String aFile)throws FileBucketAccessorException
Checks if a specified file name is present in the bucket.
Parameters:
aFile - file name to be checked in an archive file
Throws: FileBucketAccessorException
May be thrown when
- archive file is not opened,
- file name is null or empty.
 
close
public abstract void close() throws FileBucketAccessorException
Closes a file bucket.
Throws: FileBucketAccessorException
May be thrown when
- file bucket is not opened,
- file bucket name is not set,
- writing to a file bucket,
- processing contents of a file bucket.
 
add
public abstract void add(String aFile) throws FileBucketAccessorException
Adds a file to a file bucket.
Throws: FileBucketAccessorException
May be thrown when
- file bucket is not opened,
- file name or directory is null or empty,
- I/O error occurs.
 
replace
public abstract void replace(String aFile) throws FileBucketAccessorException
Replaces a file in a file bucket.
Throws: FileBucketAccessorException
May be thrown when
- file bucket is not opened,
- file name is null or empty,
- specified  file does not exist in an archive,
- specified  file does not exist on the disk;
- reading a file bucket.
 
remove
public abstract void remove(String aFile) throws FileBucketAccessorException
Removes a file from a file bucket.
Throws: FileBucketAccessorException
May be thrown when
- file name is null or empty,
- specified file does not exist in an archive,
- file  bucket is not opened.
 
clear
public abstract void clear() throws FileBucketAccessorException
Removes all files from a file bucket.
Throws: FileBucketAccessorException
May be thrown when a file bucket is not opened.
 
rename
public abstract void rename(String anOldName,
                            String aNewName) throws FileBucketAccessorException
Renames a file in a file bucket.
Throws: FileBucketAccessorException
May be thrown when
- file bucket is not opened,
- specified  file does not exist in an archive,
- any of the two arguments is null or empty.
 
contents
public abstract String[] contents() throws FileBucketAccessorException
Gets contents of a file bucket.
Throws: FileBucketAccessorException
May be thrown when a file bucket is not opened.
 
contentsAsEnumeration
public abstract Enumeration contentsAsEnumeration() throws FileBucketAccessorException
Gets contents of a file bucket as enumeration.
Throws: FileBucketAccessorException
May be thrown when a file bucket is not opened.
 
save
public abstract void save() throws FileBucketAccessorException
Saves a file bucket.
Throws: FileBucketAccessorException
May be thrown when
- file bucket is not opened,
- file bucket name is not set,
- writing to a bucket,
- processing contents of a file bucket.
 
saveAs
public void saveAs(String aName) throws FileBucketAccessorException
Saves a file bucket with another name.
Throws: FileBucketAccessorException
May be thrown when
- file bucket is not opened,
- file bucket name is not set,
- writing to a file bucket,
- processing contents of a file bucket.

up public abstract class PackagedFileBucketAccessor
extends
FileBucketAccessor

PackagedFileBucketAccessor is a generic class that introduces functionality of a bean to access to a packaged bucket of files. Methods contained in this class are:

PackagedFileBucketAccessor
public PackagedFileBucketAccessor()
Constructor
 
add
public abstract void add() throws FileBucketAccessorException
Adds files to a packaged file bucket.
Throws: FileBucketAccessorException
May be thrown.
 
extract
public abstract void extract() throws FileBucketAccessorException
Extracts files from a packaged file bucket.
Throws: FileBucketAccessorException
May be thrown.
 
extract
public abstract void extract(String aFileName) throws FileBucketAccessorException
Extracts a file from a packaged file bucket.
Throws: FileBucketAccessorException
May be thrown.
 
getDefaultDirectory
public String getDefaultDirectory()
Gets a default directory.
Returns:
default directory
 
setDefaultDirectory
public void setDefaultDirectory(String aDirectory) throws IllegalArgumentException
Sets a default directory. Fires the PropertyChange event if the default directory is actually changing. 
Parameters:
aDirectory - new setting of a default directory
Throws: IllegalArgumentException
May be thrown when a specified directory is null.
 

up public class FileBucketAccessorException
extends
Exception

The FileBucketAccessorException class introduces an exception that may be thrown during the work with a bucket of files. Methods contained in this class are:

FileBucketAccessorException
public FileBucketAccessorException()
Constructs an exception with no specified detail message.
 
FileBucketAccessorException
public FileBucketAccessorException(String aMessage)
Constructs an exception with a specified detail message.
Parameters:
aMessage - detail message

up public class JarFileAccessorException
extends
FileBucketAccessorException

The JarFileAccessorException class defines an exception that may be thrown by methods of an object of the JarFileAccessor class. Methods contained in this class are:

JarFileAccessorException
public JarFileAccessorException()
Constructs an exception with no specified detail message.
 
JarFileAccessorException
public JarFileAccessorException(String aMessage)
Constructs an exception with a specified detail message.
Parameters:
aMessage - detail message

up public class ZipFileAccessorException
extends FileBucketAccessorException

The ZipFiletAccessorException class defines an exception that may be thrown by methods of an object of the ZipFileAccessor class.

ZipFileAccessorException
public ZipFileAccessorException()
Constructs an exception with no specified detail message.
 
ZipFileAccessorException
public ZipFileAccessorException(String aMessage)
Constructs an exception with a specified detail message.
Parameters:
aMessage - detail message

 


See also:


Last Modified : 08/28/98