001 // Copyright (c) 2001 Hursh Jain (http://www.mollypages.org)
002 // The Molly framework is freely distributable under the terms of an
003 // MIT-style license. For details, see the molly pages web site at:
004 // http://www.mollypages.org/. Use, modify, have fun !
005
006 package fc.util;
007
008 import java.io.*;
009 import java.util.*;
010
011 /**
012 Should be implemented for custom code functionality inside a
013 {@link fc.util.Template}. Implementing classes <b>must</b> have
014 a no-arg constructor. It is guaranteed that only one instance
015 of this class will be instantiated by the engine, although
016 multiple threads may possible use this class at the same time.
017
018 @author hursh jain
019 **/
020 public interface CustomCode
021 {
022 /**
023 Called back from the template engine while substiting data inside
024 a template.
025 @param writer can be used to write data at the point in the merged
026 file where the custom code was called. This writer
027 should <b>not</b> be closed, otherwise the template engine
028 will not be able to proceed after this method is invoked (since
029 the template engine also uses the same writer.
030 @param env a reference to the template engine, can be used to
031 invoke methods in the engine.
032 **/
033 public void code(Writer writer, Template env) throws IOException;
034 } //~interface CustomCode