2006/unicorn/src/org/w3c/unicorn/output OutputModule.java,1.7,1.8 OutputFactory.java,1.6,1.7 SimpleOutputModule.java,1.6,1.7

Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/output
In directory hutz:/tmp/cvs-serv15820/src/org/w3c/unicorn/output

Modified Files:
	OutputModule.java OutputFactory.java SimpleOutputModule.java 
Log Message:
OutputFormaters are now instantiated in OutputModule classes

Index: OutputFactory.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/output/OutputFactory.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- OutputFactory.java	21 Sep 2009 14:38:35 -0000	1.6
+++ OutputFactory.java	23 Sep 2009 09:26:05 -0000	1.7
@@ -4,6 +4,8 @@
 // Please first read the full copyright statement in file COPYRIGHT.html
 package org.w3c.unicorn.output;
 
+import java.util.Map;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.w3c.unicorn.util.Property;
@@ -21,14 +23,19 @@
 
 	/**
 	 * Create a new output module
+	 * @param mapOfSpecificParameter 
 	 * 
 	 * @param aEnumOutputModule
 	 *            To identify which type of output module will be created.
 	 * @return The new output module.
 	 */
-	public static OutputModule createOutputModule(String module) {
-		OutputFactory.logger.trace("createOutputModule");
-		OutputFactory.logger.debug("Output module : " + module);
+	public static OutputModule createOutputModule(Map<String, String> mapOfOutputParameter, Map<String, String> mapOfSpecificParameter) {
+		logger.trace("createOutputModule");
+		logger.debug("Output module : " + mapOfOutputParameter);
+		
+		String format = mapOfOutputParameter.get("format");
+		String lang = mapOfOutputParameter.get("lang"); 
+		String mimeType = mapOfOutputParameter.get("mimetype");
 		
 		/* Commented out for now as this is unnecessary and that doesn't seem quite safe */		
 //		if(null == module || "".equals(module)) {
@@ -42,10 +49,11 @@
 //			moduleClass = Class.forName("org.w3c.unicorn.output." + module + "OutputModule");
 //			return (OutputModule) moduleClass.getConstructor().newInstance();
 //		} catch (Exception e) {
-//			OutputFactory.logger.error("Couldn't create output module " + module + ". Will use SimpleOutputModule", e);
+//			logger.error("Couldn't create output module " + module + ". Will use SimpleOutputModule", e);
 //		}
 
-		return new SimpleOutputModule();
+		return new SimpleOutputModule(mapOfOutputParameter, mapOfSpecificParameter);
+		//return new MailOutputModule(mapOfOutputParameter, mapOfSpecificParameter);
 	}
 
 	/**

Index: OutputModule.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/output/OutputModule.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- OutputModule.java	22 Sep 2009 12:37:28 -0000	1.7
+++ OutputModule.java	23 Sep 2009 09:26:05 -0000	1.8
@@ -18,26 +18,25 @@
 public interface OutputModule {
 
 	public static final Log logger = LogFactory.getLog(OutputModule.class);
-
+	
 	/**
 	 * Generate a first output before the requests are launched.
 	 * 
 	 */
-	public abstract void produceFirstOutput(final OutputFormater aOutputFormater, Map<String, Object> mapOfStringObject,
-			final Map<String, String> mapOfParameter, final Writer aWriter);
+	public abstract void produceFirstOutput(Map<String, Object> mapOfStringObject, final Writer aWriter);
 	
 	/**
 	 * Generate the output of all response.
 	 * 
 	 */
-	public abstract void produceOutput(final OutputFormater aOutputFormater, Map<String, Object> mapOfStringObject,
-			final Map<String, String> mapOfParameter, final Writer aWriter);
+	public abstract void produceOutput(Map<String, Object> mapOfStringObject, final Writer aWriter);
 
 	/**
 	 * Generates an error output
 	 * 
 	 */
-	public abstract void produceError(final OutputFormater aOutputFormater, Map<String, Object> mapOfStringObject,
-			final Map<String, String> mapOfParameter, final Writer aWriter);
+	public abstract void produceError(Map<String, Object> mapOfStringObject, final Writer aWriter);
+
+	public abstract String getOutputParameter(String string);
 
 }

Index: SimpleOutputModule.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/output/SimpleOutputModule.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- SimpleOutputModule.java	22 Sep 2009 12:37:28 -0000	1.6
+++ SimpleOutputModule.java	23 Sep 2009 09:26:05 -0000	1.7
@@ -6,6 +6,7 @@
 
 import java.io.Writer;
 import java.util.Map;
+import org.w3c.unicorn.output.OutputFactory;
 
 /**
  * This module allow to generate output in text format.
@@ -14,20 +15,32 @@
  */
 public class SimpleOutputModule implements OutputModule {
 
-	public void produceOutput(final OutputFormater aOutputFormater, Map<String, Object> mapOfStringObject,
-			final Map<String, String> mapOfParameter, final Writer aWriter) {
+	private  OutputFormater aOutputFormater;
+	
+	private Map<String, String> mapOfOutputParameters;
+	
+	public SimpleOutputModule(Map<String, String> mapOfOutputParameters, Map<String, String> mapOfSpecificParameters) {
+		this.mapOfOutputParameters = mapOfOutputParameters;
+		aOutputFormater = OutputFactory.createOutputFormater(mapOfOutputParameters.get("format"),
+				mapOfOutputParameters.get("lang"), mapOfOutputParameters.get("mimetype"));
+	}
+	
+	public void produceOutput(Map<String, Object> mapOfStringObject, final Writer aWriter) {
 		aOutputFormater.produceOutput(mapOfStringObject, aWriter);
 	}
 
-	public void produceError(final OutputFormater aOutputFormater, Map<String, Object> mapOfStringObject,
-			final Map<String, String> mapOfParameter, final Writer aWriter) {
+	public void produceError(Map<String, Object> mapOfStringObject, final Writer aWriter) {
 		aOutputFormater.produceError(mapOfStringObject, aWriter);
 	}
 
-	public void produceFirstOutput(OutputFormater aOutputFormater,
-			Map<String, Object> mapOfStringObject,
-			Map<String, String> mapOfParameter, Writer aWriter) {
+	public void produceFirstOutput(Map<String, Object> mapOfStringObject, Writer aWriter) {
 		return;
 	}
 
+	public String getOutputParameter(String string) {
+		return mapOfOutputParameters.get(string);
+	}
+	
+	
+
 }

Received on Wednesday, 23 September 2009 09:26:16 UTC