com.isti.util
Class ArchiveManager

java.lang.Object
  extended by com.isti.util.ArchiveManager
Direct Known Subclasses:
ExtendedArchiveManager

public class ArchiveManager
extends java.lang.Object

Class ArchiveManager defines an archive manager that organizes items by date. As a stand-alone class it implements a very simple archival system (a single file); but it can be extended for more complex archival needs. 7/10/2003 -- [HS,ET] Initial version. 8/20/2003 -- [ET] Fixed 'processArchivedItems()' method to respond to terminate-processing flag from call-back method. 8/22/2003 -- [ET] Fixed bug where 'get/processArchivedItems()' would always start with second item of first file; added 'getOldestArchiveFile()', 'getOldestItemInArchiveFile()' and 'getOldestItemInEntireArchive()' and 'getArchiveAccessSyncObj()' methods. 9/4/2003 -- [ET] Modified to support 'maxCount' limits. 9/8/2003 -- [ET] Bug fix to 'maxCount' limit in 'processArchivedItems()'. 9/9/2003 -- [KF] Added 'getArchivedItemsVector' methods. 9/15/2003 -- [KF] Modified to close the archive output stream(s) before deleting files. 9/16/2003 -- [ET] Removed 'archiveOutStmSyncObj', instead using 'archiveAccessSyncObj'; setup to have only public methods contain 'synchronized' blocks. 9/22/2003 -- [KF] Add constructors throwing NullPointerException if 'archiveFileNameStr' is null, Add 'getLogPrefixString', 'setLogPrefixString', 'getLogFile', and 'setLogFile' methods, Add a return value to the 'archiveItem' method to state if the item was added or not. 9/24/2003 -- [ET] Added 'checkArchiveItemOrder()' method (commented out). 9/25/2003 -- [KF] Added logging messages of errors and warnings. 9/30/2003 -- [KF] Added 'setLeaveOutputStreamsOpenFlag' and 'getLeaveOutputStreamsOpenFlag' methods, and added debug logging of stack trace for exceptions. 11/6/2003 -- [KF] Added logging to various 'set' methods. 11/17/2003 -- [ET] Changed logging level on various 'set' methods to 'debug2'. 3/31/2004 -- [ET] Fixed issue of rejecting added-items with archive dates in the future by implementing a tolerance value that can be modified by the new methods 'get/setTimeCheckOffsetMs()'; renamed method 'saveItemArchiveDate()' to 'checkItemArchiveDate()'; added explicit initializations to 'null' to several member variables. 8/6/2004 -- [KF] Made global logging use console output if not set. 12/21/2005 -- [ET] Fixed methods 'getNewestItemInArchiveFile()' and 'getOldestItemInArchiveFile()' by making them close input file when complete. 9/24/2007 -- [ET] Added 'get/setDontPurgeLastFileFlag()' methods and implementation. 7/9/2008 -- [ET] Fixed 'getNewestItemInArchiveFile()' method so it works when only one item is present in archive file. 6/29/2010 -- [ET] Slight change to error message in method 'convertStringToArchivable()'.


Nested Class Summary
static interface ArchiveManager.ProcessCallBack
          Interface ProcessCallBack defines the call-back object passed into the 'processArchivedItems()' method.
 
Field Summary
protected  java.lang.Object archiveAccessSyncObj
          Thread synchronization object for archive access.
protected  boolean archiveClosedFlag
          Flag set true after 'closeArchive()' called.
protected  java.lang.reflect.Constructor archivedClassConstructor
          Constructor for 'Archivable' class used with this manager.
protected  java.lang.String archivedFormPrefixStr
          Prefix that all archived-form items should begin with (or null).
protected  java.lang.String archivedItemDelimiter
          A string that we delimit archived items by.
protected  java.lang.String archiveFileNameStr
          Name to use for archive file(s).
protected  java.io.OutputStream archiveOutStm
          The OutputStream object we're archiving to.
protected  java.lang.String archiveRootDirName
          Root directory of our archive.
protected  boolean assumeNewlineFlag
          Flag set true if the 'archivedItemDelimiter' string is a newline.
protected  boolean dontPurgeLastFileFlag
          true to not purge last file if none after it.
protected  java.util.Vector filesForDateRangeVec
          Vector used if 'getArchiveFilesForDateRange()' not overridden.
protected  java.util.Date lastItemArchiveDate
          The date of the last item archived.
protected  boolean leaveOutputStreamsOpenFlag
          true to leave the output streams open until the archive is closed.
protected  boolean purgeIntoArchiveFlag
          true to purge items inside archives, false to only deal with files.
protected  int timeCheckOffsetMs
          Time offset used when checking item-date vs.
 
Constructor Summary
ArchiveManager(java.lang.Class classObj, java.lang.String archiveFileNameStr)
          Creates a new instance of ArchiveManager to archive instances of the given class.
ArchiveManager(java.lang.Class classObj, java.lang.String archiveRootDirName, java.lang.String archiveFileNameStr)
          Creates a new instance of ArchiveManager to archive instances of the given class.
 
Method Summary
 boolean archiveItem(Archivable item)
          Inserts an item into the archive.
protected  boolean archiveItem(Archivable item, boolean checkDateFlag)
          Inserts an item into the archive.
protected  boolean checkItemArchiveDate(Archivable item)
          Validates an item to be added the archive.
protected  void close(java.io.InputStream inStmObj)
          Closes the specified input stream.
protected  void close(java.io.OutputStream outStmObj)
          Closes the specified output stream.
 void closeArchive()
          Releases resources allocated for this archive manager.
protected  void closeArchiveOutStms()
          Close the archive output streams.
protected  Archivable convertStringToArchivable(java.lang.String str)
          Converts the given string to an 'Archivable' object.
protected  boolean deleteFile(java.io.File fileObj)
          Deletes the file.
protected  boolean doesNextArchiveFileExist(java.lang.String fNameStr)
          Determines if the next file in the archive sequence exists.
protected  void flush(java.io.OutputStream outStmObj)
          Flushes the specified output stream.
 java.lang.Object getArchiveAccessSyncObj()
          Returns the Object used to thread-synchronize the archive.
 java.lang.String getArchivedFormPrefixStr()
          Returns the prefix string that all items in their archived form should begin with.
 java.lang.String getArchivedItemDelimiter()
          Returns the delimiter string to be used in the archive file, to seperate items.
 java.util.Enumeration getArchivedItems(java.util.Date startDate, java.util.Date endDate)
          Returns all of the archived items between two date/time values (inclusive).
 java.util.Enumeration getArchivedItems(java.util.Date startDate, java.util.Date endDate, int maxCount)
          Returns all of the archived items between two date/time values (inclusive).
 java.util.Vector getArchivedItemsVector(java.util.Date startDate, java.util.Date endDate)
          Returns all of the archived items between two date/time values (inclusive).
 java.util.Vector getArchivedItemsVector(java.util.Date startDate, java.util.Date endDate, int maxCount)
          Returns all of the archived items between two date/time values (inclusive).
protected  java.io.File getArchiveFileForName(java.lang.String fNameStr)
          Returns the file object for the given file name.
protected  java.lang.String getArchiveFileNameForDate(java.util.Date dateObj)
          Returns the name of the archive file that would contain items with the given date.
protected  java.util.Vector getArchiveFilesForDateRange(java.util.Date startDate, java.util.Date endDate)
          Given 2 dates (inclusive), returns an enumeration of File objects that can be used to later create a stream.
 boolean getDontPurgeLastFileFlag()
          Returns the "purge last archive file" flag.
 boolean getLeaveOutputStreamsOpenFlag()
          Gets whether or not the output streams are left open until the archive is closed.
 LogFile getLogFile()
          Gets the log file.
 java.lang.String getLogPrefixString()
          Returns the prefix to use for log output.
 java.io.File getNewestArchiveFile()
          Returns the newest archive file available.
 Archivable getNewestItemInArchiveFile(java.io.File fileObj)
          Returns the last 'Archivable' item in the given archive file.
 Archivable getNewestItemInEntireArchive()
          Returns the last 'Archivable' item available in the entire archive.
protected  java.lang.String getNextItemDataFromFile(java.io.InputStream stmObj)
          Returns the data for next item from the archive file.
protected  java.lang.String getNextLineFromFile(java.io.BufferedReader rdrObj)
          Returns the next line of data from the given stream.
 java.io.File getOldestArchiveFile()
          Returns the oldest archive file available.
 Archivable getOldestItemInArchiveFile(java.io.File fileObj)
          Returns the first 'Archivable' item in the given archive file.
 Archivable getOldestItemInEntireArchive()
          Returns the first 'Archivable' item available in the entire archive.
protected  java.io.OutputStream getOutputStreamForItem(Archivable item)
          Returns an output stream for the file that the item should be archived to.
 boolean getPurgeIntoArchiveFlag()
          Returns the "purge items inside archives" flag.
 int getTimeCheckOffsetMs()
          Returns the time offset used when checking the archive-date of added items against the current system time.
 boolean isArchiveClosed()
          Returns the "closed" status of this archive manager.
 void processArchivedItems(java.util.Date startDate, java.util.Date endDate, ArchiveManager.ProcessCallBack callBackObj)
          Processes all of the archived items between two date/time values (inclusive).
 void processArchivedItems(java.util.Date startDate, java.util.Date endDate, ArchiveManager.ProcessCallBack callBackObj, int maxCount)
          Processes all of the archived items between two date/time values (inclusive).
 boolean purgeArchive(java.util.Date cutoffDate)
          Purges items and archive files with an archive date older than the given cutoff date.
protected  boolean renameTo(java.io.File fileObj, java.io.File dest)
          Renames the source file to the destination file.
 void setArchivedFormPrefixStr(java.lang.String str)
          Sets a prefix string that all items in their archived form should begin with.
 void setArchivedItemDelimiter(java.lang.String str)
          Sets the delimiter string to be used in the archive file, to seperate items.
 void setDontPurgeLastFileFlag(boolean flgVal)
          Configures whether or not the 'purgeArchive()' method will remove the newest archive file whose date is before the purge-cutoff date when the next file in the archive sequence does not exist.
 void setLeaveOutputStreamsOpenFlag(boolean flgVal)
          Configures whether or not the output streams are left open until the archive is closed.
 void setLogFile(LogFile logFileObj)
          Sets the log file.
 void setLogPrefixString(java.lang.String logPrefixString)
          Sets the prefix to use for log output.
 void setPurgeIntoArchiveFlag(boolean flgVal)
          Configures whether or not the 'purgeArchive()' method removes items from inside archive files.
 void setTimeCheckOffsetMs(int offsetMsVal)
          Sets the time offset used when checking the archive-date of added items against the current system time.
protected  void writeItemToFile(Archivable item, java.io.OutputStream outStm)
          Does the actual writing of the item to the file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

archivedClassConstructor

protected final java.lang.reflect.Constructor archivedClassConstructor
Constructor for 'Archivable' class used with this manager.


archiveRootDirName

protected final java.lang.String archiveRootDirName
Root directory of our archive.


archiveFileNameStr

protected final java.lang.String archiveFileNameStr
Name to use for archive file(s).


archiveOutStm

protected java.io.OutputStream archiveOutStm
The OutputStream object we're archiving to.


archiveClosedFlag

protected boolean archiveClosedFlag
Flag set true after 'closeArchive()' called.


archivedItemDelimiter

protected java.lang.String archivedItemDelimiter
A string that we delimit archived items by.


assumeNewlineFlag

protected boolean assumeNewlineFlag
Flag set true if the 'archivedItemDelimiter' string is a newline.


purgeIntoArchiveFlag

protected boolean purgeIntoArchiveFlag
true to purge items inside archives, false to only deal with files.


dontPurgeLastFileFlag

protected boolean dontPurgeLastFileFlag
true to not purge last file if none after it.


leaveOutputStreamsOpenFlag

protected boolean leaveOutputStreamsOpenFlag
true to leave the output streams open until the archive is closed.


archivedFormPrefixStr

protected java.lang.String archivedFormPrefixStr
Prefix that all archived-form items should begin with (or null).


archiveAccessSyncObj

protected final java.lang.Object archiveAccessSyncObj
Thread synchronization object for archive access.


filesForDateRangeVec

protected java.util.Vector filesForDateRangeVec
Vector used if 'getArchiveFilesForDateRange()' not overridden.


timeCheckOffsetMs

protected int timeCheckOffsetMs
Time offset used when checking item-date vs. current time.


lastItemArchiveDate

protected java.util.Date lastItemArchiveDate
The date of the last item archived.

Constructor Detail

ArchiveManager

public ArchiveManager(java.lang.Class classObj,
                      java.lang.String archiveRootDirName,
                      java.lang.String archiveFileNameStr)
               throws java.lang.NoSuchMethodException
Creates a new instance of ArchiveManager to archive instances of the given class. The given class must have a constructor with 'String' and 'Archivable.Marker' parameters, like this:
public ArchivableImpl(String dataStr, Archivable.Marker mkrObj) ...
This constructor is used to create the class from a string of data. The 'Archivable.Marker' is used to mark the constructor as being available for de-archiving (and will usually be 'null').

Parameters:
classObj - class object representing the class to be archived.
archiveRootDirName - name of root directory in which to place archive files (and possibly directories), or null to use the current working directory.
archiveFileNameStr - name to use for the archive file(s).
Throws:
java.lang.NoSuchMethodException - if a proper constructor does not exist for the class.
java.lang.NullPointerException - If archiveFileNameStr is null

ArchiveManager

public ArchiveManager(java.lang.Class classObj,
                      java.lang.String archiveFileNameStr)
               throws java.lang.NoSuchMethodException
Creates a new instance of ArchiveManager to archive instances of the given class. The given class must have a constructor with 'String' and 'Archivable.Marker' parameters, like this:
public ArchivableImpl(String dataStr, Archivable.Marker mkrObj) ...
This constructor is used to create the class from a string of data. The 'Archivable.Marker' is used to mark the constructor as being available for de-archiving (and will usually be 'null'). The archive files will be placed in the current working directory.

Parameters:
classObj - class object representing the class to be archived.
archiveFileNameStr - name to use for the archive file(s).
Throws:
java.lang.NoSuchMethodException - if a proper constructor does not exist for the class.
java.lang.NullPointerException - If archiveFileNameStr is null
Method Detail

setPurgeIntoArchiveFlag

public void setPurgeIntoArchiveFlag(boolean flgVal)
Configures whether or not the 'purgeArchive()' method removes items from inside archive files. If so then the oldest archive file containing items on or after the purge-cutoff date will be rewritten with items before the purge-cutoff date removed. (This is the default behavior.) If not then the archive will be left unchanged (while the older archive files will be deleted as usual).

Parameters:
flgVal - true to configure purging of items inside archive files.

getPurgeIntoArchiveFlag

public boolean getPurgeIntoArchiveFlag()
Returns the "purge items inside archives" flag.

Returns:
true if items inside archives are purged, false if not.

setDontPurgeLastFileFlag

public void setDontPurgeLastFileFlag(boolean flgVal)
Configures whether or not the 'purgeArchive()' method will remove the newest archive file whose date is before the purge-cutoff date when the next file in the archive sequence does not exist. This allows the archive to retain the value of an item that has not changed its value in a relatively-long time.

Parameters:
flgVal - true to configure the archive to not remove the "last" file due to be purged (when not followed by another file); false to purge the file (default).

getDontPurgeLastFileFlag

public boolean getDontPurgeLastFileFlag()
Returns the "purge last archive file" flag.

Returns:
true if the archive is configured to not remove the "last" file due to be purged (when not followed by another file); false if configured to purge the file.

setLeaveOutputStreamsOpenFlag

public void setLeaveOutputStreamsOpenFlag(boolean flgVal)
Configures whether or not the output streams are left open until the archive is closed.

Parameters:
flgVal - true to leave the output streams open until the archive is closed.

getLeaveOutputStreamsOpenFlag

public boolean getLeaveOutputStreamsOpenFlag()
Gets whether or not the output streams are left open until the archive is closed.

Returns:
true if leaving the output streams open until the archive is closed.

setArchivedItemDelimiter

public void setArchivedItemDelimiter(java.lang.String str)
Sets the delimiter string to be used in the archive file, to seperate items. This should be set to a string that will not otherwise be seen in the archived form of any items.

Parameters:
str - the delimiter string to use, or null for the default ("\n").

getArchivedItemDelimiter

public java.lang.String getArchivedItemDelimiter()
Returns the delimiter string to be used in the archive file, to seperate items.

Returns:
The delimiter string in use.

setArchivedFormPrefixStr

public void setArchivedFormPrefixStr(java.lang.String str)
Sets a prefix string that all items in their archived form should begin with. This allows leading extraneous data in the archived-form string data of items to be ignored. The default is null (no prefix string).

Parameters:
str - the prefix string to use, or null for none.

getArchivedFormPrefixStr

public java.lang.String getArchivedFormPrefixStr()
Returns the prefix string that all items in their archived form should begin with.

Returns:
The prefix string in use, or null if none.

getLogFile

public LogFile getLogFile()
Gets the log file.

Returns:
the log file.
See Also:
setLogFile, getLogPrefixString

setLogFile

public void setLogFile(LogFile logFileObj)
Sets the log file.

Parameters:
logFileObj - the log file object.
See Also:
getLogFile, setLogPrefixString

getLogPrefixString

public java.lang.String getLogPrefixString()
Returns the prefix to use for log output.

See Also:
setLogPrefixString, getLogFile

setLogPrefixString

public final void setLogPrefixString(java.lang.String logPrefixString)
Sets the prefix to use for log output.

Parameters:
logPrefixString - the prefix to use for log output.
See Also:
getLogPrefixString, setLogFile

setTimeCheckOffsetMs

public void setTimeCheckOffsetMs(int offsetMsVal)
Sets the time offset used when checking the archive-date of added items against the current system time. This sets up a tolerance value, in that the archive-date of added items can be at most the specified number of milliseconds in the future.

Parameters:
offsetMsVal - the time offset value, in milliseconds.

getTimeCheckOffsetMs

public int getTimeCheckOffsetMs()
Returns the time offset used when checking the archive-date of added items against the current system time. This sets up a tolerance value, in that the archive-date of added items can be at most the specified number of milliseconds in the future.

Returns:
Returns the time offset used when checking the archive-date of added items against the current system time.

archiveItem

public boolean archiveItem(Archivable item)
                    throws java.io.IOException
Inserts an item into the archive.

Parameters:
item - the item to be archived.
Returns:
true if the item was added, false otherwise.
Throws:
java.io.IOException - if the archive file can not be written to.

archiveItem

protected boolean archiveItem(Archivable item,
                              boolean checkDateFlag)
                       throws java.io.IOException
Inserts an item into the archive.

Parameters:
item - the item to be archived.
checkDateFlag - true to check the date.
Returns:
true if the item was added, false otherwise.
Throws:
java.io.IOException - if the archive file can not be written to.

checkItemArchiveDate

protected boolean checkItemArchiveDate(Archivable item)
Validates an item to be added the archive.

Parameters:
item - the item to be archived.
Returns:
true if the item date is valid, false otherwise.

writeItemToFile

protected void writeItemToFile(Archivable item,
                               java.io.OutputStream outStm)
                        throws java.io.IOException
Does the actual writing of the item to the file.

Parameters:
item - the item to write.
outStm - the 'OutputStream' for the archive file to write to.
Throws:
java.io.IOException - if an error occurs.

processArchivedItems

public void processArchivedItems(java.util.Date startDate,
                                 java.util.Date endDate,
                                 ArchiveManager.ProcessCallBack callBackObj,
                                 int maxCount)
Processes all of the archived items between two date/time values (inclusive).

Parameters:
startDate - the start of the time range, or null to indicate the "beginning of time".
endDate - the end of the time range, or null to indicate the "end of time".
maxCount - the maximum number of objects to be returned, or 0 for no limit.
callBackObj - the call-back object to use to process each item.

processArchivedItems

public void processArchivedItems(java.util.Date startDate,
                                 java.util.Date endDate,
                                 ArchiveManager.ProcessCallBack callBackObj)
Processes all of the archived items between two date/time values (inclusive).

Parameters:
startDate - the start of the time range, or null to indicate the "beginning of time".
endDate - the end of the time range, or null to indicate the "end of time".
callBackObj - the call-back object to use to process each item.

getArchivedItemsVector

public java.util.Vector getArchivedItemsVector(java.util.Date startDate,
                                               java.util.Date endDate,
                                               int maxCount)
Returns all of the archived items between two date/time values (inclusive).

Parameters:
startDate - the start of the time range, or null to indicate the "beginning of time".
endDate - the end of the time range, or null to indicate the "end of time".
maxCount - the maximum number of objects to be returned, or 0 for no limit.
Returns:
A vector of 'Archivable' objects with dates occuring between the two times (inclusive).

getArchivedItemsVector

public java.util.Vector getArchivedItemsVector(java.util.Date startDate,
                                               java.util.Date endDate)
Returns all of the archived items between two date/time values (inclusive).

Parameters:
startDate - the start of the time range, or null to indicate the "beginning of time".
endDate - the end of the time range, or null to indicate the "end of time".
Returns:
A vector of 'Archivable' objects with dates occuring between the two times (inclusive).

getArchivedItems

public java.util.Enumeration getArchivedItems(java.util.Date startDate,
                                              java.util.Date endDate,
                                              int maxCount)
Returns all of the archived items between two date/time values (inclusive).

Parameters:
startDate - the start of the time range, or null to indicate the "beginning of time".
endDate - the end of the time range, or null to indicate the "end of time".
maxCount - the maximum number of objects to be returned, or 0 for no limit.
Returns:
An enumeration of 'Archivable' objects with dates occuring between the two times (inclusive).

getArchivedItems

public java.util.Enumeration getArchivedItems(java.util.Date startDate,
                                              java.util.Date endDate)
Returns all of the archived items between two date/time values (inclusive).

Parameters:
startDate - the start of the time range, or null to indicate the "beginning of time".
endDate - the end of the time range, or null to indicate the "end of time".
Returns:
An enumeration of 'Archivable' objects with dates occuring between the two times (inclusive).

getNextItemDataFromFile

protected java.lang.String getNextItemDataFromFile(java.io.InputStream stmObj)
Returns the data for next item from the archive file.

Parameters:
stmObj - the input stream to read archive-file data from.
Returns:
The string data for the next item, or null if no more exist.

getNextLineFromFile

protected java.lang.String getNextLineFromFile(java.io.BufferedReader rdrObj)
Returns the next line of data from the given stream.

Parameters:
rdrObj - the input stream to read data from.
Returns:
The string data for the next line, or null if no more are available or an error occurred.

convertStringToArchivable

protected Archivable convertStringToArchivable(java.lang.String str)
Converts the given string to an 'Archivable' object.

Parameters:
str - the string to convert.
Returns:
An 'Archivable' object, or null if the string could not be converted.

purgeArchive

public boolean purgeArchive(java.util.Date cutoffDate)
Purges items and archive files with an archive date older than the given cutoff date. The 'purgeIntoArchiveFlag' configures whether or not items from inside archive files are removed. If 'true' then the oldest archive file containing items on or after the purge-cutoff date will be rewritten with items before the purge-cutoff date removed. If 'false' then the archive will be left unchanged (while the older archive files will be deleted as usual).

Parameters:
cutoffDate - the date of the oldest event to keep in the archive.
Returns:
true if successful, false if an error occurred.

deleteFile

protected boolean deleteFile(java.io.File fileObj)
Deletes the file.

Parameters:
fileObj - the file object.
Returns:
true if and only if the file is successfully deleted; false otherwise

renameTo

protected boolean renameTo(java.io.File fileObj,
                           java.io.File dest)
Renames the source file to the destination file.

Parameters:
fileObj - the file object.
dest - the new file name.
Returns:
true if and only if the renaming succeeded; false otherwise

flush

protected void flush(java.io.OutputStream outStmObj)
Flushes the specified output stream.

Parameters:
outStmObj - the output stream to flush.

close

protected void close(java.io.InputStream inStmObj)
Closes the specified input stream.

Parameters:
inStmObj - the input stream to close.

close

protected void close(java.io.OutputStream outStmObj)
Closes the specified output stream.

Parameters:
outStmObj - the output stream to close.

closeArchiveOutStms

protected void closeArchiveOutStms()
Close the archive output streams.


closeArchive

public void closeArchive()
Releases resources allocated for this archive manager.


isArchiveClosed

public boolean isArchiveClosed()
Returns the "closed" status of this archive manager.

Returns:
true if closed, false if not.

getNewestArchiveFile

public java.io.File getNewestArchiveFile()
Returns the newest archive file available.

Returns:
A 'File' object for the newest archive file available, or 'null' if none available.

getOldestArchiveFile

public java.io.File getOldestArchiveFile()
Returns the oldest archive file available.

Returns:
A 'File' object for the oldest archive file available, or 'null' if none available.

getNewestItemInArchiveFile

public Archivable getNewestItemInArchiveFile(java.io.File fileObj)
Returns the last 'Archivable' item in the given archive file.

Parameters:
fileObj - the file to use.
Returns:
An 'Archivable' object, or null if none could be found.

getNewestItemInEntireArchive

public Archivable getNewestItemInEntireArchive()
Returns the last 'Archivable' item available in the entire archive.

Returns:
An 'Archivable' object, or null if none could be found.

getOldestItemInArchiveFile

public Archivable getOldestItemInArchiveFile(java.io.File fileObj)
Returns the first 'Archivable' item in the given archive file.

Parameters:
fileObj - the file to use.
Returns:
An 'Archivable' object, or null if none could be found.

getOldestItemInEntireArchive

public Archivable getOldestItemInEntireArchive()
Returns the first 'Archivable' item available in the entire archive.

Returns:
An 'Archivable' object, or null if none could be found.

getArchiveAccessSyncObj

public java.lang.Object getArchiveAccessSyncObj()
Returns the Object used to thread-synchronize the archive.

Returns:
The Object used to thread-synchronize the archive.

getArchiveFilesForDateRange

protected java.util.Vector getArchiveFilesForDateRange(java.util.Date startDate,
                                                       java.util.Date endDate)
Given 2 dates (inclusive), returns an enumeration of File objects that can be used to later create a stream. This should be overridden to support more complex archive filesystems. These files should be in order from oldest to newest.

Parameters:
startDate - the start of the time range, or null to indicate the "beginning of time".
endDate - the end of the time range, or null to indicate the "end of time".
Returns:
A Vector of 'File' objects. The order of the 'File' objects as they are read from the Enumeration should be chronological.

getArchiveFileNameForDate

protected java.lang.String getArchiveFileNameForDate(java.util.Date dateObj)
Returns the name of the archive file that would contain items with the given date.

Parameters:
dateObj - the date object to use.
Returns:
The file name string.

getArchiveFileForName

protected java.io.File getArchiveFileForName(java.lang.String fNameStr)
Returns the file object for the given file name.

Parameters:
fNameStr - the file name to use.
Returns:
A new 'File' object for the given file name, placed in the proper directory.

getOutputStreamForItem

protected java.io.OutputStream getOutputStreamForItem(Archivable item)
                                               throws java.io.IOException
Returns an output stream for the file that the item should be archived to.

Parameters:
item - the item to be archived.
Returns:
An 'OutputStream' to be used to write to the archive file.
Throws:
java.io.IOException - if the archive file cannot be opened.

doesNextArchiveFileExist

protected boolean doesNextArchiveFileExist(java.lang.String fNameStr)
Determines if the next file in the archive sequence exists. Subclasses should override this method (this version always returns 'true').

Parameters:
fNameStr - name of archive file.
Returns:
true if the next file in the archive sequence exists (or a date code could not be parsed from the given filename); false otherwise.