Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.w3c.tools.resources.store
Class ResourceStoreImpl

    java.lang.Object
      |
      +--org.w3c.tools.resources.store.ResourceStoreImpl

public class ResourceStoreImpl
extends java.lang.Object
implements ResourceStore

A generic resource store that keeps resource in a file using the Serializer interface.

Field Summary
`protected ResourceStoreManager` | `manager` Our resource store manager.
`protected Serializer` | `serializer` Our Resource Serializer.

Constructor Summary
`ResourceStoreImpl()`

Method Summary
`boolean` | `acceptUnload()` Can this resource store be unloaded now ? This method gets called by the ResourceStoreManager before calling the `shutdown` method, when possible.
`void` | `addResource(Resource resource)` Add this resource to this resource store.
`java.util.Enumeration` | `enumerateResourceIdentifiers()` Enumerate all the resources saved in this store.
`java.lang.String` | `getIdentifier()` Get the identifier for that store.
`int` | `getVersion()` Get the version of that resource store.
`boolean` | `hasResource(java.lang.String identifier)` Check for the existence of a resource in this store.
`void` | `initialize(ResourceStoreManager manager, java.lang.Object token, java.io.File repository, Serializer serializer)` This resource store is being built, initialize it with the given arg.
`protected void` | `internalSave(boolean unload)` Internal save: save the repository back to disk.
`Resource` | `loadResource(java.lang.String identifier, java.util.Hashtable defs)` Restore the resource whose name is given.
`protected void` | `loadResources()`
`Resource` | `lookupResource(java.lang.String identifier)` Get this resource, but only if already loaded.
`protected void` | `markModified()`
`void` | `markModified(Resource resource)` Mark this resource as modified.
`protected void` | `markUsed()` Mark the store as having been used recently.
`void` | `removeResource(java.lang.String identifier)` Remove this resource from the repository.
`void` | `renameResource(java.lang.String oldid, java.lang.String newid)` Rename a given resource.
`void` | `save()` Save this store.
`void` | `saveResource(Resource resource)` Stabilize the given resource.
`void` | `shutdown()` Shutdown this store.
`protected void` | `warning(java.lang.String msg)` Emit the given string as a warning, to whoever it is appropriate.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### serializer

    protected Serializer serializer

  Our Resource Serializer.

### manager

    protected ResourceStoreManager manager

  Our resource store manager.

Constructor Detail

### ResourceStoreImpl

    public ResourceStoreImpl()

Method Detail

### markUsed

    protected final void markUsed()

  Mark the store as having been used recently.

### markModified

    protected void markModified()

### getVersion

    public int getVersion()

  Get the version of that resource store. Version numbers are used to distinguish between pickling format. A resource store implementator has the duty of bumping the returned number whenever it's archiving format changes. Resource stores that relies on some external archiving mechanisms (such as a database), may return a constant.
  Specified by:
    getVersion in interface ResourceStore
  Returns:
    An integer version number.

### getIdentifier

    public java.lang.String getIdentifier()

  Get the identifier for that store.
  Specified by:
    getIdentifier in interface ResourceStore
  Returns:
    A uniq store identifier, as a String.

### warning

    protected void warning(java.lang.String msg)

  Emit the given string as a warning, to whoever it is appropriate.
  Parameters:
    `msg` - The warning message.

### loadResource

    public Resource loadResource(java.lang.String identifier,
                                 java.util.Hashtable defs)
                          throws InvalidResourceException

  Restore the resource whose name is given. This method doesn't assume that the resource will actually be restored, it can be kept in a cache by the ResourceStore object, and the cached version of the resource may be returned.
  Specified by:
    loadResource in interface ResourceStore
  Parameters:
    `identifier` - The identifier of the resource to restore.
    `defs` - Default attribute values. If the resource needs to be restored from its pickled version, this Hashtable provides a set of default values for some of the attributes.
  Returns:
    A Resource instance, or null.
  Throws:
    InvalidResourceException - If the resource could not be restored from the store.

### lookupResource

    public Resource lookupResource(java.lang.String identifier)

  Get this resource, but only if already loaded. The resource store may (recommended) maintain a cache of the resource it loads from its store. If the resource having this identifier has already been loaded, return it, otherwise, return null.
  Specified by:
    lookupResource in interface ResourceStore
  Parameters:
    `identifier` - The resource identifier.
  Returns:
    A Resource instance, or null.

### saveResource

    public void saveResource(Resource resource)

  Stabilize the given resource.
  Specified by:
    saveResource in interface ResourceStore
  Parameters:
    `resource` - The resource to save.

### addResource

    public void addResource(Resource resource)

  Add this resource to this resource store.
  Specified by:
    addResource in interface ResourceStore
  Parameters:
    `resource` - The resource to be added.

### removeResource

    public void removeResource(java.lang.String identifier)

  Remove this resource from the repository.
  Specified by:
    removeResource in interface ResourceStore
  Parameters:
    `identifier` - The identifier of the resource to be removed.

### renameResource

    public void renameResource(java.lang.String oldid,
                               java.lang.String newid)

  Rename a given resource.
  Specified by:
    renameResource in interface ResourceStore
  Parameters:
    `oldid` - The olde resource identifier.
    `newid` - The new resource identifier.

### markModified

    public void markModified(Resource resource)

  Mark this resource as modified.
  Specified by:
    markModified in interface ResourceStore
  Parameters:
    `resource` - The resource that has changed (and will have to be pickled some time latter).

### acceptUnload

    public boolean acceptUnload()

  Can this resource store be unloaded now ? This method gets called by the ResourceStoreManager before calling the `shutdown` method, when possible. An implementation of that method is responsible for checking the `acceptUnload` method of all its loaded resource before returning true, meaning that the resource store can be unloaded.
  Specified by:
    acceptUnload in interface ResourceStore
  Returns:
    A boolean true if the resource store can be unloaded.

### internalSave

    protected void internalSave(boolean unload)
                         throws java.io.IOException

  Internal save: save the repository back to disk.
  Parameters:
    `unload` - Should we unload any existing resources ?

### shutdown

    public void shutdown()

  Shutdown this store.
  Specified by:
    shutdown in interface ResourceStore

### save

    public void save()

  Save this store.
  Specified by:
    save in interface ResourceStore

### enumerateResourceIdentifiers

    public java.util.Enumeration enumerateResourceIdentifiers()

  Enumerate all the resources saved in this store.
  Specified by:
    enumerateResourceIdentifiers in interface ResourceStore
  Returns:
    An enumeration of Strings, giving the identifier for all the resources that this store knows about.

### hasResource

    public boolean hasResource(java.lang.String identifier)

  Check for the existence of a resource in this store.
  Specified by:
    hasResource in interface ResourceStore
  Parameters:
    `identifier` - The identifier of the resource to check.
  Returns:
    A boolean true if the resource exists in this store, false otherwise.

### loadResources

    protected void loadResources()

### initialize

    public void initialize(ResourceStoreManager manager,
                           java.lang.Object token,
                           java.io.File repository,
                           Serializer serializer)

  This resource store is being built, initialize it with the given arg.
  Specified by:
    initialize in interface ResourceStore
  Parameters:
    `manager` - The ResourceStoreManager instance that asks yourself to initialize.
    `token` - The resource store manager key to that resource store, this token should be used when calling methods from the manager that are to act on yourself.
    `repository` - A file, giving the location of the associated repository.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD