com.wiris.plugin.storage
Interface StorageAndCache

All Known Implementing Classes:
CompressedStorageAndCache, ContainerStorageAndCache, FileStorageAndCache

public interface StorageAndCache


Method Summary
 java.lang.String codeDigest(java.lang.String content)
          Given a content, computes a digest of it.
 java.lang.String decodeDigest(java.lang.String digest)
          Given a computed digest, returns the respective content.
 void init(HttpServletRequest request, java.util.Properties config)
          Initializes the storage and cache system.
 byte[] retreiveData(java.lang.String digest)
          Given a computed digest, returns the stored data associated with it.
 void storeData(java.lang.String digest, byte[] stream)
          Associates a data stream with a computed digest.
 

Method Detail

init

void init(HttpServletRequest request,
          java.util.Properties config)
Initializes the storage and cache system. This method is called before any call to other methods.

Parameters:
request - The servlet request.
config - WIRIS plugin configuration loaded from configuration.ini.

codeDigest

java.lang.String codeDigest(java.lang.String content)
Given a content, computes a digest of it. This digest must be unique in order to use it as identifier of the content. For example, the digest can be the md5 sum of the content.

Parameters:
content -
Returns:
A computed digest of the content.

decodeDigest

java.lang.String decodeDigest(java.lang.String digest)
Given a computed digest, returns the respective content. You might need to store the relation digest content during the codeDigest(java.lang.String).

Parameters:
digest - A computed digest.
Returns:
The content associated to the computed digest. If it is not found, this method should return null.

retreiveData

byte[] retreiveData(java.lang.String digest)
Given a computed digest, returns the stored data associated with it. This should be a cache system. As a cache there is a contract between the implementation and the caller:

Parameters:
digest - A computed digest.
Returns:
The data associated with the digest. If it is not found, this method should return null.

storeData

void storeData(java.lang.String digest,
               byte[] stream)
Associates a data stream with a computed digest.

Parameters:
digest - A computed digest.
stream - The data to be stored.