From: <lan...@us...> - 2003-12-23 18:03:59
|
Update of /cvsroot/webmacro/webmacro/src/org/webmacro/util In directory sc8-pr-cvs1:/tmp/cvs-serv24092/src/org/webmacro/util Modified Files: SparseProperties.java WMEval.java Log Message: Upgrades to basic functionality Index: SparseProperties.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/util/SparseProperties.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SparseProperties.java 21 Jul 2003 05:49:48 -0000 1.4 --- SparseProperties.java 23 Dec 2003 18:03:56 -0000 1.5 *************** *** 12,15 **** --- 12,16 ---- import java.util.Properties; + import java.util.Enumeration; /** *************** *** 47,50 **** --- 48,75 ---- super(defaults); this.globalDefault = globalDefault; + } + + public static SparseProperties getTemplate() + { + return getTemplate(null); + } + + public static SparseProperties getTemplate(Properties template) + { + SparseProperties p = null; + if (template == null) + { + p = new SparseProperties(); + } + else + { + p = new SparseProperties(template); + } + Enumeration e = p.keys(); + while (e.hasMoreElements()) + { + p.put(e.nextElement(), null); + } + return p; } Index: WMEval.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/util/WMEval.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** WMEval.java 16 Jul 2003 06:45:00 -0000 1.14 --- WMEval.java 23 Dec 2003 18:03:56 -0000 1.15 *************** *** 322,325 **** --- 322,338 ---- } + /** + * Evaluates the current context for the input file and writes it to the output file. + */ + public String eval (String templateResourceFile, String outputFileName, boolean append) throws Exception + { + Template t = wm.getTemplate(templateResourceFile); + String val = t.evaluateAsString(context); + OutputStream out = new FileOutputStream(outputFileName, append); + out.write(val.getBytes()); + out.close(); + return val; + } + /** |