com.wiris.plugin.storage
Class CompressedStorageAndCache

java.lang.Object
  extended by com.wiris.plugin.storage.CompressedStorageAndCache
All Implemented Interfaces:
StorageAndCache

public class CompressedStorageAndCache
extends java.lang.Object
implements StorageAndCache


Constructor Summary
CompressedStorageAndCache()
           
 
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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompressedStorageAndCache

public CompressedStorageAndCache()
Method Detail

codeDigest

public java.lang.String codeDigest(java.lang.String content)
Description copied from interface: StorageAndCache
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.

Specified by:
codeDigest in interface StorageAndCache
Returns:
A computed digest of the content.

decodeDigest

public java.lang.String decodeDigest(java.lang.String digest)
Description copied from interface: StorageAndCache
Given a computed digest, returns the respective content. You might need to store the relation digest content during the StorageAndCache.codeDigest(java.lang.String).

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

init

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

Specified by:
init in interface StorageAndCache
Parameters:
request - The servlet request.
config - WIRIS plugin configuration loaded from configuration.ini.

retreiveData

public byte[] retreiveData(java.lang.String digest)
Description copied from interface: StorageAndCache
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:

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

storeData

public void storeData(java.lang.String digest,
                      byte[] stream)
Description copied from interface: StorageAndCache
Associates a data stream with a computed digest.

Specified by:
storeData in interface StorageAndCache
Parameters:
digest - A computed digest.
stream - The data to be stored.