org.apache.velocity.tools.view.tools
Class ImportTool

java.lang.Object
  extended by org.apache.velocity.tools.view.ImportSupport
      extended by org.apache.velocity.tools.view.tools.ImportTool

public class ImportTool
extends ImportSupport

General-purpose text-importing view 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:
 <tool>
   <key>import</key>
   <scope>request</scope>
   <class>org.apache.velocity.tools.view.tools.ImportTool</class>
 </tool>
 

Since:
VelocityTools 1.1
Version:
$Revision: 477914 $ $Date: 2006-11-21 13:52:11 -0800 (Tue, 21 Nov 2006) $
Author:
Marino A. Jonsson

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.velocity.tools.view.ImportSupport
ImportSupport.ImportResponseWrapper, ImportSupport.SafeClosingHttpURLConnectionReader
 
Field Summary
protected static org.apache.commons.logging.Log LOG
           
 
Fields inherited from class org.apache.velocity.tools.view.ImportSupport
application, DEFAULT_ENCODING, request, response, VALID_SCHEME_CHARS
 
Constructor Summary
ImportTool()
          Default constructor.
 
Method Summary
 void init(java.lang.Object obj)
          Initializes this tool.
 java.lang.String read(java.lang.String url)
          Returns the supplied URL rendered as a String.
 
Methods inherited from class org.apache.velocity.tools.view.ImportSupport
acquireReader, acquireString, getContentTypeAttribute, isAbsoluteUrl, stripSession
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

protected static final org.apache.commons.logging.Log LOG
Constructor Detail

ImportTool

public ImportTool()
Default constructor. Tool must be initialized before use.

Method Detail

init

public void init(java.lang.Object obj)
Initializes this tool.

Parameters:
obj - the current ViewContext
Throws:
java.lang.IllegalArgumentException - if the param is not a ViewContext

read

public java.lang.String read(java.lang.String url)
Returns the supplied URL rendered as a String.

Parameters:
url - the URL to import
Returns:
the URL as a string


Copyright (c) 2003-2007 Apache Software Foundation