You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by wg...@apache.org on 2005/01/15 08:26:42 UTC

svn commit: r125254 - /jakarta/velocity/trunk/src/java/org/apache/velocity/texen/Generator.java

Author: wglass
Date: Fri Jan 14 23:26:40 2005
New Revision: 125254

URL: http://svn.apache.org/viewcvs?view=rev&rev=125254
Log:
fixed parameter intputEncoding which was causing encoding to be ignored.  http://issues.apache.org/bugzilla/show_bug.cgi?id=32786
Modified:
   jakarta/velocity/trunk/src/java/org/apache/velocity/texen/Generator.java

Modified: jakarta/velocity/trunk/src/java/org/apache/velocity/texen/Generator.java
Url: http://svn.apache.org/viewcvs/jakarta/velocity/trunk/src/java/org/apache/velocity/texen/Generator.java?view=diff&rev=125254&p1=jakarta/velocity/trunk/src/java/org/apache/velocity/texen/Generator.java&r1=125253&p2=jakarta/velocity/trunk/src/java/org/apache/velocity/texen/Generator.java&r2=125254
==============================================================================
--- jakarta/velocity/trunk/src/java/org/apache/velocity/texen/Generator.java	(original)
+++ jakarta/velocity/trunk/src/java/org/apache/velocity/texen/Generator.java	Fri Jan 14 23:26:40 2005
@@ -42,7 +42,7 @@
  *
  * @author <a href="mailto:leon@opticode.co.za">Leon Messerschmidt</a>
  * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
- * @version $Id$ 
+ * @version $Id$
  */
 public class Generator
 {
@@ -50,12 +50,12 @@
      * Where the texen output will placed.
      */
     public static final String OUTPUT_PATH = "output.path";
-    
+
     /**
      * Where the velocity templates live.
      */
     public static final String TEMPLATE_PATH = "template.path";
-    
+
     /**
      * Default properties file used for controlling the
      * tools placed in the context.
@@ -67,7 +67,7 @@
      * Default properties used by texen.
      */
     private Properties props = new Properties();
-    
+
     /**
      * Context used for generating the texen output.
      */
@@ -99,7 +99,7 @@
      * (templates).
      */
     protected String inputEncoding;
-    
+
     /**
      * Velocity engine.
      */
@@ -122,14 +122,14 @@
     {
         return instance;
     }
-    
+
     /**
      * Set the velocity engine.
      */
     public void setVelocityEngine(VelocityEngine ve)
     {
         this.ve = ve;
-    }        
+    }
 
     /**
      * Create a new generator object with properties loaded from
@@ -166,7 +166,7 @@
             setDefaultProps();
         }
     }
-    
+
     /**
      * Create a new Generator object with a given property
      * set. The property set will be duplicated.
@@ -177,7 +177,7 @@
     {
         this.props = (Properties)props.clone();
     }
-    
+
     /**
      * Set default properties.
      */
@@ -191,7 +191,7 @@
             {
                 inputStream = classLoader.getResourceAsStream(
                     DEFAULT_TEXEN_PROPERTIES);
-            
+
                 props.load( inputStream );
             }
             finally
@@ -207,7 +207,7 @@
             System.err.println("Cannot get default properties!");
         }
     }
-    
+
     /**
      * Set the template path, where Texen will look
      * for Velocity templates.
@@ -278,7 +278,7 @@
         if (encoding == null || encoding.length() == 0 || encoding.equals("8859-1") || encoding.equals("8859_1")) {
             writer = new FileWriter(path);
         }
-        else 
+        else
         {
             writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(path), encoding));
         }
@@ -309,13 +309,13 @@
      *
      * @param String input template
      * @param String output file
-     */ 
-    public String parse (String inputTemplate, String outputFile) 
+     */
+    public String parse (String inputTemplate, String outputFile)
         throws Exception
     {
         return parse(inputTemplate, outputFile, null, null);
     }
-    
+
     /**
      * 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
@@ -349,9 +349,9 @@
      * @param String id for object to be placed in the control context
      * @param String object to be placed in the context
      * @return String generated output from velocity
-     */ 
-    public String parse (String inputTemplate, 
-                         String intputEncoding,
+     */
+    public String parse (String inputTemplate,
+                         String inputEncoding,
                          String outputFile,
                          String outputEncoding,
                          String objectID,
@@ -361,10 +361,10 @@
         if (objectID != null && object != null)
         {
             controlContext.put(objectID, object);
-        }            
-        
+        }
+
         Template template = getTemplate(inputTemplate, inputEncoding != null ? inputEncoding : this.inputEncoding);
-        
+
         if (outputFile == null || outputFile.equals(""))
         {
             StringWriter sw = new StringWriter();
@@ -374,7 +374,7 @@
         else
         {
             Writer writer = null;
-            
+
             if (writers.get(outputFile) == null)
             {
                 /*
@@ -385,7 +385,7 @@
                             getOutputPath() + File.separator + outputFile,
                             outputEncoding != null ? outputEncoding : this.outputEncoding
                          );
-                    
+
                 /*
                  * Place the file writer in our collection
                  * of file writers.
@@ -395,14 +395,14 @@
             else
             {
                 writer = (Writer) writers.get(outputFile);
-            }                
-            
+            }
+
             VelocityContext vc = new VelocityContext( controlContext );
             template.merge (vc,writer);
 
             // commented because it is closed in shutdown();
             //fw.close();
-            
+
             return "";
         }
     }
@@ -425,7 +425,7 @@
         Template template = getTemplate(controlTemplate, inputEncoding);
         StringWriter sw = new StringWriter();
         template.merge (controlContext,sw);
-        
+
         return sw.toString();
     }
 
@@ -437,14 +437,14 @@
      *
      * @param Hashtable objects to place in the control context
      * @return Context context filled with objects
-     */ 
+     */
     protected Context getContext (Hashtable objs)
     {
         fillContextHash (controlContext,objs);
         return controlContext;
     }
 
-    /** 
+    /**
      * Add all the contents of a Hashtable to the context.
      *
      * @param Context context to fill with objects
@@ -470,7 +470,7 @@
         context.put ("generator", instance);
         context.put ("outputDirectory", getOutputPath());
     }
-    
+
     /**
      * Add objects to the context from the current properties.
      *
@@ -481,17 +481,17 @@
     protected void fillContextProperties (Context context)
     {
         Enumeration enumeration = props.propertyNames();
-        
+
         while (enumeration.hasMoreElements())
         {
             String nm = (String) enumeration.nextElement();
             if (nm.startsWith ("context.objects."))
             {
-                
+
                 String contextObj = props.getProperty (nm);
                 int colon = nm.lastIndexOf ('.');
                 String contextName = nm.substring (colon+1);
-                
+
                 try
                 {
                     Class cls = Class.forName (contextObj);
@@ -515,11 +515,11 @@
     public void shutdown()
     {
         Iterator iterator = writers.values().iterator();
-        
+
         while(iterator.hasNext())
         {
             Writer writer = (Writer) iterator.next();
-                        
+
             try
             {
                 writer.flush();

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org