    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Class w3c.jigsaw.upgrade.from1to2.SimpleResourceStore

    java.lang.Object
       |
       +----w3c.jigsaw.upgrade.from1to2.SimpleResourceStore

public class SimpleResourceStore
extends Object

A very naive resource store. This resource store keeps all the resources in a file. It loads all resources (on a per-demand basis), and never unloads them.

##

SimpleResourceStore()

##

enumerateResourceIdentifiers()
  Enumerate all the resources identifier in this repository.
getFileAt(int)
  Get our file, positionned at the given position.
getResourceBytes(ResourceIndex, byte[])
  Get the bytes that are the pickled version of the given resource.
initialize(File)
  Initialize this simple store with the given file.
loadIndex(Hashtable)
  Restore our whole index from our repository.
save()
  Internal save: save the repository back to disk.
toString()
  Print a simple resource store.
upgrade(String)

##

SimpleResourceStore

     public SimpleResourceStore()

##

getFileAt

     protected RandomAccessFile getFileAt(int pos) throws IOException

  Get our file, positionned at the given position. We won't keep our repository file always open (too much of these resource stroe would burn our available file descriptors).

  Parameters:
    at - The position at wich you want the stream.

loadIndex

     protected synchronized void loadIndex(Hashtable target) throws IOException

  Restore our whole index from our repository.

getResourceBytes

     protected synchronized byte[] getResourceBytes(ResourceIndex index,
                                                    byte into[]) throws IOException

  Get the bytes that are the pickled version of the given resource. This opens the file for each resource, it could of course be optimized for the cases were all the resources are to be loaded at once.

  Parameters:
    identifier - The resource identifier.
  Returns:
    The length, in the instance buffer, of the bytes that makes this resource.

save

     public synchronized void save() throws IOException

  Internal save: save the repository back to disk.

  Parameters:
    unload - Should we unload any existing resources ?

upgrade

     public boolean upgrade(String identifier) throws IOException, ResourceUpgraderException

enumerateResourceIdentifiers

     public Enumeration enumerateResourceIdentifiers()

  Enumerate all the resources identifier in this repository.

toString

     public String toString()

  Print a simple resource store.

  Overrides:
    toString in class Object

initialize

     public void initialize(File repository) throws IOException

  Initialize this simple store with the given file.

  Parameters:
    manager - The resource store manager that loaded use.
    file - The repository file.

    All Packages  Class Hierarchy  This Package  Previous  Next  Index