1 2 import java.io.BufferedWriter ; 3 import java.io.OutputStreamWriter ; 4 import java.io.Writer ; 5 6 import java.util.Hashtable ; 7 import java.util.Vector ; 8 import java.util.Properties ; 9 10 import org.apache.velocity.Template; 11 12 import org.apache.velocity.runtime.Runtime; 13 14 23 24 public class DBContextTest 25 { 26 public DBContextTest(String templateFile) 27 { 28 try 29 { 30 Runtime.init( new Properties () ); 31 32 Template template = Runtime.getTemplate(templateFile); 33 34 DBContext dbc = new DBContext(); 35 36 Hashtable h = new Hashtable (); 37 h.put("Bar", "this is from a hashtable!"); 38 39 dbc.put( "string", "Hello!"); 40 dbc.put( "hashtable", h ); 41 42 Writer writer = new BufferedWriter (new OutputStreamWriter (System.out)); 43 44 template.merge(dbc, writer); 45 46 writer.flush(); 47 writer.close(); 48 } 49 catch( Exception e ) 50 { 51 Runtime.error(e); 52 } 53 } 54 55 public static void main(String [] args) 56 { 57 DBContextTest t; 58 t = new DBContextTest(args[0]); 59 } 60 } 61 | Popular Tags |