1 /* 2 * $Id: VelocityModelBody.java 1305546 2012-03-26 20:34:37Z nlebas $ 3 * 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 */ 21 package org.apache.tiles.request.velocity.autotag; 22 23 import java.io.IOException; 24 import java.io.Writer; 25 26 import org.apache.tiles.autotag.core.runtime.AbstractModelBody; 27 import org.apache.velocity.context.InternalContextAdapter; 28 import org.apache.velocity.runtime.parser.node.ASTBlock; 29 30 /** 31 * Body abstraction for a Velocity directive body. 32 * 33 * @version $Rev: 1305546 $ $Date: 2012-03-27 07:34:37 +1100 (Tue, 27 Mar 2012) $ 34 */ 35 public class VelocityModelBody extends AbstractModelBody { 36 37 /** 38 * The real body. 39 */ 40 private ASTBlock body; 41 42 /** 43 * The Velocity context. 44 */ 45 private InternalContextAdapter context; 46 47 /** 48 * Constructor. 49 * 50 * @param context The Velocity context. 51 * @param body The real body. 52 * @param defaultWriter The default writer. 53 */ 54 public VelocityModelBody(InternalContextAdapter context, ASTBlock body, Writer defaultWriter) { 55 super(defaultWriter); 56 this.context = context; 57 this.body = body; 58 } 59 60 @Override 61 public void evaluate(Writer writer) throws IOException { 62 body.render(context, writer); 63 } 64 65 }