1 /***
2 * The contents of this file are subject to the Mozilla Public
3 * License Version 1.1 (the "License"); you may not use this file
4 * except in compliance with the License. You may obtain a copy of
5 * the License at http://www.mozilla.org/MPL/
6 *
7 * Software distributed under the License is distributed on an "AS
8 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9 * implied. See the License for the specific language governing
10 * rights and limitations under the License.
11 *
12 * The Original Code is pow2toolkit library.
13 *
14 * The Initial Owner of the Original Code is
15 * Power Of Two S.R.L. (www.pow2.com)
16 *
17 * Portions created by Power Of Two S.R.L. are
18 * Copyright (C) Power Of Two S.R.L.
19 * All Rights Reserved.
20 *
21 * Contributor(s):
22 */
23
24 package com.pow2.texen.ant;
25
26
27 import org.apache.velocity.context.*;
28 import org.apache.velocity.VelocityContext;
29 import org.apache.velocity.texen.ant.TexenTask;
30
31
32 /***
33 * Simple Texen Task class.
34 * <br>
35 * Put some useful classes
36 * into the control context.
37 * <br>
38 * See <code>initControlContext</code> for further details.
39 *
40 * @author Luca Fossato
41 * @created 24 ottobre 2002
42 */
43 public class SimplePreprocessorTask extends TexenTask
44 {
45 /***
46 * Set up the initial context with some useful references
47 * to utility classes.
48 * <br>
49 * Here they are:
50 * <ul>
51 * <li>
52 * fileBean - com.pow2.texen.ant.FileBean class
53 * <br>
54 * Note: the <code>fileDirectory</code> attribute is set to the
55 * <code>templatePath</code> value
56 * </li>
57 * </ul>
58 *
59 * @return the context
60 * @throws Exception if any error occurs
61 */
62 public Context initControlContext() throws Exception
63 {
64 Context context = new VelocityContext();
65
66
67 FileBean fileBean = new FileBean();
68 fileBean.setFileDirectory(templatePath);
69 context.put("fileBean", fileBean);
70
71 return context;
72 }
73 }