org.springframework.scripting.support

## 类 ResourceScriptSource

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

- 所有已实现的接口:
    ScriptSource

      public class ResourceScriptSource
      extends 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).
  从以下版本开始:
    2.0
  作者:
    Rob Harrop, Juergen Hoeller
  另请参阅:
    `InputStreamSource.getInputStream()`, `Resource.getFile()`, `ResourceLoader`

- - ### 字段概要

    字段
    限定符和类型 | 字段和说明
    --- | ---
    `protected Log` | `logger` Logger available to subclasses

  - ### 构造器概要

    构造器
    构造器和说明
    `ResourceScriptSource(org.springframework.core.io.support.EncodedResource resource)` Create a new ResourceScriptSource for the given resource.
    `ResourceScriptSource(org.springframework.core.io.Resource resource)` Create a new ResourceScriptSource for the given resource.

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `org.springframework.core.io.Resource` | `getResource()` Return the `Resource` to load the script from.
    `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(String encoding)` Set the encoding used for reading the script resource.
    `String` | `suggestedClassName()` Determine a class name for the underlying script.
    `String` | `toString()`

    - ### 从类继承的方法 java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### 字段详细资料

    - #### logger

          protected final Log logger

      Logger available to subclasses

  - ### 构造器详细资料

    - #### ResourceScriptSource

          public ResourceScriptSource(org.springframework.core.io.support.EncodedResource resource)

      Create a new ResourceScriptSource for the given resource.
      参数:
        `resource` - the EncodedResource to load the script from

    - #### ResourceScriptSource

          public ResourceScriptSource(org.springframework.core.io.Resource resource)

      Create a new ResourceScriptSource for the given resource.
      参数:
        `resource` - the Resource to load the script from (using UTF-8 encoding)

  - ### 方法详细资料

    - #### getResource

          public final org.springframework.core.io.Resource getResource()

      Return the `Resource` to load the script from.

    - #### setEncoding

          public void setEncoding(@Nullable
                                  String encoding)

      Set the encoding used for reading the script resource.

      The default value for regular Resources is "UTF-8". A `null` value implies the platform default.

    - #### getScriptAsString

          public String getScriptAsString()
                                   throws IOException

      从接口复制的说明: `ScriptSource`
      Retrieve the current script source text as String.
      指定者:
        `getScriptAsString` 在接口中 `ScriptSource`
      返回:
        the script text
      抛出:
        `IOException` - if script retrieval failed

    - #### isModified

          public boolean isModified()

      从接口复制的说明: `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.
      指定者:
        `isModified` 在接口中 `ScriptSource`
      返回:
        whether the script data has been modified

    - #### retrieveLastModifiedTime

          protected long retrieveLastModifiedTime()

      Retrieve the current last-modified timestamp of the underlying resource.
      返回:
        the current timestamp, or 0 if not determinable

    - #### suggestedClassName

          @Nullable
          public String suggestedClassName()

      从接口复制的说明: `ScriptSource`
      Determine a class name for the underlying script.
      指定者:
        `suggestedClassName` 在接口中 `ScriptSource`
      返回:
        the suggested class name, or `null` if none available

    - #### toString

          public String toString()

      覆盖:
        `toString` 在类中 `Object`