Class ImportTool

java.lang.Object
org.apache.velocity.tools.generic.SafeConfig
org.apache.velocity.tools.generic.ImportTool
All Implemented Interfaces:
Serializable

@DefaultKey("import") @ValidScope("request") public class ImportTool extends SafeConfig implements Serializable
General-purpose text-importing tool for templates.

Usage: just call $import.read("http://www.foo.com/bleh.jsp?sneh=bar") to insert the contents of the named resource into the template.

Toolbox configuration:

<tools>
  <toolbox scope="request">
    <tool class="org.apache.velocity.tools.view.ImportTool"/>
  </toolbox>
</tools>
Since:
VelocityTools 3.0
Version:
$Id$
Author:
Marino A. Jonsson
See Also:
  • Field Details

    • importSupport

      protected transient ImportSupport importSupport
      ImportSupport utility which provides underlying i/o
  • Constructor Details

    • ImportTool

      public ImportTool()
  • Method Details

    • initializeImportSupport

      protected void initializeImportSupport(ValueParser config)
      Importsupport initialization
      Parameters:
      config - configuration values
    • configure

      protected void configure(ValueParser values)
      Configuration
      Overrides:
      configure in class SafeConfig
      Parameters:
      values - configuration values
    • read

      public String read(String resource)
      Returns the supplied resource rendered as a String.
      Parameters:
      resource - the URL to import
      Returns:
      the URL as a string
    • fetch

      public String fetch(String url)
      Returns the supplied URL rendered as a String.
      Parameters:
      url - the URL to import
      Returns:
      the URL as a string