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.
manifest- The manifest.
MANIFEST_NAME- File name of the manifest.
pairs- A serializable set of key/value associations.
Bucket()
- Creates a Bucket with no content.
Bucket(InputStream)
- Creates a bucket with the content of a jar file.
clone()
- Clones the Bucket.
get(String)
- Return the byte array associated with the given file name.
getClassLoader()
- Returns the ClassLoader
getManifest()
- Returns the manifest.
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.
hasConflict(Bucket)
- Determines if two Buckets have common files which differ in their manifests.
jar(OutputStream)
- Write the bucket in jar file format (compressed)
modified(String)
- Return the time when an entry was last modified.
put(String, byte[])
- Associates a name and a value.
putObject(String, Object)
- Serialize an object and save it as a named resource file in the jar.
remove(String)
- Remove a file and its manifest entry from the bucket.
removeObject(String)
- Remove an object and its manifest entry from the bucket.
resources()
- Return an enumeration of the file names.
setNested(Bucket)
- Assign the bucket in which this bucket is nested.
store(OutputStream)
- Write the bucket in jar file format (uncompressed)
update(Bucket)
- Update the bucket with the contents of another.
validate()
- Validate the jar contents against the manifest security hashes.
MANIFEST_NAME
protected static final String MANIFEST_NAME
- File name of the manifest.
manifest
protected Manifest manifest
- The manifest.
pairs
protected Vector pairs
- A serializable set of key/value associations.
Bucket
public Bucket()
- Creates a Bucket with no content.
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.
setNested
public void setNested(Bucket context)
- Assign the bucket in which this bucket is nested.
getClassLoader
public final ClassLoader getClassLoader()
- Returns the ClassLoader
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.
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.
clone
public Object clone()
- Clones the Bucket.
- Overrides:
- clone in class Object
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.
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.
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.
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
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.
resources
public Enumeration resources()
- Return an enumeration of the file names.
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.
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.
getManifest
public Manifest getManifest()
- Returns the manifest.
validate
public boolean validate() throws NoSuchAlgorithmException
- Validate the jar contents against the manifest security hashes.
Returns true if all are valid.
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.
update
public void update(Bucket b)
- Update the bucket with the contents of another.
All Packages Class Hierarchy This Package Previous Next Index