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 currentVelocityContextand 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 ResourcegetResource(String name)Retrieves a resource registered under the given name in theVelocityContext.org.apache.velocity.VelocityContextgetVelocityContext()Return the used velocity context.ResourceprocessAndAddResource(String name, Resource resource)Evaluates the givenResourceusing the currentVelocityContextand adds the result of this processing to theVelocityContextunder given name.ResourceprocessResource(Resource resource)Evaluates the givenResourceusing the currentVelocityContextand 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 givenResourceusing the currentVelocityContextand return the result.- Parameters:
resource- the resource- Returns:
- The result of the processing
-
processAndAddResource
public Resource processAndAddResource(String name, Resource resource)
Evaluates the givenResourceusing the currentVelocityContextand adds the result of this processing to theVelocityContextunder given name.The evaluated
Resourceis 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 aIllegalArgumentExceptionis thrown.- Parameters:
name- The name of the resource- Returns:
- The registered resource
- Throws:
IllegalArgumentException- If no resource of the given name exists.
-
-