org.apache.velocity.runtime.resource

Class Resource

public abstract class Resource extends Object

This class represent a general text resource that may have been retrieved from any number of possible sources.

Version: $Id: Resource.java,v 1.12.4.1 2004/03/03 23:23:01 geirm Exp $

Author: Jason van Zyl Geir Magnusson Jr.

Field Summary
protected Objectdata
Resource might require ancillary storage of some kind
protected Stringencoding
Character encoding of this resource
protected longlastModified
The file modification time (in milliseconds) for the cached template.
protected longmodificationCheckInterval
How often the file modification time is checked (in seconds).
protected static longMILLIS_PER_SECOND
The number of milliseconds in a minute, used to calculate the check interval.
protected Stringname
Name of the resource
protected longnextCheck
The next time the file modification time will be checked (in milliseconds).
protected ResourceLoaderresourceLoader
The template loader that initially loaded the input stream for this template, and knows how to check the source of the input stream for modification.
protected RuntimeServicesrsvc
Constructor Summary
Resource()
Default constructor
Method Summary
ObjectgetData()
Get arbitrary data object that might be used by the resource.
StringgetEncoding()
get the encoding of this resource for example, "ISO-8859-1"
longgetLastModified()
Return the lastModifed time of this template.
StringgetName()
Get the name of this template.
ResourceLoadergetResourceLoader()
Return the template loader that pulled in the template stream
booleanisSourceModified()
abstract booleanprocess()
Perform any subsequent processing that might need to be done by a resource.
booleanrequiresChecking()
Is it time to check to see if the resource source has been updated?
voidsetData(Object data)
Set arbitrary data object that might be used by the resource.
voidsetEncoding(String encoding)
set the encoding of this resource for example, "ISO-8859-1"
voidsetLastModified(long lastModified)
Set the last modified time for this template.
voidsetModificationCheckInterval(long modificationCheckInterval)
Set the modification check interval.
voidsetName(String name)
Set the name of this resource, for example test.vm.
voidsetResourceLoader(ResourceLoader resourceLoader)
Set the template loader for this template.
voidsetRuntimeServices(RuntimeServices rs)
voidtouch()
'Touch' this template and thereby resetting the nextCheck field.

Field Detail

data

protected Object data
Resource might require ancillary storage of some kind

encoding

protected String encoding
Character encoding of this resource

lastModified

protected long lastModified
The file modification time (in milliseconds) for the cached template.

modificationCheckInterval

protected long modificationCheckInterval
How often the file modification time is checked (in seconds).

MILLIS_PER_SECOND

protected static final long MILLIS_PER_SECOND
The number of milliseconds in a minute, used to calculate the check interval.

name

protected String name
Name of the resource

nextCheck

protected long nextCheck
The next time the file modification time will be checked (in milliseconds).

resourceLoader

protected ResourceLoader resourceLoader
The template loader that initially loaded the input stream for this template, and knows how to check the source of the input stream for modification.

rsvc

protected RuntimeServices rsvc

Constructor Detail

Resource

public Resource()
Default constructor

Method Detail

getData

public Object getData()
Get arbitrary data object that might be used by the resource.

getEncoding

public String getEncoding()
get the encoding of this resource for example, "ISO-8859-1"

getLastModified

public long getLastModified()
Return the lastModifed time of this template.

getName

public String getName()
Get the name of this template.

getResourceLoader

public ResourceLoader getResourceLoader()
Return the template loader that pulled in the template stream

isSourceModified

public boolean isSourceModified()

process

public abstract boolean process()
Perform any subsequent processing that might need to be done by a resource. In the case of a template the actual parsing of the input stream needs to be performed.

Returns: Whether the resource could be processed successfully. For a Template or ContentResource, this indicates whether the resource could be read.

Throws: ResourceNotFoundException Similar in semantics as returning false.

requiresChecking

public boolean requiresChecking()
Is it time to check to see if the resource source has been updated?

setData

public void setData(Object data)
Set arbitrary data object that might be used by the resource.

setEncoding

public void setEncoding(String encoding)
set the encoding of this resource for example, "ISO-8859-1"

setLastModified

public void setLastModified(long lastModified)
Set the last modified time for this template.

setModificationCheckInterval

public void setModificationCheckInterval(long modificationCheckInterval)
Set the modification check interval.

Parameters: interval The interval (in seconds).

setName

public void setName(String name)
Set the name of this resource, for example test.vm.

setResourceLoader

public void setResourceLoader(ResourceLoader resourceLoader)
Set the template loader for this template. Set when the Runtime determines where this template came from the list of possible sources.

setRuntimeServices

public void setRuntimeServices(RuntimeServices rs)

touch

public void touch()
'Touch' this template and thereby resetting the nextCheck field.
Copyright B) 2002 Apache Software Foundation. All Rights Reserved.