EchoPoint
1.0

echopoint.template
Class CachedFileDataSource

java.lang.Object
  extended byechopoint.template.AbstractDataSource
      extended byechopoint.template.FileDataSource
          extended byechopoint.template.CachedFileDataSource
All Implemented Interfaces:
DataSource, java.io.Serializable

public class CachedFileDataSource
extends FileDataSource
implements java.io.Serializable

A CachedFileDataSource implements a DataSource for a files and URLS, but caches small ones up to CACHED_SIZE_LIMIT or a specified limit size.

See Also:
Serialized Form

Field Summary
static int CACHED_ENTRY_LIMIT
          How many entries can we have after which we will clear the cache a little.
static int CACHED_SIZE_LIMIT
          How big can the file be after which we wont cache it.
 
Fields inherited from class echopoint.template.FileDataSource
canonicalName
 
Fields inherited from class echopoint.template.AbstractDataSource
DEFAULT_ENCODING
 
Constructor Summary
CachedFileDataSource(java.io.File f)
          Creates a cache entry for the file if its less than CACHED_SIZE_LIMIT in size.
CachedFileDataSource(java.io.File f, int cacheSize)
          Creates a cache entry for the file if its less than cacheSize in size.
CachedFileDataSource(java.io.File f, int maxFileCacheSize, java.lang.String encoding)
          Creates a cached entry for the File f if its less than maxFileCacheSize in size.
CachedFileDataSource(java.net.URL url)
          Creates a cached entry for the URL url.
CachedFileDataSource(java.net.URL url, java.lang.String encoding)
          Creates a cached entry for the URL url.
 
Method Summary
 java.io.Reader getInputReader()
          Gets an Reader of the File.
 long lastModified()
          Returns the time the content of this File was last modified.
 
Methods inherited from class echopoint.template.FileDataSource
getCanonicalName
 
Methods inherited from class echopoint.template.AbstractDataSource
getCharacterEncoding, setCharacterEncoding
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CACHED_SIZE_LIMIT

public static final int CACHED_SIZE_LIMIT
How big can the file be after which we wont cache it.

See Also:
Constant Field Values

CACHED_ENTRY_LIMIT

public static final int CACHED_ENTRY_LIMIT
How many entries can we have after which we will clear the cache a little.

See Also:
Constant Field Values
Constructor Detail

CachedFileDataSource

public CachedFileDataSource(java.io.File f)
                     throws java.io.IOException,
                            java.io.UnsupportedEncodingException
Creates a cache entry for the file if its less than CACHED_SIZE_LIMIT in size.

Uses the default character encoding of AbstractDataSource.DEFAULT_ENCODING


CachedFileDataSource

public CachedFileDataSource(java.io.File f,
                            int cacheSize)
                     throws java.io.IOException,
                            java.io.UnsupportedEncodingException
Creates a cache entry for the file if its less than cacheSize in size.

Uses the default character encoding of AbstractDataSource.DEFAULT_ENCODING


CachedFileDataSource

public CachedFileDataSource(java.io.File f,
                            int maxFileCacheSize,
                            java.lang.String encoding)
                     throws java.io.IOException,
                            java.io.UnsupportedEncodingException
Creates a cached entry for the File f if its less than maxFileCacheSize in size.

Uses the character encoding supplied


CachedFileDataSource

public CachedFileDataSource(java.net.URL url)
                     throws java.io.IOException,
                            java.io.UnsupportedEncodingException
Creates a cached entry for the URL url. URLs are always cached

Uses the default character encoding of "iso-8859-1"


CachedFileDataSource

public CachedFileDataSource(java.net.URL url,
                            java.lang.String encoding)
                     throws java.io.IOException,
                            java.io.UnsupportedEncodingException
Creates a cached entry for the URL url. URLs are always cached

Uses the character encoding provided.

Method Detail

getInputReader

public java.io.Reader getInputReader()
                              throws java.io.IOException
Gets an Reader of the File.

Specified by:
getInputReader in interface DataSource
Overrides:
getInputReader in class FileDataSource
Throws:
java.io.IOException

lastModified

public long lastModified()
Returns the time the content of this File was last modified.

The return value is used to decide whether to reparse a Source or not. Reparsing is done if the value returned here differs from the value returned at the last processing time.

Specified by:
lastModified in interface DataSource
Overrides:
lastModified in class FileDataSource
Returns:
long a modification time

EchoPoint
1.0