Package com.bc.ceres.resource
Class ResourceEngine
- java.lang.Object
-
- com.bc.ceres.resource.ResourceEngine
-
public class ResourceEngine extends Object
An engine to transform resources using aVelocityEngine
.Resources given to this engine are processed and added to the embedded
VelocityContext
. For the evaluation the currentVelocityContext
and its content is used.Resources can be retrieved afterwards.
- Since:
- Ceres 0.13.2
-
-
Constructor Summary
Constructors Constructor Description ResourceEngine()
Create a resource engine.ResourceEngine(org.apache.velocity.app.VelocityEngine velocityEngine)
Create a resource engine using the given velocity engine.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Resource
getResource(String name)
Retrieves a resource registered under the given name in theVelocityContext
.org.apache.velocity.VelocityContext
getVelocityContext()
Return the used velocity context.Resource
processAndAddResource(String name, Resource resource)
Evaluates the givenResource
using the currentVelocityContext
and adds the result of this processing to theVelocityContext
under given name.Resource
processResource(Resource resource)
Evaluates the givenResource
using the currentVelocityContext
and return the result.
-
-
-
Method Detail
-
getVelocityContext
public org.apache.velocity.VelocityContext getVelocityContext()
Return the used velocity context.- Returns:
- the velocity context.
-
processResource
public Resource processResource(Resource resource)
Evaluates the givenResource
using the currentVelocityContext
and return the result.- Parameters:
resource
- the resource- Returns:
- The result of the processing
-
processAndAddResource
public Resource processAndAddResource(String name, Resource resource)
Evaluates the givenResource
using the currentVelocityContext
and adds the result of this processing to theVelocityContext
under given name.The evaluated
Resource
is returned.- Parameters:
name
- The name under which the resource is addedresource
- the resource- Returns:
- The result of the processing
-
getResource
public Resource getResource(String name)
Retrieves a resource registered under the given name in theVelocityContext
. If no resource is registered under the given name aIllegalArgumentException
is thrown.- Parameters:
name
- The name of the resource- Returns:
- The registered resource
- Throws:
IllegalArgumentException
- If no resource of the given name exists.
-
-