public final class ResourceManager extends Object
Constructor and Description |
---|
ResourceManager(Class<?> baseClass)
Constructor.
|
ResourceManager(Class<?> baseClass,
ResourceFinder resourceFinder,
boolean useCache)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
<T> T |
getResource(Class<T> c,
Parser parser,
String name)
Reads the input stream and parses it into a POJO using the specified parser.
|
<T> T |
getResource(Class<T> c,
Parser parser,
String name,
Locale locale)
Reads the input stream and parses it into a POJO using the specified parser.
|
InputStream |
getStream(String name)
Finds the resource with the given name.
|
InputStream |
getStream(String name,
Locale locale)
Finds the resource with the given name for the specified locale and returns it as an input stream.
|
String |
getString(String name)
Finds the resource with the given name and converts it to a simple string.
|
String |
getString(String name,
Locale locale)
Finds the resource with the given name and converts it to a simple string.
|
public ResourceManager(Class<?> baseClass, ResourceFinder resourceFinder, boolean useCache)
baseClass
- The default class to use for retrieving resources from the classpath.resourceFinder
- The resource finder implementation.useCache
- If public ResourceManager(Class<?> baseClass)
Uses default BasicResourceFinder
for finding resources.
baseClass
- The default class to use for retrieving resources from the classpath.public InputStream getStream(String name) throws IOException
name
- Name of the desired resource.IOException
- Thrown by underlying stream.public InputStream getStream(String name, Locale locale) throws IOException
name
- Name of the desired resource.locale
- The locale. Can be IOException
- Thrown by underlying stream.public String getString(String name) throws IOException
name
- Name of the desired resource.IOException
- Thrown by underlying stream.public String getString(String name, Locale locale) throws IOException
name
- Name of the desired resource.locale
- The locale. Can be IOException
- Thrown by underlying stream.public <T> T getResource(Class<T> c, Parser parser, String name) throws IOException, ParseException
c
- The class type of the POJO to create.parser
- The parser to use to parse the stream.name
- The resource name (e.g. "htdocs/styles.css").IOException
- Thrown by underlying stream.ParseException
- If stream could not be parsed using the specified parser.public <T> T getResource(Class<T> c, Parser parser, String name, Locale locale) throws IOException, ParseException
c
- The class type of the POJO to create.parser
- The parser to use to parse the stream.name
- The resource name (e.g. "htdocs/styles.css").locale
- Optional locale.
IOException
- Thrown by underlying stream.ParseException
- If stream could not be parsed using the specified parser.Copyright © 2016–2020 The Apache Software Foundation. All rights reserved.