- From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
- Date: Thu, 24 Sep 2009 15:28:44 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/output In directory hutz:/tmp/cvs-serv27287/src/org/w3c/unicorn/output Modified Files: OutputModule.java Log Message: OutputModule is now an abstract class + implements displayOnIndex method that replace redirection to index Index: OutputModule.java =================================================================== RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/output/OutputModule.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- OutputModule.java 23 Sep 2009 09:26:05 -0000 1.8 +++ OutputModule.java 24 Sep 2009 15:28:42 -0000 1.9 @@ -4,21 +4,34 @@ // Please first read the full copyright statement in file COPYRIGHT.html package org.w3c.unicorn.output; +import java.io.IOException; import java.io.Writer; import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.velocity.VelocityContext; +import org.w3c.unicorn.util.Language; +import org.w3c.unicorn.util.Templates; /** * Interface for all output module. * * @author Damien LEROY */ -public interface OutputModule { - +public abstract class OutputModule { + + protected Map<String, String> outputParameters; + + protected Map<String, String> specificParameters; + public static final Log logger = LogFactory.getLog(OutputModule.class); + public OutputModule(Map<String, String> mapOfOutputParameters, Map<String, String> mapOfSpecificParameters) { + this.outputParameters = mapOfOutputParameters; + this.specificParameters = mapOfSpecificParameters; + } + /** * Generate a first output before the requests are launched. * @@ -37,6 +50,30 @@ */ public abstract void produceError(Map<String, Object> mapOfStringObject, final Writer aWriter); - public abstract String getOutputParameter(String string); + protected void displayOnIndex(Map<String, Object> mapOfStringObject, Writer writer) { + VelocityContext context = new VelocityContext(Language.getContext(outputParameters.get("lang"))); + + for (final String sObjectName : mapOfStringObject.keySet()) + context.put(sObjectName, mapOfStringObject.get(sObjectName)); + + Templates.write("index.vm", context, writer); + try { + writer.close(); + } catch (IOException e) { + logger.error("Error closing output writer: " + e.getMessage(), e); + } + } + + public String getOutputParameter(String string) { + return outputParameters.get(string); + } + + public Map<String, String> getOutputParameters() { + return outputParameters; + } + public void setOutputParameters(Map<String, String> mapOfOutputParameters) { + this.outputParameters = mapOfOutputParameters; + } + }
Received on Thursday, 24 September 2009 15:28:53 UTC