de.smartics.maven.issues.cache
Class AbstractFileTaskDataStore

Package class diagram package AbstractFileTaskDataStore
java.lang.Object
  extended by de.smartics.maven.issues.cache.AbstractFileTaskDataStore
All Implemented Interfaces:
TaskDataStore
Direct Known Subclasses:
XmlTaskDataStore

public abstract class AbstractFileTaskDataStore
     
     
extends Object
implements TaskDataStore

Base implementation of the TaskDataStore interface that writes the task data to individual files.

Author:
Robert Reiner

Field Summary
protected  String fileNameExtension
          The extension to append to the created files.
protected  File persistentStoreDirectory
          The reference to the directory to store the individual task files.
 
Constructor Summary
protected AbstractFileTaskDataStore(File persistentStoreDirectory, String fileNameExtension)
          Default constructor.
 
Method Summary
protected static void close(Closeable closeable)
          Closes the given closeable and logs problems at error level to the log.
protected static void close(File file, Closeable closeable)
          Closes the given closeable and logs problems at error level to the log.
protected  File createFile(String id)
          Creates a file for the given identifier.
 org.eclipse.mylyn.tasks.core.data.TaskData load(String id)
          Retrieves the task information.
 void persist(org.eclipse.mylyn.tasks.core.data.TaskData task)
          Persists the task information.
protected  org.eclipse.mylyn.tasks.core.data.TaskData readTask(File file)
          Reads the task from the given file.
protected abstract  org.eclipse.mylyn.tasks.core.data.TaskData readTask(InputStream inputStream)
          Reads the task from the given input stream.
protected  void writeTask(File file, org.eclipse.mylyn.tasks.core.data.TaskData task)
          Persists the task to the given file.
protected abstract  void writeTask(OutputStream outputStream, org.eclipse.mylyn.tasks.core.data.TaskData task)
          Persists the task to the given output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

persistentStoreDirectory

protected final File persistentStoreDirectory
The reference to the directory to store the individual task files.


fileNameExtension

protected final String fileNameExtension
The extension to append to the created files. This extension usually includes the dot, may be empty, but must not be null.

Constructor Detail

AbstractFileTaskDataStore

protected AbstractFileTaskDataStore(File persistentStoreDirectory,
                                    String fileNameExtension)
Default constructor.

Parameters:
persistentStoreDirectory - the reference to the directory to store the individual task files.
fileNameExtension - the extension to append to the created files.
Method Detail

load

public org.eclipse.mylyn.tasks.core.data.TaskData load(String id)
                                                throws PersistenceException
Retrieves the task information.

Specified by:
load in interface TaskDataStore
Parameters:
id - the unique identifier of the task information.
Returns:
the requested task information with the given identifier or null if no task data is stored for the given identifier.
Throws:
PersistenceException - if the task information cannot be retrieved.

createFile

protected File createFile(String id)
Creates a file for the given identifier.

Parameters:
id - the identifier of the file to be created.
Returns:
a file with a name that is unique for the given unique identifier.

readTask

protected org.eclipse.mylyn.tasks.core.data.TaskData readTask(File file)
                                                       throws PersistenceException
Reads the task from the given file.

Parameters:
file - the file to read from.
Returns:
the task information read from the given file.
Throws:
PersistenceException - if the task data cannot be read from the given file.

readTask

protected abstract org.eclipse.mylyn.tasks.core.data.TaskData readTask(InputStream inputStream)
                                                                throws PersistenceException
Reads the task from the given input stream.

Parameters:
inputStream - the input stream to read from.
Returns:
the task information read from the given input stream.
Throws:
PersistenceException - if the task data cannot be read from the given input stream.

persist

public void persist(org.eclipse.mylyn.tasks.core.data.TaskData task)
             throws PersistenceException
Persists the task information.

Specified by:
persist in interface TaskDataStore
Parameters:
task - the task information to persist.
Throws:
PersistenceException - if the task cannot be persisted.

writeTask

protected void writeTask(File file,
                         org.eclipse.mylyn.tasks.core.data.TaskData task)
                  throws PersistenceException
Persists the task to the given file. If the file already exists, it will be overwritten.

Parameters:
file - the file to write to.
task - the task data to store.
Throws:
PersistenceException - if the task data cannot be written to the given file.

close

protected static void close(Closeable closeable)
Closes the given closeable and logs problems at error level to the log.

Parameters:
closeable - the closeable to close.

close

protected static void close(File file,
                            Closeable closeable)
Closes the given closeable and logs problems at error level to the log.

Parameters:
file - the name of the file for logging.
closeable - the closeable to close.

writeTask

protected abstract void writeTask(OutputStream outputStream,
                                  org.eclipse.mylyn.tasks.core.data.TaskData task)
                           throws PersistenceException
Persists the task to the given output stream.

Parameters:
outputStream - the output stream to write to.
task - the task data to store.
Throws:
PersistenceException - if the task data cannot be written to the given output stream.


Copyright © 2008-2010 Kronseder & Reiner GmbH - smartics. All Rights Reserved.