org.apache.velocity.runtime.resource.ResourceManager Java Examples

The following examples show how to use org.apache.velocity.runtime.resource.ResourceManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AliadaResourceFactory.java    From aliada-tool with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns a resource according with given data.
 * 
 * @param resourceName the resource name.
 * @param resourceType the resource kind.
 * @return The resource described by name and type.
 */
public static Resource getResource(final String resourceName, final int resourceType) {
    switch (resourceType) {
        case ResourceManager.RESOURCE_TEMPLATE:
            return new AliadaTemplate();
        case ResourceManager.RESOURCE_CONTENT:
            return new ContentResource();
        default:
        	throw new IllegalArgumentException("WARNIGN: Unknown resource type: " + resourceType);
    }
}
 
Example #2
Source File: Template.java    From velocity-engine with Apache License 2.0 5 votes vote down vote up
/** Default constructor */
public Template()
{
    super();

    setType(ResourceManager.RESOURCE_TEMPLATE);
}
 
Example #3
Source File: RuntimeInstance.java    From velocity-engine with Apache License 2.0 3 votes vote down vote up
/**
 * Returns a <code>Template</code> from the resource manager
 *
 * @param name The  name of the desired template.
 * @param encoding Character encoding of the template
 * @return     The template.
 * @throws ResourceNotFoundException if template not found
 *          from any available source.
 * @throws ParseErrorException if template cannot be parsed due
 *          to syntax (or other) error.
 */
public Template getTemplate(String name, String  encoding)
    throws ResourceNotFoundException, ParseErrorException
{
    requireInitialization();
    if (encoding == null) encoding = getDefaultEncoding();
    return (Template)
            resourceManager.getResource(name,
                ResourceManager.RESOURCE_TEMPLATE, encoding);
}
 
Example #4
Source File: RuntimeInstance.java    From velocity-engine with Apache License 2.0 3 votes vote down vote up
/**
 * Returns a static content resource from the
 * resource manager.
 *
 * @param name Name of content resource to get
 * @param encoding Character encoding to use
 * @return parsed ContentResource object ready for use
 * @throws ResourceNotFoundException if template not found
 *          from any available source.
 * @throws ParseErrorException When the template could not be parsed.
 */
public ContentResource getContent(String name, String encoding)
    throws ResourceNotFoundException, ParseErrorException
{
    requireInitialization();

    return (ContentResource)
            resourceManager.getResource(name,
                    ResourceManager.RESOURCE_CONTENT, encoding);
}