You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by jv...@locus.apache.org on 2000/11/04 03:42:13 UTC
cvs commit: jakarta-velocity/src/java/org/apache/velocity/texen Generator.java
jvanzyl 00/11/03 18:42:13
Modified: src/java/org/apache/velocity/texen Generator.java
Log:
- update.
Revision Changes Path
1.4 +6 -30 jakarta-velocity/src/java/org/apache/velocity/texen/Generator.java
Index: Generator.java
===================================================================
RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/texen/Generator.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Generator.java 2000/11/03 15:28:17 1.3
+++ Generator.java 2000/11/04 02:42:12 1.4
@@ -17,7 +17,7 @@
*
* @author <a href="mailto:leon@opticode.co.za">Leon Messerschmidt</a>
* @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
- * @version $Id: Generator.java,v 1.3 2000/11/03 15:28:17 jvanzyl Exp $
+ * @version $Id: Generator.java,v 1.4 2000/11/04 02:42:12 jvanzyl Exp $
*/
public class Generator
{
@@ -135,39 +135,21 @@
* Parse an input and write the output to an output file. If the
* output file parameter is null or an empty string the result is
* returned as a string object. Otherwise an empty string is returned.
- * You can add one object (obj) to the context with the name objName.
+ * You can add objects to the context with the objs Hashtable.
*/
public String parse (String input, String output, String objName, Object obj)
throws Exception
{
- Hashtable h = new Hashtable();
- if (objName != null && obj != null)
- {
- h.put (objName,obj);
- }
- return this.parse (input,output,h);
- }
-
- /**
- * Parse an input and write the output to an output file. If the
- * output file parameter is null or an empty string the result is
- * returned as a string object. Otherwise an empty string is returned.
- * You can add objects to the context with the objs Hashtable.
- */
- public String parse (String input, String output, Hashtable objs)
- throws Exception
- {
- try
- {
- Context context = getContext (objs);
+ if (objName != null && obj != null)
+ controlContext.put(objName, obj);
Template template = Runtime.getTemplate(input);
if (output == null || output.equals(""))
{
StringWriter sw = new StringWriter();
- template.merge (context,sw);
+ template.merge (controlContext,sw);
return sw.toString();
}
else
@@ -175,16 +157,10 @@
FileWriter fw = new FileWriter (props.getProperty (PATH_OUTPUT)+
File.separator +
output);
- template.merge (context,fw);
+ template.merge (controlContext,fw);
fw.close();
return "";
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- return null;
}
}