Class ImportTool

  • All Implemented Interfaces:
    java.io.Serializable

    @DefaultKey("import")
    @ValidScope("request")
    public class ImportTool
    extends SafeConfig
    implements java.io.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:
    Serialized Form
    • Field Detail

      • importSupport

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

      • ImportTool

        public ImportTool()
    • Method Detail

      • 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 java.lang.String read​(java.lang.String resource)
        Returns the supplied resource rendered as a String.
        Parameters:
        resource - the URL to import
        Returns:
        the URL as a string
      • fetch

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