com.ptc.wvs.client.pview
Class PViewCache

java.lang.Object
  extended bycom.ptc.wvs.client.pview.PViewCache

public class PViewCache
extends Object

Manages the file cache used by the viewer



Supported API: false

Extendable: false


Field Summary
private  Hashtable cache
           
private  boolean debug
           
private  String directoryCache
           
 
Constructor Summary
PViewCache()
          Creates a new PViewCache.
PViewCache(String directory)
          Creates a new PViewCache.
 
Method Summary
 void addCacheEntry(String key, String file, int usedBy)
          Adds a new entry to the cache
 void addCacheReference(String key, int usedBy)
          Returns a new unique filename in the cache
 void deleteCachedEntries(int usedBy)
          Deletes a reference to an entry in the cache.
private  String directorySetup(String directory)
          Initialize the directory
 String getCachedFilename(String key)
          Returns the file name from the cache
 String getNewCacheFilename(String extension)
          Returns a new unique filename in the cache
 boolean isDebug()
          Returns the debug state
 boolean isInCache(String key)
          Returns if the key is currently available from the cache
 boolean isInCache(String key, int usedBy)
          Returns if the key is currently available from the cache, and refernced by the specifed viewer
 void setDebug(boolean debug)
          Switches debug information on/off
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cache

private Hashtable cache

directoryCache

private String directoryCache

debug

private boolean debug
Constructor Detail

PViewCache

public PViewCache()
Creates a new PViewCache. The directory used to hold the cached files will be determined by a call to PViewUtilities.getTempDirectory, a sub-directory of pvcache will be created in this directory.


PViewCache

public PViewCache(String directory)
Creates a new PViewCache. The directory specified will be used to hold the cached files in a sub-directory of pvcache. pvcache will be created if it does not already exist

Method Detail

directorySetup

private String directorySetup(String directory)
Initialize the directory

Parameters:
directory - the specified directory (it must already exist)
Returns:
the cache directory, if blank, it failed to access.

setDebug

public void setDebug(boolean debug)
Switches debug information on/off

Parameters:
debug - specifies if debug information is to be produced

isDebug

public boolean isDebug()
Returns the debug state

Returns:
debug state

getNewCacheFilename

public String getNewCacheFilename(String extension)
Returns a new unique filename in the cache

Parameters:
extension - to the filename
Returns:
unique filename

addCacheReference

public void addCacheReference(String key,
                              int usedBy)
Returns a new unique filename in the cache

Parameters:
key - typically the url to the viewable
usedBy - a reference to the viewer, typically the HWND (window handle)

addCacheEntry

public void addCacheEntry(String key,
                          String file,
                          int usedBy)
Adds a new entry to the cache

Parameters:
key - typically the url to the viewable
file - the file name in the cache directory
usedBy - a reference to the viewer, typically the HWND (window handle)

isInCache

public boolean isInCache(String key)
Returns if the key is currently available from the cache

Parameters:
key - typically the url to the viewable
Returns:
True if located in the cache

isInCache

public boolean isInCache(String key,
                         int usedBy)
Returns if the key is currently available from the cache, and refernced by the specifed viewer

Parameters:
key - typically the url to the viewable
usedBy - a reference to the viewer, typically the HWND (window handle)
Returns:
True if located in the cache

getCachedFilename

public String getCachedFilename(String key)
Returns the file name from the cache

Parameters:
key - typically the url to the viewable
Returns:
the file name

deleteCachedEntries

public void deleteCachedEntries(int usedBy)
Deletes a reference to an entry in the cache. If then no other viewer references the entry, the file is deleted from disk

Parameters:
usedBy - a reference to the viewer, typically the HWND (window handle)