Class ResourceEngine


  • public class ResourceEngine
    extends Object
    An engine to transform resources using a VelocityEngine.

    Resources given to this engine are processed and added to the embedded VelocityContext. For the evaluation the current VelocityContext and its content is used.

    Resources can be retrieved afterwards.

    Since:
    Ceres 0.13.2
    • Constructor Detail

      • ResourceEngine

        public ResourceEngine()
        Create a resource engine.
      • ResourceEngine

        public ResourceEngine​(org.apache.velocity.app.VelocityEngine velocityEngine)
        Create a resource engine using the given velocity engine.
        Parameters:
        velocityEngine - A velocity engine
    • 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 given Resource using the current VelocityContext and return the result.
        Parameters:
        resource - the resource
        Returns:
        The result of the processing
      • processAndAddResource

        public Resource processAndAddResource​(String name,
                                              Resource resource)
        Evaluates the given Resource using the current VelocityContext and adds the result of this processing to the VelocityContext under given name.

        The evaluated Resource is returned.

        Parameters:
        name - The name under which the resource is added
        resource - the resource
        Returns:
        The result of the processing
      • getResource

        public Resource getResource​(String name)
        Retrieves a resource registered under the given name in the VelocityContext. If no resource is registered under the given name a IllegalArgumentException is thrown.
        Parameters:
        name - The name of the resource
        Returns:
        The registered resource
        Throws:
        IllegalArgumentException - If no resource of the given name exists.