Resource (Velocity 1.4 API)
Keywords: org.apache.velocity.runtime.resource.Resource class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.velocity.runtime.resource
Class Resource

    java.lang.Object
      org.apache.velocity.runtime.resource.Resource

Direct Known Subclasses:
  ContentResource, Template

public abstract class Resource
extends java.lang.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 java.lang.Object` | `data` Resource might require ancillary storage of some kind
`protected java.lang.String` | `encoding` Character encoding of this resource
`protected long` | `lastModified` The file modification time (in milliseconds) for the cached template.
`protected static long` | `MILLIS_PER_SECOND` The number of milliseconds in a minute, used to calculate the check interval.
`protected long` | `modificationCheckInterval` How often the file modification time is checked (in seconds).
`protected java.lang.String` | `name` Name of the resource
`protected long` | `nextCheck` The next time the file modification time will be checked (in milliseconds).
`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.
`protected RuntimeServices` | `rsvc`

Constructor Summary
`Resource()` Default constructor

Method Summary
`java.lang.Object` | `getData()` Get arbitrary data object that might be used by the resource.
`java.lang.String` | `getEncoding()` get the encoding of this resource for example, "ISO-8859-1"
`long` | `getLastModified()` Return the lastModifed time of this template.
`java.lang.String` | `getName()` Get the name of this template.
`ResourceLoader` | `getResourceLoader()` Return the template loader that pulled in the template stream
`boolean` | `isSourceModified()`
`abstract boolean` | `process()` Perform any subsequent processing that might need to be done by a resource.
`boolean` | `requiresChecking()` Is it time to check to see if the resource source has been updated?
`void` | `setData(java.lang.Object data)` Set arbitrary data object that might be used by the resource.
`void` | `setEncoding(java.lang.String encoding)` set the encoding of this resource for example, "ISO-8859-1"
`void` | `setLastModified(long lastModified)` Set the last modified time for this template.
`void` | `setModificationCheckInterval(long modificationCheckInterval)` Set the modification check interval.
`void` | `setName(java.lang.String name)` Set the name of this resource, for example test.vm.
`void` | `setResourceLoader(ResourceLoader resourceLoader)` Set the template loader for this template.
`void` | `setRuntimeServices(RuntimeServices rs)`
`void` | `touch()` 'Touch' this template and thereby resetting the nextCheck field.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### rsvc

    protected RuntimeServices rsvc

### 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.

### MILLIS_PER_SECOND

    protected static final long MILLIS_PER_SECOND

  The number of milliseconds in a minute, used to calculate the check interval.

  See Also:
    Constant Field Values

### modificationCheckInterval

    protected long modificationCheckInterval

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

### lastModified

    protected long lastModified

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

### nextCheck

    protected long nextCheck

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

### name

    protected java.lang.String name

  Name of the resource

### encoding

    protected java.lang.String encoding

  Character encoding of this resource

### data

    protected java.lang.Object data

  Resource might require ancillary storage of some kind

Constructor Detail

### Resource

    public Resource()

  Default constructor

Method Detail

### setRuntimeServices

    public void setRuntimeServices(RuntimeServices rs)

### process

    public abstract boolean process()
                             throws ResourceNotFoundException,
                                    ParseErrorException,
                                    java.lang.Exception

  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`.
    `ParseErrorException`
    `java.lang.Exception`

### isSourceModified

    public boolean isSourceModified()

### setModificationCheckInterval

    public void setModificationCheckInterval(long modificationCheckInterval)

  Set the modification check interval.

### requiresChecking

    public boolean requiresChecking()

  Is it time to check to see if the resource source has been updated?

### touch

    public void touch()

  'Touch' this template and thereby resetting the nextCheck field.

### setName

    public void setName(java.lang.String name)

  Set the name of this resource, for example test.vm.

### getName

    public java.lang.String getName()

  Get the name of this template.

### setEncoding

    public void setEncoding(java.lang.String encoding)

  set the encoding of this resource for example, "ISO-8859-1"

### getEncoding

    public java.lang.String getEncoding()

  get the encoding of this resource for example, "ISO-8859-1"

### getLastModified

    public long getLastModified()

  Return the lastModifed time of this template.

### setLastModified

    public void setLastModified(long lastModified)

  Set the last modified time for this template.

### getResourceLoader

    public ResourceLoader getResourceLoader()

  Return the template loader that pulled in the template stream

### 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.

### setData

    public void setData(java.lang.Object data)

  Set arbitrary data object that might be used by the resource.

### getData

    public java.lang.Object getData()

  Get arbitrary data object that might be used by the resource.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002 Apache Software Foundation. All Rights Reserved.