- From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
- Date: Fri, 07 Aug 2009 12:03:44 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/output
In directory hutz:/tmp/cvs-serv7256/src/org/w3c/unicorn/output
Modified Files:
Tag: dev2
Output.java
Log Message:
new libs
bypassed controller
implemented some language properties
Index: Output.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/output/Attic/Output.java,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -d -r1.1.2.3 -r1.1.2.4
--- Output.java 6 Aug 2009 12:46:58 -0000 1.1.2.3
+++ Output.java 7 Aug 2009 12:03:42 -0000 1.1.2.4
@@ -1,5 +1,61 @@
package org.w3c.unicorn.output;
+import java.io.File;
+import java.io.IOException;
+import java.io.Writer;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.Properties;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.Velocity;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.exception.ParseErrorException;
+import org.apache.velocity.exception.ResourceNotFoundException;
+import org.w3c.unicorn.util.Property;
+
public class Output {
+ private static VelocityContext context = new VelocityContext();
+ private static VelocityEngine engine = new VelocityEngine();
+ static {
+ Properties aProperties = new Properties();
+
+ try {
+ aProperties.load(
+ (new File(Property.get("PATH_TO_CONF_FILES") + Property.get("VELOCITY_PROPERTIES"))).toURI().toURL().openStream()
+ //Property.getPropertyFileURL("velocity.properties").openStream()
+ );
+
+ aProperties.put(Velocity.FILE_RESOURCE_LOADER_PATH, Property
+ .get("PATH_TO_TEMPLATES"));
+
+ engine.init(aProperties);
+ } catch (MalformedURLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ public static void write(ArrayList<String> templateList,
+ VelocityContext velocityContext, HttpServletResponse resp) throws ResourceNotFoundException, ParseErrorException, Exception {
+ Writer writer = resp.getWriter();
+
+ for (String templateString : templateList) {
+ Template template = engine.getTemplate(templateString, "UTF-8");
+ template.merge(velocityContext, writer);
+ }
+
+ writer.close();
+
+ }
+
}
Received on Friday, 7 August 2009 12:03:53 UTC