All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Class ORG.opengroup.jar.Bucket

java.lang.Object
    |
    +----ORG.opengroup.jar.Bucket

public class Bucket
extends Object
implements Cloneable, Serializable
Holds the contents of a jar file.


Variable Index

 o manifest
The manifest.
 o MANIFEST_NAME
File name of the manifest.
 o pairs
A serializable set of key/value associations.

Constructor Index

 o Bucket()
Creates a Bucket with no content.
 o Bucket(InputStream)
Creates a bucket with the content of a jar file.

Method Index

 o clone()
Clones the Bucket.
 o get(String)
Return the byte array associated with the given file name.
 o getClassLoader()
Returns the ClassLoader
 o getManifest()
Returns the manifest.
 o getObject(String)
Either deserialize an existing object or, if there is no such object, create a new object using the null constructor of the class with the same name.
 o hasConflict(Bucket)
Determines if two Buckets have common files which differ in their manifests.
 o jar(OutputStream)
Write the bucket in jar file format (compressed)
 o modified(String)
Return the time when an entry was last modified.
 o put(String, byte[])
Associates a name and a value.
 o putObject(String, Object)
Serialize an object and save it as a named resource file in the jar.
 o remove(String)
Remove a file and its manifest entry from the bucket.
 o removeObject(String)
Remove an object and its manifest entry from the bucket.
 o resources()
Return an enumeration of the file names.
 o setNested(Bucket)
Assign the bucket in which this bucket is nested.
 o store(OutputStream)
Write the bucket in jar file format (uncompressed)
 o update(Bucket)
Update the bucket with the contents of another.
 o validate()
Validate the jar contents against the manifest security hashes.

Variables

 o MANIFEST_NAME
protected static final String MANIFEST_NAME
File name of the manifest.

 o manifest
protected Manifest manifest
The manifest.

 o pairs
protected Vector pairs
A serializable set of key/value associations.

Constructors

 o Bucket
public Bucket()
Creates a Bucket with no content.

 o Bucket
public Bucket(InputStream is) throws IOException, ZipException
Creates a bucket with the content of a jar file.

Parameters:
is - The input stream for the jar file.
Throws: IOException
May be thrown when reading from the input stream.
Throws: ZipException
May be thrown when processing the contents of the jar.

Methods

 o setNested
public void setNested(Bucket context)
Assign the bucket in which this bucket is nested.

 o getClassLoader
public final ClassLoader getClassLoader()
Returns the ClassLoader

 o jar
public void jar(OutputStream os) throws IOException, ZipException
Write the bucket in jar file format (compressed)

Parameters:
os - The output stream for the jar file.
Throws: IOException
May be thrown when writting to the output stream.
Throws: ZipException
May be thrown when processing the contents of the jar.
 o store
public void store(OutputStream os) throws IOException, ZipException
Write the bucket in jar file format (uncompressed)

Parameters:
os - The output stream for the jar file.
Throws: IOException
May be thrown when writting to the output stream.
Throws: ZipException
May be thrown when processing the contents of the jar.
 o clone
public Object clone()
Clones the Bucket.

Overrides:
clone in class Object
 o getObject
public Object getObject(String name) throws IOException, ClassNotFoundException
Either deserialize an existing object or, if there is no such object, create a new object using the null constructor of the class with the same name.

Parameters:
name - A dot-seperated name, with no file extension.
Throws: IOException
Error occurred while deserializing.
Throws: ClassNotFoundException
No object or class by that name.
 o get
public byte[] get(String name)
Return the byte array associated with the given file name.

Parameters:
name - A /-seperated path name, complete with file extensions.
Returns:
The associated byte array or null.
 o modified
public long modified(String name)
Return the time when an entry was last modified.

Parameters:
name - A /-seperated path name, complete with file extensions.
Returns:
The time in milliseconds, or 0.
 o putObject
public void putObject(String name,
                      Object obj) throws IOException
Serialize an object and save it as a named resource file in the jar. This is the exact reverse of java.beans.Beans.instantiate. Security hashes are included in the manifest.

Parameters:
name - A dot-seperated 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 the object.
See Also:
java.beans.Beans#instantiate
 o put
public void put(String name,
                byte[] value)
Associates a name and a value. Security hashes are included in the manifest.

Parameters:
name - A /-seperated path name, complete with file extensions.
value - The associated byte array.
 o resources
public Enumeration resources()
Return an enumeration of the file names.

 o removeObject
public void removeObject(String name)
Remove an object and its manifest entry from the bucket.

Parameters:
name - A dot-seperated path, with NO file extension.
 o remove
public void remove(String name)
Remove a file and its manifest entry from the bucket.

Parameters:
name - A /-seperated path name, complete with file extensions.
 o getManifest
public Manifest getManifest()
Returns the manifest.

 o validate
public boolean validate() throws NoSuchAlgorithmException
Validate the jar contents against the manifest security hashes. Returns true if all are valid.

 o hasConflict
public boolean hasConflict(Bucket b)
Determines if two Buckets have common files which differ in their manifests. This is a very strict test which will detect even differences in the delimiters used in the manifests. It is this strict to meet security requirements. Note that for every file in a bucket there is a manifest section which contains a security hash for that file, so as long as both buckets have been validated, one need only compare the manifests. Returns true if there is a conflict.

 o update
public void update(Bucket b)
Update the bucket with the contents of another.


All Packages  Class Hierarchy  This Package  Previous  Next  Index