org.semanticdesktop.aperture.accessor.base
Class FileAccessData

java.lang.Object
  extended by org.semanticdesktop.aperture.accessor.base.AccessDataImpl
      extended by org.semanticdesktop.aperture.accessor.base.FileAccessData
All Implemented Interfaces:
AccessData

public class FileAccessData
extends AccessDataImpl

FileAccessData extends AccessDataImpl with functionality for storing the access data to a file and initializing it with the contents of such a file.


Field Summary
static String AGGREGATED_ID_TAG
           
static String REFERRED_ID_TAG
           
 
Fields inherited from class org.semanticdesktop.aperture.accessor.base.AccessDataImpl
aggregatedIDMap, idMap, referredIDMap
 
Fields inherited from interface org.semanticdesktop.aperture.accessor.AccessData
BYTE_SIZE_KEY, DATE_KEY, REDIRECTS_TO_KEY
 
Constructor Summary
FileAccessData()
          Creates a new FileAccessData instance.
FileAccessData(File dataFile)
          Creates a new FileAccessData that uses the specified File for persistent storage.
FileAccessData(File dataFile, int autoSaveInterval)
          Creates a new FileAccessData that uses the specified File for persistent storage.
FileAccessData(int autoSaveInterval)
          Creates a new FileAccessData instance.
 
Method Summary
 void clear()
          Clears this AccessData.
 String get(String id, String key)
          Gets specific information about the specified id.
 int getAutoSaveInterval()
           
 File getDataFile()
           
 void initialize()
          Prepares the AccessData for operation.
 void put(String id, String key, String value)
          Stores information (a key-value pair) for the specified id.
 void setAutoSaveInterval(int autoSaveInterval)
          Sets the auto save interval.
 void setDataFile(File dataFile)
          Sets the data File to be used by this FileAccessData.
 void store()
          Informs the AccessData that processing has completed and, in case of a persistent storage, now is a good time to write or flush results.
 
Methods inherited from class org.semanticdesktop.aperture.accessor.base.AccessDataImpl
getAggregatedIDs, getAggregatedIDsClosure, getReferredIDs, getSize, getStoredIDs, getUntouchedIDsIterator, isKnownId, isTouched, putAggregatedID, putReferredID, remove, remove, removeAggregatedID, removeReferredID, removeReferredIDs, removeUntouchedIDs, touch, touchRecursively
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REFERRED_ID_TAG

public static final String REFERRED_ID_TAG
See Also:
Constant Field Values

AGGREGATED_ID_TAG

public static final String AGGREGATED_ID_TAG
See Also:
Constant Field Values
Constructor Detail

FileAccessData

public FileAccessData()
Creates a new FileAccessData instance. The access data cannot be made persistent until a data file is specified.


FileAccessData

public FileAccessData(File dataFile)
Creates a new FileAccessData that uses the specified File for persistent storage.

Parameters:
dataFile - The data file to be used by this FileAccessData.

FileAccessData

public FileAccessData(int autoSaveInterval)
Creates a new FileAccessData instance. The access data cannot be made persistent until a data file is specified.

Parameters:
autoSaveInterval - the autoSaveInterval, see setAutoSaveInterval(int) for details

FileAccessData

public FileAccessData(File dataFile,
                      int autoSaveInterval)
Creates a new FileAccessData that uses the specified File for persistent storage.

Parameters:
dataFile - The data file to be used by this FileAccessData.
autoSaveInterval - the autoSaveInterval, see setAutoSaveInterval(int) for details
Method Detail

setDataFile

public void setDataFile(File dataFile)
Sets the data File to be used by this FileAccessData.

Parameters:
dataFile - The data File to use or 'null' when the FileAccessData is not required (anymore) to persistently store its access data.

getDataFile

public File getDataFile()

getAutoSaveInterval

public int getAutoSaveInterval()
Returns:
Returns the autoSaveInterval or 0 if the autosave feature is disabled.

setAutoSaveInterval

public void setAutoSaveInterval(int autoSaveInterval)
Sets the auto save interval. If set to non-zero value, the FileAccessData will increment an internal counter after each operation put(String, String, String) and get(String, String) When this counter reaches the autoSaveInterval value, the store() method will be called and the counter will be reset. Each call to this method resets the counter too.

Parameters:
autoSaveInterval - The new autoSaveInterval value, if set to zero, the autosave feature will be disabled

put

public void put(String id,
                String key,
                String value)
Description copied from interface: AccessData
Stores information (a key-value pair) for the specified id.

Specified by:
put in interface AccessData
Overrides:
put in class AccessDataImpl
Parameters:
id - The resource's ID.
key - The info key.
value - The info value.
See Also:
AccessData.put(String, String, String)

get

public String get(String id,
                  String key)
Description copied from interface: AccessData
Gets specific information about the specified id.

Specified by:
get in interface AccessData
Overrides:
get in class AccessDataImpl
Parameters:
id - The resource's ID.
key - The info key.
Returns:
The stored info value, or null if no info has been stored for the specified id and key.
See Also:
AccessData.get(String, String)

initialize

public void initialize()
                throws IOException
Description copied from interface: AccessData
Prepares the AccessData for operation. This may for example mean reading files or opening repositories that hold the stored data.

Specified by:
initialize in interface AccessData
Overrides:
initialize in class AccessDataImpl
Throws:
IOException
See Also:
AccessData.initialize()

store

public void store()
           throws IOException
Description copied from interface: AccessData
Informs the AccessData that processing has completed and, in case of a persistent storage, now is a good time to write or flush results. Afterwards the AccessData may be in an unusable state until 'initialize' is invoked again.

Specified by:
store in interface AccessData
Overrides:
store in class AccessDataImpl
Throws:
IOException
See Also:
AccessData.store()

clear

public void clear()
           throws IOException
Description copied from interface: AccessData
Clears this AccessData. This may be invoked on initialized and unititialized AccessData's. Both in-memory information as any persistent storage will be cleared. Afterwards the AccessData may be in an unusable state until 'initialize' is invoked again.

Specified by:
clear in interface AccessData
Overrides:
clear in class AccessDataImpl
Throws:
IOException
See Also:
AccessData.clear()


Copyright © 2010 Aperture Development Team. All Rights Reserved.