Class ImportSupport
java.lang.Object
org.apache.velocity.tools.generic.SafeConfig
org.apache.velocity.tools.generic.ImportSupport
- Direct Known Subclasses:
JsonTool
Provides methods to import arbitrary local or remote resources as strings, generic version.
Based on ImportSupport from the JSTL taglib by Shawn Bayern
- Since:
- VelocityTools 3.0
- Version:
- $$
- Author:
- Marino A. Jonsson, Claude Brisson
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringConfiguration key for XmlTool and JsonTool, used to specify a local resourcestatic final StringConfiguration key for ImportTool, XmlTool and JsonTool, used to specify a local or remote source URLprotected static final StringFields inherited from class SafeConfig
LOCK_CONFIG_KEY, log, LOGGER_NAME_KEY, SAFE_MODE_KEY, USE_CLASS_LOGGER_KEY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ReaderAcquire a reader to a local URL - non applicable to the generic version of ImportSupportprotected StringAquire the content of a local URL.acquireReader(String url) Acquire a reader to an URLprotected ReaderAcquire a reader to a remote URLprotected StringAquire the content of a remote URL.acquireString(String url) protected voidconfigure(ValueParser values) Configure import supportprotected URLgetClasspathResource(String resource) Classpath entry URL builderstatic StringgetContentTypeAttribute(String input, String name) Get the value associated with a content-type attribute.protected URLgetFileResource(String resource) Overridable local file URL builder.static StringgetProtocol(String url) Returns protocol, or null for a local URLgetResourceReader(String resource) Get a reader of a local resource, first trying with a file (or a webapp resource for the view flavor) then with a classpath entry.getResourceString(String resource) Fetch a local resource, first trying with a file (or a webapp resource for the view flavor) then with a classpath entry.static booleanisRemoteURL(String url) Returns whether an URL is remote or localvoidsetSafeMode(boolean safe) Sets or clears safe modeMethods inherited from class SafeConfig
configure, getLog, initLogger, isConfigLocked, isSafeMode, setLockConfig
-
Field Details
-
VALID_SCHEME_CHARS
- See Also:
-
RESOURCE_KEY
Configuration key for XmlTool and JsonTool, used to specify a local resource- See Also:
-
URL_KEY
Configuration key for ImportTool, XmlTool and JsonTool, used to specify a local or remote source URL- See Also:
-
-
Constructor Details
-
ImportSupport
public ImportSupport()
-
-
Method Details
-
configure
Configure import support- Overrides:
configurein classSafeConfig- Parameters:
values- configuration values
-
setSafeMode
public void setSafeMode(boolean safe) Sets or clears safe mode- Overrides:
setSafeModein classSafeConfig- Parameters:
safe- flag value
-
acquireString
- Parameters:
url- the URL resource to return as string- Returns:
- the URL resource as string
- Throws:
IOException- if operation failed
-
acquireRemoteURLString
Aquire the content of a remote URL.- Parameters:
url- remote URL- Returns:
- the URL resource as string
- Throws:
IOException- if operation failed
-
acquireLocalURLString
Aquire the content of a local URL.- Parameters:
url- local URL- Returns:
- the URL resource as string
- Throws:
IOException- if operation failed
-
acquireReader
Acquire a reader to an URL- Parameters:
url- the URL to read- Returns:
- a Reader for the InputStream created from the supplied URL
- Throws:
IOException- if operation failed
-
acquireRemoteURLReader
Acquire a reader to a remote URL- Parameters:
url- the URL to read- Returns:
- a Reader for the InputStream created from the supplied URL
- Throws:
IOException- if operation failed
-
acquireLocalURLReader
Acquire a reader to a local URL - non applicable to the generic version of ImportSupport- Parameters:
url- the URL to read- Returns:
- a Reader for the InputStream created from the supplied URL
- Throws:
IOException- if operation failed
-
isRemoteURL
Returns whether an URL is remote or local- Parameters:
url- the url to check out- Returns:
- wether the URL is remote
-
getProtocol
-
getContentTypeAttribute
Get the value associated with a content-type attribute. Syntax defined in RFC 2045, section 5.1.- Parameters:
input- the string containing the attributesname- the name of the content-type attribute- Returns:
- the value associated with a content-type attribute
-
getResourceString
-
getResourceReader
-
getFileResource
-
getClasspathResource
-