@InvalidScope(value={"application","session","request"}) public class ImportSupport extends SafeConfig
Provides methods to import arbitrary local or remote resources as strings, generic version.
Based on ImportSupport from the JSTL taglib by Shawn Bayern
Modifier and Type | Class and Description |
---|---|
protected static class |
ImportSupport.SafeClosingHttpURLConnectionReader |
Modifier and Type | Field and Description |
---|---|
static String |
RESOURCE_KEY
Configuration key for XmlTool and JsonTool, used to specify a local resource
|
static String |
URL_KEY
Configuration key for ImportTool, XmlTool and JsonTool, used to specify a local or remote source URL
|
protected static String |
VALID_SCHEME_CHARS |
LOCK_CONFIG_KEY, log, LOGGER_NAME_KEY, SAFE_MODE_KEY, USE_CLASS_LOGGER_KEY
Constructor and Description |
---|
ImportSupport() |
Modifier and Type | Method and Description |
---|---|
protected Reader |
acquireLocalURLReader(String url)
Acquire a reader to a local URL - non applicable to the generic version of ImportSupport
|
protected String |
acquireLocalURLString(String url)
Aquire the content of a local URL.
|
Reader |
acquireReader(String url)
Acquire a reader to an URL
|
protected Reader |
acquireRemoteURLReader(String url)
Acquire a reader to a remote URL
|
protected String |
acquireRemoteURLString(String url)
Aquire the content of a remote URL.
|
String |
acquireString(String url) |
protected void |
configure(ValueParser values)
Configure import support
|
protected URL |
getClasspathResource(String resource)
Classpath entry URL builder
|
static String |
getContentTypeAttribute(String input,
String name)
Get the value associated with a content-type attribute.
|
protected URL |
getFileResource(String resource)
Overridable local file URL builder.
|
static String |
getProtocol(String url)
Returns protocol, or null for a local URL
|
Reader |
getResourceReader(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.
|
String |
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 boolean |
isRemoteURL(String url)
Returns whether an URL is remote or local
|
void |
setSafeMode(boolean safe)
Sets or clears safe mode
|
configure, getLog, initLogger, isConfigLocked, isSafeMode, setLockConfig
protected static final String VALID_SCHEME_CHARS
public static final String RESOURCE_KEY
public static final String URL_KEY
protected void configure(ValueParser values)
configure
in class SafeConfig
values
- configuration valuespublic void setSafeMode(boolean safe)
setSafeMode
in class SafeConfig
safe
- flag valuepublic String acquireString(String url) throws IOException
url
- the URL resource to return as stringIOException
- if operation failedprotected String acquireRemoteURLString(String url) throws IOException
url
- remote URLIOException
- if operation failedprotected String acquireLocalURLString(String url) throws IOException
url
- local URLIOException
- if operation failedpublic Reader acquireReader(String url) throws IOException
url
- the URL to readIOException
- if operation failedprotected Reader acquireRemoteURLReader(String url) throws IOException
url
- the URL to readIOException
- if operation failedprotected Reader acquireLocalURLReader(String url) throws IOException
url
- the URL to readIOException
- if operation failedpublic static boolean isRemoteURL(String url)
url
- the url to check outpublic static String getProtocol(String url)
url
- the url to check outpublic static String getContentTypeAttribute(String input, String name)
input
- the string containing the attributesname
- the name of the content-type attributepublic String getResourceString(String resource)
resource
- the resource to readpublic Reader getResourceReader(String resource)
resource
- the resource to readprotected URL getFileResource(String resource) throws Exception
resource
- the resource to readException
- if operation failedCopyright © 2002–2018 The Apache Software Foundation. All rights reserved.