org.apache.james.mailrepository.filepair
Class AbstractFileRepository

java.lang.Object
  |
  +--org.apache.avalon.framework.logger.AbstractLogEnabled
        |
        +--org.apache.james.mailrepository.filepair.AbstractFileRepository
All Implemented Interfaces:
Component, Configurable, Contextualizable, Initializable, LogEnabled, Repository, Serviceable
Direct Known Subclasses:
File_Persistent_Object_Repository, File_Persistent_Stream_Repository

public abstract class AbstractFileRepository
extends AbstractLogEnabled
implements Repository, Contextualizable, Serviceable, Configurable, Initializable

This an abstract class implementing functionality for creating a file-store.

Author:
Stefano Mazzocchi, Federico Barbieri

Field Summary
protected static int BYTE_MASK
           
protected static boolean DEBUG
           
protected static String HANDLED_URL
           
protected static char[] HEX_DIGITS
           
protected  File m_baseDirectory
           
protected  BlockContext m_context
           
protected  String m_destination
           
protected  String m_extension
           
protected  FilenameFilter m_filter
           
protected  String m_name
           
protected  String m_path
           
protected  ServiceManager m_serviceManager
           
 
Constructor Summary
AbstractFileRepository()
           
 
Method Summary
 void configure(Configuration configuration)
           
 boolean containsKey(String key)
          Indicates if the given key is associated to a contained object.
 void contextualize(Context context)
           
protected  AbstractFileRepository createChildRepository()
           
protected  String decode(String filename)
          Inverse of encode exept it do not use path.
protected  String encode(String key)
          Returns a String that uniquely identifies the object.
 Repository getChildRepository(String childName)
           
protected abstract  String getExtensionDecorator()
           
protected  File getFile(String key)
           
protected  InputStream getInputStream(String key)
           
protected  OutputStream getOutputStream(String key)
           
 void initialize()
           
 Iterator list()
          Returns the list of used keys.
 void remove(String key)
          Remove the object associated to the given key.
 void service(ServiceManager serviceManager)
           
protected  void setDestination(String destination)
           
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

protected static final boolean DEBUG
See Also:
Constant Field Values

HANDLED_URL

protected static final String HANDLED_URL
See Also:
Constant Field Values

BYTE_MASK

protected static final int BYTE_MASK
See Also:
Constant Field Values

HEX_DIGITS

protected static final char[] HEX_DIGITS

m_path

protected String m_path

m_destination

protected String m_destination

m_extension

protected String m_extension

m_name

protected String m_name

m_filter

protected FilenameFilter m_filter

m_baseDirectory

protected File m_baseDirectory

m_serviceManager

protected ServiceManager m_serviceManager

m_context

protected BlockContext m_context
Constructor Detail

AbstractFileRepository

public AbstractFileRepository()
Method Detail

getExtensionDecorator

protected abstract String getExtensionDecorator()

contextualize

public void contextualize(Context context)
Specified by:
contextualize in interface Contextualizable

service

public void service(ServiceManager serviceManager)
             throws ServiceException
Specified by:
service in interface Serviceable
ServiceException

configure

public void configure(Configuration configuration)
               throws ConfigurationException
Specified by:
configure in interface Configurable
ConfigurationException

initialize

public void initialize()
                throws Exception
Specified by:
initialize in interface Initializable
Exception

setDestination

protected void setDestination(String destination)
                       throws ConfigurationException
ConfigurationException

createChildRepository

protected AbstractFileRepository createChildRepository()
                                                throws Exception
Exception

getChildRepository

public Repository getChildRepository(String childName)
Specified by:
getChildRepository in interface Repository

getFile

protected File getFile(String key)
                throws IOException
IOException

getInputStream

protected InputStream getInputStream(String key)
                              throws IOException
IOException

getOutputStream

protected OutputStream getOutputStream(String key)
                                throws IOException
IOException

remove

public void remove(String key)
Remove the object associated to the given key.


containsKey

public boolean containsKey(String key)
Indicates if the given key is associated to a contained object.


list

public Iterator list()
Returns the list of used keys.


encode

protected String encode(String key)
Returns a String that uniquely identifies the object. Note: since this method uses the Object.toString() method, it's up to the caller to make sure that this method doesn't change between different JVM executions (like it may normally happen). For this reason, it's highly recommended (even if not mandated) that Strings be used as keys.


decode

protected String decode(String filename)
Inverse of encode exept it do not use path. So decode(encode(s) - m_path) = s. In other words it returns a String that can be used as key to retive the record contained in the 'filename' file.



"Copyright © 1999-2002 Apache Jakarta Project. All Rights Reserved."