classpathhelper
Class ClassStore

java.lang.Object
  extended byclasspathhelper.ClassStore

public abstract class ClassStore
extends java.lang.Object

A base class that defines a store for class bytes. This would typically correspond to a jar file or directory.

Since:
1.0
Author:
bharris

Field Summary
protected  CompositeClassStoreContentsFilter filters
          Filters used in determining if a file in the store should be visible
protected  SessionCache sessionCache
           
 
Constructor Summary
protected ClassStore(java.lang.String locationDescription, SessionCache theSessionCache)
           
 
Method Summary
 void addClassStoreContentsFilter(ClassStoreContentsFilter filter)
          Adds a new filter to this composite.
abstract  byte[] findBytes(java.lang.String path, long[] checksum)
          Method for looking up the bytes from a location in the given store.
abstract  byte[] findClassBytes(java.lang.String path, java.lang.String classname, long[] checksum)
          Deprecated. Use findBytes(java.lang.String, long[]).
protected  byte[] getBytes(java.io.InputStream in, long[] checksum)
          Internal helper method that copies the contents of an input stream into a byte array.
abstract  java.util.Iterator getClassNames()
          Deprecated. Use getContentNames().
abstract  java.util.Iterator getContentNames()
          Enumerates a list of ContentDescription objects which correspond to files within this class store.
 java.lang.String getLocationDescription()
          The name of this store.
abstract  java.lang.String getSeparator()
           
abstract  java.net.URL getURL(java.lang.String path)
          Returns a URL to the given entity.
 boolean removeClassStoreContentsFilter(ClassStoreContentsFilter filter)
          Removes a filter from the composite.
abstract  void verifyClassStore()
          Method used to test to see if this ClassStore is configured correctly.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sessionCache

protected SessionCache sessionCache

filters

protected CompositeClassStoreContentsFilter filters
Filters used in determining if a file in the store should be visible

Constructor Detail

ClassStore

protected ClassStore(java.lang.String locationDescription,
                     SessionCache theSessionCache)
Parameters:
locationDescription - The description of the location this class store represents.
Since:
1.0
Method Detail

findClassBytes

public abstract byte[] findClassBytes(java.lang.String path,
                                      java.lang.String classname,
                                      long[] checksum)
                               throws java.lang.ClassNotFoundException
Deprecated. Use findBytes(java.lang.String, long[]).

Method for looking up a class file's bytes from the given store.

Parameters:
path - The likely relative path of the classname (used as an optimization to prevent ClassStores from needing to recalculate this value on every call).
classname - The class to look up.
checksum - Optional output array (at least of length 1). Can be null.
Returns:
The bytes for that class
Throws:
java.lang.ClassNotFoundException - If the class is not in this store.
Since:
1.0

findBytes

public abstract byte[] findBytes(java.lang.String path,
                                 long[] checksum)
Method for looking up the bytes from a location in the given store.

Parameters:
path - The path within the store.
checksum - Optional output array (at least of length 1). Can be null.
Returns:
The bytes of the element or null if the element could not be found.

getClassNames

public abstract java.util.Iterator getClassNames()
Deprecated. Use getContentNames().

Enumerates a list of class names within this class store.

Returns:
An iterator of String objects corresponding to the classnames in this store.
Since:
1.0

getContentNames

public abstract java.util.Iterator getContentNames()
Enumerates a list of ContentDescription objects which correspond to files within this class store.

Returns:
An iterator of ContentDescription objects corresponding to the contents of the store.
Since:
1.1

getSeparator

public abstract java.lang.String getSeparator()
Returns:
The string used as a separator for paths. This is used by ClassStoreContentsFilter to allow it to correctly parse the contents of the store. This differs from File.separator in that some stores (such as jars) might always use a specific separator.
Since:
1.0

getURL

public abstract java.net.URL getURL(java.lang.String path)
                             throws java.net.MalformedURLException
Returns a URL to the given entity.

Parameters:
path - a forward slash / seperated path to the element.
Returns:
A URL over the given entity or null if the object is not found.
Throws:
java.net.MalformedURLException
Since:
1.1

verifyClassStore

public abstract void verifyClassStore()
                               throws java.lang.Exception

Method used to test to see if this ClassStore is configured correctly. Subclasses will throw exceptions if any problem exists with the configuration.

When successful this method just returns.

Throws:
java.lang.Exception - The problem with the configuration.

getLocationDescription

public java.lang.String getLocationDescription()
The name of this store. This would typically be a file path of some sort.

Returns:
A name identifying this store.
Since:
1.0

addClassStoreContentsFilter

public void addClassStoreContentsFilter(ClassStoreContentsFilter filter)
Adds a new filter to this composite. Filters can only be added once. If the same filter is added multiple times, subsequent adds will be ignored.

Parameters:
filter - The new filter object.
Since:
1.0

removeClassStoreContentsFilter

public boolean removeClassStoreContentsFilter(ClassStoreContentsFilter filter)
Removes a filter from the composite.

Parameters:
filter - The filter to remove.
Returns:
true If the filter was in the composite, otherwise false
Since:
1.0

getBytes

protected byte[] getBytes(java.io.InputStream in,
                          long[] checksum)
                   throws java.io.IOException
Internal helper method that copies the contents of an input stream into a byte array. Subclasses use this to retrieve bytes.

Parameters:
in - The input stream. Will be read to end, but not closed.
checksum - Optional array of size 1 to return the checksum from the bytes into. Can be null.
Returns:
The bytes within that input stream.
Throws:
java.io.IOException - If an I/O error occurs.
Since:
1.0