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

## org.springframework.scripting.support
Class ResourceScriptSource

    java.lang.Object
      org.springframework.scripting.support.ResourceScriptSource

All Implemented Interfaces:
  ScriptSource

    public class ResourceScriptSource

extends java.lang.Object
implements ScriptSource

`ScriptSource` implementation based on Spring's `Resource` abstraction. Loads the script text from the underlying Resource's `File` or `InputStream`, and tracks the last-modified timestamp of the file (if possible).

Since:
  2.0
Author:
  Rob Harrop, Juergen Hoeller
See Also:
  `Resource.getInputStream()`, `Resource.getFile()`, `ResourceLoader`

Field Summary
`protected org.apache.commons.logging.Log` | `logger` Logger available to subclasses

Constructor Summary
`ResourceScriptSource(Resource resource)` Create a new ResourceScriptSource for the given resource.

Method Summary
`Resource` | `getResource()` Return the `Resource` to load the script from.
`java.lang.String` | `getScriptAsString()` Retrieve the current script source text as String.
`boolean` | `isModified()` Indicate whether the underlying script data has been modified since the last time `ScriptSource.getScriptAsString()` was called.
`protected long` | `retrieveLastModifiedTime()` Retrieve the current last-modified timestamp of the underlying resource.
`void` | `setEncoding(java.lang.String encoding)` Sets the encoding used for reading the script resource.
`java.lang.String` | `suggestedClassName()` Determine a class name for the underlying script.
`java.lang.String` | `toString()`

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

Field Detail

### logger

    protected final org.apache.commons.logging.Log logger

  Logger available to subclasses

Constructor Detail

### ResourceScriptSource

    public ResourceScriptSource(Resource resource)

  Create a new ResourceScriptSource for the given resource.

  Parameters:
    `resource` - the Resource to load the script from

Method Detail

### getResource

    public final Resource getResource()

  Return the `Resource` to load the script from.

### getScriptAsString

    public java.lang.String getScriptAsString()
                                       throws java.io.IOException

  Description copied from interface: `ScriptSource`
  Retrieve the current script source text as String.

  Specified by:
    `getScriptAsString` in interface `ScriptSource`
  Returns:
    the script text
  Throws:
    `java.io.IOException` - if script retrieval failed

### isModified

    public boolean isModified()

  Description copied from interface: `ScriptSource`
  Indicate whether the underlying script data has been modified since the last time `ScriptSource.getScriptAsString()` was called. Returns `true` if the script has not been read yet.

  Specified by:
    `isModified` in interface `ScriptSource`
  Returns:
    whether the script data has been modified

### retrieveLastModifiedTime

    protected long retrieveLastModifiedTime()

  Retrieve the current last-modified timestamp of the underlying resource.

  Returns:
    the current timestamp, or 0 if not determinable

### suggestedClassName

    public java.lang.String suggestedClassName()

  Description copied from interface: `ScriptSource`
  Determine a class name for the underlying script.

  Specified by:
    `suggestedClassName` in interface `ScriptSource`
  Returns:
    the suggested class name, or `null` if none available

### setEncoding

    public void setEncoding(java.lang.String encoding)

  Sets the encoding used for reading the script resource. The default value is "UTF-8". A null value, implies the platform default.

  Parameters:
    `encoding` - charset encoding used for reading the script.

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

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