org.apache.avalon.cornerstone.blocks.masterstore
Class AbstractFileRepository

java.lang.Object
  extended byorg.apache.avalon.cornerstone.blocks.masterstore.AbstractFileRepository
All Implemented Interfaces:
Repository
Direct Known Subclasses:
AbstractFilePersistentObjectRepository, AbstractFilePersistentStreamRepository, AbstractXMLFilePersistentObjectRepository

public abstract class AbstractFileRepository
extends java.lang.Object
implements Repository

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

Author:
Avalon Development Team

Field Summary
protected static int BYTE_MASK
           
protected static boolean DEBUG
           
protected static java.lang.String HANDLED_URL
           
protected static char[] HEX_DIGITS
           
protected  java.io.File m_baseDirectory
           
protected  java.lang.String m_destination
           
protected  java.lang.String m_extension
           
protected  java.io.FilenameFilter m_filter
           
protected  java.lang.String m_name
           
protected  java.lang.String m_path
           
protected  FileRepositoryMonitor monitor
           
 
Constructor Summary
AbstractFileRepository()
           
 
Method Summary
 boolean containsKey(java.lang.String key)
          Indicates if the given key is associated to a contained object.
protected  AbstractFileRepository createChildRepository()
           
protected  java.lang.String decode(java.lang.String filename)
          Inverse of encode exept it do not use path.
protected  java.lang.String encode(java.lang.String key)
          Returns a String that uniquely identifies the object.
 Repository getChildRepository(java.lang.String childName)
           
protected abstract  java.lang.String getExtensionDecorator()
           
protected  java.io.File getFile(java.lang.String key)
           
protected  java.io.InputStream getInputStream(java.lang.String key)
           
protected  java.io.OutputStream getOutputStream(java.lang.String key)
           
protected abstract  void initializeChild(AbstractFileRepository child)
           
 java.util.Iterator list()
          Returns the list of used keys.
 void remove(java.lang.String key)
          Remove the object associated to the given key.
protected  void setDestination(java.lang.String destination)
           
 
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 java.lang.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 java.lang.String m_path

m_destination

protected java.lang.String m_destination

m_extension

protected java.lang.String m_extension

m_name

protected java.lang.String m_name

m_filter

protected java.io.FilenameFilter m_filter

m_baseDirectory

protected java.io.File m_baseDirectory

monitor

protected FileRepositoryMonitor monitor
Constructor Detail

AbstractFileRepository

public AbstractFileRepository()
Method Detail

getExtensionDecorator

protected abstract java.lang.String getExtensionDecorator()

setDestination

protected void setDestination(java.lang.String destination)
                       throws java.io.IOException
Throws:
java.io.IOException

createChildRepository

protected AbstractFileRepository createChildRepository()
                                                throws java.lang.Exception
Throws:
java.lang.Exception

getChildRepository

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

initializeChild

protected abstract void initializeChild(AbstractFileRepository child)
                                 throws java.lang.Exception
Throws:
java.lang.Exception

getFile

protected java.io.File getFile(java.lang.String key)
                        throws java.io.IOException
Throws:
java.io.IOException

getInputStream

protected java.io.InputStream getInputStream(java.lang.String key)
                                      throws java.io.IOException
Throws:
java.io.IOException

getOutputStream

protected java.io.OutputStream getOutputStream(java.lang.String key)
                                        throws java.io.IOException
Throws:
java.io.IOException

remove

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


containsKey

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


list

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


encode

protected java.lang.String encode(java.lang.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 java.lang.String decode(java.lang.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 © 1997-2005 The Apache Software Foundation. All Rights Reserved.