tribble.io
Class DiskCacheFile

java.lang.Object
  extended by tribble.io.DiskCacheFile

public class DiskCacheFile
extends java.lang.Object

Disk cached document file.

Notes

The contents of this document file information object are written to the cached directory control file, one line per document file. The format of the information is:

    filename sep created sep access sep expiry sep sep sep sep docID nl
 
Which is composed of the following fields:
sep
A single separator character ('|'), used to delimit the fields in the text line entry.
filename
The name of the filename in the local cache directory. This name must not contain any spaces.
created
The date and time that this document file was created within the cache directory, in the format YYYYMMDDhhmmss.
accessed
The date and time that this document file was last accessed, in the format YYYYMMDDhhmmss.
expiry
The number of days past its last access time that this document file expires, as an unsigned integer.
nl
A single newline, to terminate the text line entry.

Since:
2002-06-04
Version:
$Revision: 1.1 $ $Date: 2002/06/06 04:10:16 $
Author:
David R. Tribble, david@tribble.com
Copyright 2002 by David R. Tribble, all rights reserved.
See Also:
DiskCacheManager

Field Summary
protected  java.util.Date m_accessTime
          Last access date for this document file.
protected  java.util.Date m_createTime
          Creation date for this document file.
protected  java.lang.String m_docId
          Document-ID of this document file.
protected  int m_expiryDays
          Days past the last access date that this document file expires.
protected  java.io.File m_fname
          Local cached filename for this document file.
protected  DiskCacheManager m_mgr
          Local directory cache manager that owns (manages) this document file.
(package private) static java.lang.String REV
          Revision information.
 
Constructor Summary
protected DiskCacheFile(java.lang.String docId, java.io.File fname, DiskCacheManager mgr)
          Constructor.
 
Method Summary
(package private) static DiskCacheFile fromEntryLine(java.lang.String line, java.io.File dir)
          Reconstruct a document file information object from a control file entry line.
(package private) static java.util.Date fromIso8601(java.lang.String s)
          Convert a text string containing a date in ISO-8601 format into a date.
protected  boolean hasExpired(java.util.Date now)
          Determine if this document file has expired or not.
protected  java.lang.String toEntryLine()
          Construct a control file entry line out of this cached document file information object.
(package private) static java.lang.String toIso8601(java.util.Date when)
          Convert a date into an ISO-8601 formatted text string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REV

static final java.lang.String REV
Revision information.

See Also:
Constant Field Values

m_mgr

protected DiskCacheManager m_mgr
Local directory cache manager that owns (manages) this document file.


m_docId

protected java.lang.String m_docId
Document-ID of this document file.


m_fname

protected java.io.File m_fname
Local cached filename for this document file.


m_createTime

protected java.util.Date m_createTime
Creation date for this document file.


m_accessTime

protected java.util.Date m_accessTime
Last access date for this document file.


m_expiryDays

protected int m_expiryDays
Days past the last access date that this document file expires.

Constructor Detail

DiskCacheFile

protected DiskCacheFile(java.lang.String docId,
                        java.io.File fname,
                        DiskCacheManager mgr)
Constructor.

Parameters:
docId - The document-ID to associate with this cached document file.
fname - The name of the file residing in the local cache directory associated with this cached document file.
mgr - The cache directory manager that owns (manages) this cached document file.
Since:
1.1, 2002-06-04
See Also:
DiskCacheManager.createFile(java.lang.String)
Method Detail

fromEntryLine

static DiskCacheFile fromEntryLine(java.lang.String line,
                                   java.io.File dir)
                            throws java.io.IOException
Reconstruct a document file information object from a control file entry line.

Parameters:
line - A cache index file entry line, containing information about a document file.
dir - The cache directory name where the cached file resides.
Throws:
java.io.IOException - Thrown if line is malformed.
Since:
1.1, 2002-06-05
See Also:
toEntryLine()

toIso8601

static java.lang.String toIso8601(java.util.Date when)
Convert a date into an ISO-8601 formatted text string.

Parameters:
when - A date to convert.
Returns:
A text string in ISO-8601 format, "YYYYMMDDhhmmss". The time will be relative to the UTC timezone.
Since:
1.1, 2002-06-05
See Also:
fromIso8601(java.lang.String)

fromIso8601

static java.util.Date fromIso8601(java.lang.String s)
Convert a text string containing a date in ISO-8601 format into a date.

Parameters:
s - A text string in ISO-8601 format, "YYYYMMDDhhmmss". The time is assumed to be relative to the UTC timezone.
Returns:
A date value.
Since:
1.1, 2002-06-05
See Also:
toIso8601(java.util.Date)

hasExpired

protected boolean hasExpired(java.util.Date now)
Determine if this document file has expired or not.

Parameters:
now - The current date.
Returns:
True if this document file has expired, otherwise false.
Since:
1.1, 2002-06-04
See Also:
DiskCacheManager.setExpiryDays(int), DiskCacheManager.removeAllExpiredFiles(), DiskCacheManager.removeExpiredEntries()

toEntryLine

protected java.lang.String toEntryLine()
Construct a control file entry line out of this cached document file information object.

Returns:
A cache index file entry line, containing information about this document file.
Since:
1.1, 2002-06-04
See Also:
fromEntryLine(java.lang.String, java.io.File)