You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by tf...@apache.org on 2012/10/24 23:13:10 UTC

svn commit: r1401885 - in /db/torque/torque4/trunk: torque-ant-tasks/src/main/java/org/apache/torque/ant/task/ torque-generator/src/main/java/org/apache/torque/generator/configuration/ torque-generator/src/main/java/org/apache/torque/generator/configur...

Author: tfischer
Date: Wed Oct 24 21:13:09 2012
New Revision: 1401885

URL: http://svn.apache.org/viewvc?rev=1401885&view=rev
Log:
TORQUE-239: Create debug output to determine where a output snippet came from 

Added:
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/HtmlOutputType.java
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/JavaOutputType.java
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/OutputType.java
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/OutputTypeHelper.java
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/PropertiesOutputType.java
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/UnknownOutputType.java
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/XmlOutputType.java
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/DebuggingOutletWrapper.java
    db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/expectedProperties.properties
    db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/expectedPropertiesDebugOutput.properties
    db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/package.html
Modified:
    db/torque/torque4/trunk/torque-ant-tasks/src/main/java/org/apache/torque/ant/task/TorqueGeneratorTask.java
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/ConfigurationHandlers.java
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/UnitConfiguration.java
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/UnitConfigurationReader.java
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/UnitDescriptor.java
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/controller/Output.java
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/controller/OutputConfigurationTags.java
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/controller/OutputSaxHandler.java
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/OutletConfiguration.java
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/OutletConfigurationXmlParser.java
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/Outlet.java
    db/torque/torque4/trunk/torque-generator/src/main/resources/org/apache/torque/generator/configuration/configuration.xsd
    db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/outlet/OutletConfigurationTest.java
    db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/control/PropertyToJavaGenerationTest.java
    db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/src/main/torque-gen/conf/control.xml
    db/torque/torque4/trunk/torque-maven-plugin/src/main/java/org/apache/torque/generator/maven/TorqueGeneratorMojo.java
    db/torque/torque4/trunk/torque-site/src/site/xdoc/documentation/modules/generator/reference/configuration.xml

Modified: db/torque/torque4/trunk/torque-ant-tasks/src/main/java/org/apache/torque/ant/task/TorqueGeneratorTask.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-ant-tasks/src/main/java/org/apache/torque/ant/task/TorqueGeneratorTask.java?rev=1401885&r1=1401884&r2=1401885&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-ant-tasks/src/main/java/org/apache/torque/ant/task/TorqueGeneratorTask.java (original)
+++ db/torque/torque4/trunk/torque-ant-tasks/src/main/java/org/apache/torque/ant/task/TorqueGeneratorTask.java Wed Oct 24 21:13:09 2012
@@ -134,6 +134,11 @@ public class TorqueGeneratorTask extends
     private String loglevel;
 
     /**
+     * Whether to add debug information to the output.
+     */
+    private boolean addDebuggingInfoToOutput = false;
+
+    /**
      * The encoding which should be used for the files which do not have an
      * output encoding set in the templates.
      */
@@ -328,6 +333,7 @@ public class TorqueGeneratorTask extends
         unitDescriptor.setOverrideSourceProvider(fileSourceProvider);
         unitDescriptor.setOverrideOptions(optionConfiguration);
         unitDescriptor.setLoglevel(convertedLoglevel);
+        unitDescriptor.setAddDebuggingInfoToOutput(addDebuggingInfoToOutput);
         unitDescriptor.setDefaultOutputEncoding(defaultOutputEncoding);
         log("unit descriptor created", Project.MSG_DEBUG);
         if (overrideConfigDir != null)
@@ -483,6 +489,17 @@ public class TorqueGeneratorTask extends
     }
 
     /**
+     * Sets whether debugging information should be added to the output.
+     *
+     * @param addDebuggingInfoToOutput true if debugging information
+     *        should be added to the output, false otherwise.
+     */
+    public void setAddDebuggingInfoToOutput(boolean addDebuggingInfoToOutput)
+    {
+        this.addDebuggingInfoToOutput = addDebuggingInfoToOutput;
+    }
+
+    /**
      * Sets the encoding which should be used for the files which do not have
      * an output encoding set in the templates.
      *

Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/ConfigurationHandlers.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/ConfigurationHandlers.java?rev=1401885&r1=1401884&r2=1401885&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/ConfigurationHandlers.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/ConfigurationHandlers.java Wed Oct 24 21:13:09 2012
@@ -19,12 +19,20 @@ package org.apache.torque.generator.conf
  * under the License.
  */
 
+import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Map;
 import java.util.Set;
 
 import org.apache.torque.generator.configuration.mergepoint.ActionSaxHandlerFactories;
 import org.apache.torque.generator.configuration.mergepoint.OptionsSaxHandlerFactories;
 import org.apache.torque.generator.configuration.source.SourceSaxHandlerFactories;
+import org.apache.torque.generator.control.outputtype.HtmlOutputType;
+import org.apache.torque.generator.control.outputtype.JavaOutputType;
+import org.apache.torque.generator.control.outputtype.OutputType;
+import org.apache.torque.generator.control.outputtype.PropertiesOutputType;
+import org.apache.torque.generator.control.outputtype.UnknownOutputType;
+import org.apache.torque.generator.control.outputtype.XmlOutputType;
 import org.apache.torque.generator.source.stream.PropertiesSourceFormat;
 import org.apache.torque.generator.source.stream.StreamSourceFormat;
 import org.apache.torque.generator.source.stream.XmlSourceFormat;
@@ -42,6 +50,12 @@ public class ConfigurationHandlers
     private OutletTypes outletTypes = new OutletTypes();
 
     /**
+     * The known types of outputs.
+     */
+    private Map<String, OutputType> outputTypes
+            = new HashMap<String, OutputType>();
+
+    /**
      * The known (file) formats of stream sources (e.g. XML, properties).
      */
     private Set<StreamSourceFormat> streamSourceFormats
@@ -72,7 +86,12 @@ public class ConfigurationHandlers
     {
         streamSourceFormats.add(new XmlSourceFormat());
         streamSourceFormats.add(new PropertiesSourceFormat());
-    }
+        outputTypes.put(UnknownOutputType.KEY, new UnknownOutputType());
+        outputTypes.put(JavaOutputType.KEY, new JavaOutputType());
+        outputTypes.put(XmlOutputType.KEY, new XmlOutputType());
+        outputTypes.put(HtmlOutputType.KEY, new HtmlOutputType());
+        outputTypes.put(PropertiesOutputType.KEY, new PropertiesOutputType());
+   }
 
     /**
      * Returns the known outlet types.
@@ -85,6 +104,16 @@ public class ConfigurationHandlers
     }
 
     /**
+     * Returns the known output types.
+     *
+     * @return the known outlet types, not null.
+     */
+    public Map<String, OutputType> getOutputTypes()
+    {
+        return outputTypes;
+    }
+
+    /**
      * Returns the known source configuration handlers.
      *
      * @return the known source configuration handlers, not mull.

Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/UnitConfiguration.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/UnitConfiguration.java?rev=1401885&r1=1401884&r2=1401885&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/UnitConfiguration.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/UnitConfiguration.java Wed Oct 24 21:13:09 2012
@@ -75,6 +75,9 @@ public class UnitConfiguration
     /** The Loglevel for generation. */
     private Loglevel loglevel = Loglevel.INFO;
 
+    /** Whether to add debug information to the output. */
+    private boolean addDebuggingInfoToOutput = false;
+
     /**
      * The output encoding if no specific encoding has been set in the output;
      * null for the default platform encoding.
@@ -324,6 +327,27 @@ public class UnitConfiguration
     }
 
     /**
+     * Returns whether to add debug information to the output.
+     *
+     * @return true if debug information should be added, false otherwise.
+     */
+    public boolean isAddDebuggingInfoToOutput()
+    {
+        return addDebuggingInfoToOutput;
+    }
+
+    /**
+     * Sets whether to add debug information to the output.
+     *
+     * @param addDebuggingInfoToOutput true if debug information should be
+     *        added, false otherwise.
+     */
+    public void setAddDebuggingInfoToOutput(boolean addDebuggingInfoToOutput)
+    {
+        this.addDebuggingInfoToOutput = addDebuggingInfoToOutput;
+    }
+
+    /**
      * Returns the configuration handlers used to parse the configuration
      * of this generation unit.
      *

Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/UnitConfigurationReader.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/UnitConfigurationReader.java?rev=1401885&r1=1401884&r2=1401885&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/UnitConfigurationReader.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/UnitConfigurationReader.java Wed Oct 24 21:13:09 2012
@@ -113,8 +113,8 @@ class UnitConfigurationReader
                     = new OutletConfigurationXmlParser()
                         .readOutletConfiguration(
                                 configurationProvider,
-                                unitDescriptor.getProjectPaths(),
-                                configurationHandlers);
+                                configurationHandlers,
+                                unitDescriptor);
             unitConfiguration.setOutletConfiguration(outletConfiguration);
         }
 
@@ -140,7 +140,10 @@ class UnitConfigurationReader
         // Restore this loglevel.
         unitConfiguration.getLoglevel().apply();
 
-        mergeInheritedOutletConfiguration(unitConfiguration, inherited);
+        mergeInheritedOutletConfiguration(
+                unitDescriptor,
+                unitConfiguration,
+                inherited);
         mergeInheritedOptionConfiguration(unitConfiguration, inherited);
         mergeInheritedOutputFiles(unitConfiguration, inherited);
         mergeInheritedEntityRefernces(unitConfiguration, inherited);
@@ -260,13 +263,15 @@ class UnitConfigurationReader
      * Merges an inherited outlet configuration into the outlet
      * configuration of the current unit configuration.
      *
-     * @param unitConfiguration the current unit configuration
+     *@param unitDescriptor the descriptor of the current generation unit.
+     * @param unitConfiguration the current unit configuration.
      * @param inheritedConfiguration the inherited unit configuration
      *        which outlets should be merged.
      *
      * @throws ConfigurationException will not normally happen.
      */
     private void mergeInheritedOutletConfiguration(
+                UnitDescriptor unitDescriptor,
                 UnitConfiguration unitConfiguration,
                 UnitConfiguration inheritedConfiguration)
             throws ConfigurationException
@@ -284,7 +289,9 @@ class UnitConfigurationReader
         {
             if (!outletConfiguration.outletExists(entry.getKey()))
             {
-                outletConfiguration.addOutlet(entry.getValue());
+                outletConfiguration.addOutlet(
+                        entry.getValue(),
+                        unitDescriptor);
             }
         }
         outletConfiguration.resolveMergepointMappings();

Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/UnitDescriptor.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/UnitDescriptor.java?rev=1401885&r1=1401884&r2=1401885&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/UnitDescriptor.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/UnitDescriptor.java Wed Oct 24 21:13:09 2012
@@ -75,6 +75,9 @@ public class UnitDescriptor
      */
     private Loglevel loglevel;
 
+    /** Whether to add debug information to the output. */
+    private boolean addDebuggingInfoToOutput = false;
+
     /**
      * The output encoding if no specific encoding has been set in the output;
      * null for the default platform encoding.
@@ -82,8 +85,8 @@ public class UnitDescriptor
     private String defaultOutputEncoding = null;
 
     /**
-     * Constructor without inheritance, override options, overrideSourceFileset
-     * and loglevel.
+     * Constructor without inheritance, override options, overrideSourceFileset,
+     * loglevel and addDebuggingInfoToOutput.
      *
      * @param packaging The packaging of the generation unit, not null.
      * @param projectPaths The paths the Torque generator must know about
@@ -239,6 +242,28 @@ public class UnitDescriptor
     }
 
     /**
+     * Returns whether debugging info should be added to the output.
+     *
+     * @return true if debugging info should be added to the output,
+     *         false if not.
+     */
+    public boolean isAddDebuggingInfoToOutput()
+    {
+        return addDebuggingInfoToOutput;
+    }
+
+    /**
+     * Sets whether debugging info should be added to the output.
+     *
+     * @param addDebuggingInfoToOutput true if debugging info should be added
+     *        to the output, false if not.
+     */
+    public void setAddDebuggingInfoToOutput(boolean addDebuggingInfoToOutput)
+    {
+        this.addDebuggingInfoToOutput = addDebuggingInfoToOutput;
+    }
+
+    /**
      * Returns the output encoding if no specific encoding has been set
      * in the output.
      *

Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/controller/Output.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/controller/Output.java?rev=1401885&r1=1401884&r2=1401885&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/controller/Output.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/controller/Output.java Wed Oct 24 21:13:09 2012
@@ -19,7 +19,9 @@ package org.apache.torque.generator.conf
  * under the License.
  */
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.torque.generator.control.existingtargetstrategy.ReplaceTargetFileStrategy;
+import org.apache.torque.generator.control.outputtype.UnknownOutputType;
 import org.apache.torque.generator.outlet.Outlet;
 import org.apache.torque.generator.qname.QualifiedName;
 import org.apache.torque.generator.source.SourceProcessConfiguration;
@@ -30,6 +32,15 @@ import org.apache.torque.generator.sourc
  */
 public class Output
 {
+    /** Constant for the Carriage return String. */
+    private static final String CARRIAGE_RETURN = "\r";
+
+    /** Constant for the Line feed String. */
+    private static final String LINE_FEED = "\n";
+
+    /** Constant for the Carriage return + Line feed String. */
+    private static final String CARRIAGE_RETURN_LINE_FEED = "\r\n";
+
     /**
      * The name by which this output can be identified.
      */
@@ -71,6 +82,18 @@ public class Output
             = ReplaceTargetFileStrategy.STRATEGY_NAME;
 
     /**
+     * The type of the generated output, e.g. java, xml, html.
+     * default is unknown.
+     */
+    private String type = UnknownOutputType.KEY;
+
+    /**
+     * The file's line break character(s), determined from the already
+     * generated output.
+     */
+    private String lineBreak;
+
+    /**
      * The key for the output directory into which the output is written,
      * or null for the default output directory.
      */
@@ -284,6 +307,79 @@ public class Output
     }
 
     /**
+     * Sets the type of the produced output, e.g. java, xml.
+     *
+     * @param type the type, not null.
+     *
+     * @throws NullPointerException if type is null.
+     */
+    public void setType(String type)
+    {
+        if (type == null)
+        {
+            throw new NullPointerException("type must not be null");
+        }
+        this.type = type;
+    }
+
+    /**
+     * Returns the type of the produced output, e.g. java, xml.
+     *
+     * @return the type, not null.
+     */
+    public String getType()
+    {
+        return type;
+    }
+
+    /**
+     * Returns the line break character(s) for this Output.
+     * If the line break was already determined, the already determined
+     * line break character(s) are returned, and content is ignored.
+     * If the line break character was not already determined,
+     * the occurence of the different line break characters is counted
+     * and the largest is returned ("\r\n" for equal count)
+     * If one of them is > 0, the result is cached and stored;
+     * if all occurences are 0, the result is not cached and will be determined
+     * anew if the method is called another time for the same output.
+     *
+     * @param content the already produced content.
+     * @return the line break character(s), one of "\r", "\n", "\r\n".
+     */
+    public String getOrDetermineLineBreak(String content)
+    {
+        if (lineBreak != null)
+        {
+            return lineBreak;
+        }
+        String contentString = content.toString();
+        int r = StringUtils.countMatches(contentString, CARRIAGE_RETURN);
+        int n = StringUtils.countMatches(contentString, LINE_FEED);
+        int rn = StringUtils.countMatches(
+                contentString,
+                CARRIAGE_RETURN_LINE_FEED);
+        // r and n are contained within rn
+        if ((rn >= r - rn) || (rn >= n - rn))
+        {
+            if (rn > 0)
+            {
+                this.lineBreak = CARRIAGE_RETURN_LINE_FEED;
+            }
+            return CARRIAGE_RETURN_LINE_FEED;
+        }
+        else if (n > r)
+        {
+            this.lineBreak = LINE_FEED;
+            return LINE_FEED;
+        }
+        else
+        {
+            this.lineBreak = CARRIAGE_RETURN;
+            return CARRIAGE_RETURN;
+        }
+    }
+
+    /**
      * {@inheritDoc}
      */
     @Override
@@ -298,7 +394,10 @@ public class Output
                 .append(",filenameOutlet=")
                 .append(filenameOutlet)
                 .append(",contentOutlet=")
-                .append(contentOutlet).append(")");
+                .append(contentOutlet)
+                .append(",type=")
+                .append(type)
+                .append(")");
         return result.toString();
     }
 }

Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/controller/OutputConfigurationTags.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/controller/OutputConfigurationTags.java?rev=1401885&r1=1401884&r2=1401885&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/controller/OutputConfigurationTags.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/controller/OutputConfigurationTags.java Wed Oct 24 21:13:09 2012
@@ -51,6 +51,9 @@ public final class OutputConfigurationTa
     /** Attribute name for the "encoding" attribute. */
     public static final String ENCODING_ATTRIBUTE = "encoding";
 
+    /** Attribute name for the "type" attribute. */
+    public static final String TYPE_ATTRIBUTE = "type";
+
     /** Tag name for the "outlet" tag. */
     public static final String OUTLET_TAG = "outlet";
 

Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/controller/OutputSaxHandler.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/controller/OutputSaxHandler.java?rev=1401885&r1=1401884&r2=1401885&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/controller/OutputSaxHandler.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/controller/OutputSaxHandler.java Wed Oct 24 21:13:09 2012
@@ -22,11 +22,12 @@ package org.apache.torque.generator.conf
 import static org.apache.torque.generator.configuration.controller.OutputConfigurationTags.ENCODING_ATTRIBUTE;
 import static org.apache.torque.generator.configuration.controller.OutputConfigurationTags.EXISTING_TARGET_STRATEGY_ATTRIBUTE;
 import static org.apache.torque.generator.configuration.controller.OutputConfigurationTags.FILENAME_GENERATOR_TAG;
+import static org.apache.torque.generator.configuration.controller.OutputConfigurationTags.FILE_ATTRIBUTE;
 import static org.apache.torque.generator.configuration.controller.OutputConfigurationTags.NAME_ATTRIBUTE;
 import static org.apache.torque.generator.configuration.controller.OutputConfigurationTags.OUTLET_TAG;
-import static org.apache.torque.generator.configuration.controller.OutputConfigurationTags.OUTPUT_TAG;
-import static org.apache.torque.generator.configuration.controller.OutputConfigurationTags.FILE_ATTRIBUTE;
 import static org.apache.torque.generator.configuration.controller.OutputConfigurationTags.OUTPUT_DIR_KEY_ATTRIBUTE;
+import static org.apache.torque.generator.configuration.controller.OutputConfigurationTags.OUTPUT_TAG;
+import static org.apache.torque.generator.configuration.controller.OutputConfigurationTags.TYPE_ATTRIBUTE;
 import static org.apache.torque.generator.configuration.outlet.OutletConfigurationTags.INPUT_TAG;
 import static org.apache.torque.generator.configuration.source.SourceConfigurationTags.SOURCE_TAG;
 
@@ -39,6 +40,7 @@ import org.apache.torque.generator.confi
 import org.apache.torque.generator.configuration.source.SourceSaxHandler;
 import org.apache.torque.generator.configuration.source.SourceSaxHandlerFactories;
 import org.apache.torque.generator.configuration.source.SourceSaxHandlerFactory;
+import org.apache.torque.generator.control.outputtype.UnknownOutputType;
 import org.apache.torque.generator.qname.QualifiedName;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
@@ -196,6 +198,14 @@ public class OutputSaxHandler extends De
             {
                 output.setEncoding(attributes.getValue(ENCODING_ATTRIBUTE));
             }
+            if (attributes.getValue(TYPE_ATTRIBUTE) != null)
+            {
+                output.setType(attributes.getValue(TYPE_ATTRIBUTE));
+            }
+            else
+            {
+                output.setType(UnknownOutputType.KEY);
+            }
         }
         else if (SOURCE_TAG.equals(rawName))
         {

Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/OutletConfiguration.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/OutletConfiguration.java?rev=1401885&r1=1401884&r2=1401885&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/OutletConfiguration.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/OutletConfiguration.java Wed Oct 24 21:13:09 2012
@@ -25,7 +25,9 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.torque.generator.configuration.ConfigurationException;
+import org.apache.torque.generator.configuration.UnitDescriptor;
 import org.apache.torque.generator.configuration.mergepoint.MergepointMapping;
+import org.apache.torque.generator.outlet.DebuggingOutletWrapper;
 import org.apache.torque.generator.outlet.Outlet;
 import org.apache.torque.generator.qname.QualifiedName;
 
@@ -53,13 +55,18 @@ public class OutletConfiguration
      * Creates a OutletConfiguration containing a list of Outlets.
      *
      * @param outlets the list of outlets, not null.
+     * @param mergepointMappings all isolated mergepoint mappings, not null.
+     * @param unitDescriptor the descriptor of the unit of generation,
+     *        not null.
      *
      * @throws ConfigurationException if outlets contains
      *         two outlets with the same name.
-     * @throws NullPointerException if outlets is null.
+     * @throws NullPointerException if a parameter is null.
      */
-    public OutletConfiguration(Collection<Outlet> outlets,
-                Collection<MergepointMapping> mergepointMappings)
+    public OutletConfiguration(
+                Collection<Outlet> outlets,
+                Collection<MergepointMapping> mergepointMappings,
+                UnitDescriptor unitDescriptor)
             throws ConfigurationException
     {
         if (outlets == null)
@@ -71,9 +78,14 @@ public class OutletConfiguration
             throw new NullPointerException(
                     "mergepointMappings must not be null");
         }
+        if (unitDescriptor == null)
+        {
+            throw new NullPointerException(
+                    "unitDescriptor must not be null");
+        }
         for (Outlet outlet : outlets)
         {
-            addOutlet(outlet);
+            addOutlet(outlet, unitDescriptor);
         }
         for (MergepointMapping mergepointMapping : mergepointMappings)
         {
@@ -172,18 +184,25 @@ public class OutletConfiguration
      * Adds a outlet.
      *
      * @param outlet the outlet to be added, not null.
+     * @param unitDescriptor the descriptor of the generation unit,
+     *        not null.
      *
      * @throws ConfigurationException if a outlet with the outlet's name
      *         already exists in the configuration.
      * @throws NullPointerException if outlet is null.
      */
-    public void addOutlet(Outlet outlet)
+    public void addOutlet(Outlet outlet, UnitDescriptor unitDescriptor)
         throws ConfigurationException
     {
         if (outlet == null)
         {
             throw new NullPointerException("outlet must not be null");
         }
+        if (unitDescriptor == null)
+        {
+            throw new NullPointerException(
+                    "unitDescriptor must not be null");
+        }
         Outlet existingOutlet = outlets.get(outlet.getName());
         if (existingOutlet != null)
         {
@@ -195,6 +214,10 @@ public class OutletConfiguration
                     + " already exists, it has the class "
                     + existingOutlet.getClass().getName());
         }
+        if (unitDescriptor.isAddDebuggingInfoToOutput())
+        {
+            outlet = new DebuggingOutletWrapper(outlet);
+        }
         outlets.put(outlet.getName(), outlet);
     }
 

Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/OutletConfigurationXmlParser.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/OutletConfigurationXmlParser.java?rev=1401885&r1=1401884&r2=1401885&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/OutletConfigurationXmlParser.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/OutletConfigurationXmlParser.java Wed Oct 24 21:13:09 2012
@@ -34,6 +34,7 @@ import org.apache.commons.logging.LogFac
 import org.apache.torque.generator.configuration.ConfigurationException;
 import org.apache.torque.generator.configuration.ConfigurationHandlers;
 import org.apache.torque.generator.configuration.ConfigurationProvider;
+import org.apache.torque.generator.configuration.UnitDescriptor;
 import org.apache.torque.generator.configuration.mergepoint.MergepointMapping;
 import org.apache.torque.generator.configuration.paths.ProjectPaths;
 import org.apache.torque.generator.outlet.Outlet;
@@ -95,6 +96,7 @@ public class OutletConfigurationXmlParse
      *        files, not null.
      * @param projectPaths The paths of the surrounding project, not null.
      * @param outletTypes the configured types of outlets, not null.
+     * @param unitDescriptor the unit descriptor, not null.
      *
      * @return the outlet configuration.
      *
@@ -103,8 +105,8 @@ public class OutletConfigurationXmlParse
      */
     public OutletConfiguration readOutletConfiguration(
             ConfigurationProvider configurationProvider,
-            ProjectPaths projectPaths,
-            ConfigurationHandlers configurationHandlers)
+            ConfigurationHandlers configurationHandlers,
+            UnitDescriptor unitDescriptor)
         throws ConfigurationException
     {
         if (configurationHandlers == null)
@@ -119,12 +121,6 @@ public class OutletConfigurationXmlParse
                     + " configurationProvider is null");
             throw new NullPointerException("configurationProvider is null");
         }
-        if (projectPaths == null)
-        {
-            log.error("OutletConfiguration: "
-                    + " projectPaths is null");
-            throw new NullPointerException("projectPaths is null");
-        }
 
         List<Outlet> allOutlets = new ArrayList<Outlet>();
         List<MergepointMapping> allMergepointMappings
@@ -146,7 +142,7 @@ public class OutletConfigurationXmlParse
                         = readOutletConfig(
                                 inputStream,
                                 configurationProvider,
-                                projectPaths,
+                                unitDescriptor.getProjectPaths(),
                                 configurationHandlers);
                 allOutlets.addAll(fileContent.getOutlets());
                 allMergepointMappings.addAll(
@@ -191,7 +187,10 @@ public class OutletConfigurationXmlParse
                 }
             }
         }
-        return new OutletConfiguration(allOutlets, allMergepointMappings);
+        return new OutletConfiguration(
+                allOutlets,
+                allMergepointMappings,
+                unitDescriptor);
     }
 
 

Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/HtmlOutputType.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/HtmlOutputType.java?rev=1401885&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/HtmlOutputType.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/HtmlOutputType.java Wed Oct 24 21:13:09 2012
@@ -0,0 +1,45 @@
+package org.apache.torque.generator.control.outputtype;
+
+
+/**
+ * The output type for HTML output.
+ *
+ * @version $Id: $
+ */
+public class HtmlOutputType implements OutputType
+{
+    /** The unique key of the output type. */
+    public static final String KEY = "html";
+
+    /** The start of a comment. */
+    private static final String COMMENT_START = "<!-- ";
+
+    /** The end of a comment. */
+    private static final String COMMENT_END = " -->";
+
+    /**
+     * Returns the start of a comment.
+     * It is assumed that the comment itself does not contain line breaks.
+     *
+     * @param lineBreak the line break for the current output, not null.
+     *
+     * @return the String which starts a comment, not null.
+     */
+    public String getCommentStart(String lineBreak)
+    {
+        return COMMENT_START;
+    }
+
+    /**
+     * Returns the end of a comment.
+     * It is assumed that the comment itself does not contain line breaks.
+     *
+     * @param lineBreak the line break for the current output, not null.
+     *
+     * @return the String which starts a comment, not null.
+     */
+    public String getCommentEnd(String lineBreak)
+    {
+        return COMMENT_END + lineBreak;
+    }
+}

Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/JavaOutputType.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/JavaOutputType.java?rev=1401885&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/JavaOutputType.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/JavaOutputType.java Wed Oct 24 21:13:09 2012
@@ -0,0 +1,42 @@
+package org.apache.torque.generator.control.outputtype;
+
+
+/**
+ * The output type for java output.
+ *
+ * @version $Id: $
+ */
+public class JavaOutputType implements OutputType
+{
+    /** The unique key of the output type. */
+    public static final String KEY = "java";
+
+    /** The start of a comment. */
+    private static final String COMMENT_START = "// ";
+
+    /**
+     * Returns the start of a comment.
+     * It is assumed that the comment itself does not contain line breaks.
+     *
+     * @param lineBreak the line break for the current output, not null.
+     *
+     * @return the String which starts a comment, not null.
+     */
+    public String getCommentStart(String lineBreak)
+    {
+        return COMMENT_START;
+    }
+
+    /**
+     * Returns the end of a comment.
+     * It is assumed that the comment itself does not contain line breaks.
+     *
+     * @param lineBreak the line break for the current output, not null.
+     *
+     * @return the String which starts a comment, not null.
+     */
+    public String getCommentEnd(String lineBreak)
+    {
+        return lineBreak;
+    }
+}

Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/OutputType.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/OutputType.java?rev=1401885&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/OutputType.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/OutputType.java Wed Oct 24 21:13:09 2012
@@ -0,0 +1,30 @@
+package org.apache.torque.generator.control.outputtype;
+
+
+/**
+ * An interface describing the type of output produced by the generator.
+ *
+ * @version $Id: $
+ */
+public interface OutputType
+{
+    /**
+     * Returns the start of a comment.
+     * It is assumed that the comment itself does not contain line breaks.
+     *
+     * @param lineBreak the line break for the current output, not null.
+     *
+     * @return the String which starts a comment, not null.
+     */
+    String getCommentStart(String lineBreak);
+
+    /**
+     * Returns the end of a comment.
+     * It is assumed that the comment itself does not contain line breaks.
+     *
+     * @param lineBreak the line break for the current output, not null.
+     *
+     * @return the String which ends a comment, not null.
+     */
+    String getCommentEnd(String lineBreak);
+}

Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/OutputTypeHelper.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/OutputTypeHelper.java?rev=1401885&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/OutputTypeHelper.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/OutputTypeHelper.java Wed Oct 24 21:13:09 2012
@@ -0,0 +1,37 @@
+package org.apache.torque.generator.control.outputtype;
+
+import org.apache.commons.lang.StringUtils;
+
+/**
+ * Helper class for output types.
+ *
+ * @version $Id: $
+ */
+public class OutputTypeHelper
+{
+    /**
+     * Returns the line break character from already produced output.
+     *
+     * @param content the already produced content.
+     * @return the line break character(s), one of "\r", "\n", "\r\n".
+     */
+    public static String determineLineBreak(StringBuilder content)
+    {
+        String contentString = content.toString();
+        int r = StringUtils.countMatches(contentString, "\r");
+        int n = StringUtils.countMatches(contentString, "\n");
+        int rn = StringUtils.countMatches(contentString, "\r\n");
+        if (!(r > rn) && !(n > rn))
+        {
+            return "\r\n";
+        }
+        else if (n > r)
+        {
+            return "\n";
+        }
+        else
+        {
+            return "\r";
+        }
+    }
+}

Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/PropertiesOutputType.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/PropertiesOutputType.java?rev=1401885&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/PropertiesOutputType.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/PropertiesOutputType.java Wed Oct 24 21:13:09 2012
@@ -0,0 +1,42 @@
+package org.apache.torque.generator.control.outputtype;
+
+
+/**
+ * The output type for properties output.
+ *
+ * @version $Id: $
+ */
+public class PropertiesOutputType implements OutputType
+{
+    /** The unique key of the output type. */
+    public static final String KEY = "properties";
+
+    /** The start of a comment. */
+    private static final String COMMENT_START = "# ";
+
+    /**
+     * Returns the start of a comment.
+     * It is assumed that the comment itself does not contain line breaks.
+     *
+     * @param lineBreak the line break for the current output, not null.
+     *
+     * @return the String which starts a comment, not null.
+     */
+    public String getCommentStart(String lineBreak)
+    {
+        return COMMENT_START;
+    }
+
+    /**
+     * Returns the end of a comment.
+     * It is assumed that the comment itself does not contain line breaks.
+     *
+     * @param lineBreak the line break for the current output, not null.
+     *
+     * @return the String which starts a comment, not null.
+     */
+    public String getCommentEnd(String lineBreak)
+    {
+        return lineBreak;
+    }
+}

Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/UnknownOutputType.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/UnknownOutputType.java?rev=1401885&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/UnknownOutputType.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/UnknownOutputType.java Wed Oct 24 21:13:09 2012
@@ -0,0 +1,45 @@
+package org.apache.torque.generator.control.outputtype;
+
+
+/**
+ * An output type which is used if no other output type is defined.
+ *
+ * @version $Id: $
+ */
+public class UnknownOutputType implements OutputType
+{
+    /** The unique key of the output type. */
+    public static final String KEY = "unknown";
+
+    /** The start of a comment. */
+    private static final String COMMENT_START = "----- ";
+
+    /** The end of a comment. */
+    private static final String COMMENT_END = " -----";
+
+    /**
+     * Returns the start of a comment.
+     * It is assumed that the comment itself does not contain line breaks.
+     *
+     * @param lineBreak the line break for the current output, not null.
+     *
+     * @return the String which starts a comment, not null.
+     */
+    public String getCommentStart(String lineBreak)
+    {
+        return COMMENT_START;
+    }
+
+    /**
+     * Returns the end of a comment.
+     * It is assumed that the comment itself does not contain line breaks.
+     *
+     * @param lineBreak the line break for the current output, not null.
+     *
+     * @return the String which starts a comment, not null.
+     */
+    public String getCommentEnd(String lineBreak)
+    {
+        return COMMENT_END + lineBreak;
+    }
+}

Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/XmlOutputType.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/XmlOutputType.java?rev=1401885&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/XmlOutputType.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/outputtype/XmlOutputType.java Wed Oct 24 21:13:09 2012
@@ -0,0 +1,45 @@
+package org.apache.torque.generator.control.outputtype;
+
+
+/**
+ * The output type for XML output.
+ *
+ * @version $Id: $
+ */
+public class XmlOutputType implements OutputType
+{
+    /** The unique key of the output type. */
+    public static final String KEY = "xml";
+
+    /** The start of a comment. */
+    private static final String COMMENT_START = "<!-- ";
+
+    /** The end of a comment. */
+    private static final String COMMENT_END = " -->";
+
+    /**
+     * Returns the start of a comment.
+     * It is assumed that the comment itself does not contain line breaks.
+     *
+     * @param lineBreak the line break for the current output, not null.
+     *
+     * @return the String which starts a comment, not null.
+     */
+    public String getCommentStart(String lineBreak)
+    {
+        return COMMENT_START;
+    }
+
+    /**
+     * Returns the end of a comment.
+     * It is assumed that the comment itself does not contain line breaks.
+     *
+     * @param lineBreak the line break for the current output, not null.
+     *
+     * @return the String which starts a comment, not null.
+     */
+    public String getCommentEnd(String lineBreak)
+    {
+        return COMMENT_END + lineBreak;
+    }
+}

Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/DebuggingOutletWrapper.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/DebuggingOutletWrapper.java?rev=1401885&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/DebuggingOutletWrapper.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/DebuggingOutletWrapper.java Wed Oct 24 21:13:09 2012
@@ -0,0 +1,242 @@
+package org.apache.torque.generator.outlet;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Map;
+
+import org.apache.torque.generator.GeneratorException;
+import org.apache.torque.generator.configuration.ConfigurationException;
+import org.apache.torque.generator.configuration.controller.Output;
+import org.apache.torque.generator.configuration.mergepoint.MergepointMapping;
+import org.apache.torque.generator.control.ControllerState;
+import org.apache.torque.generator.control.outputtype.OutputType;
+import org.apache.torque.generator.qname.QualifiedName;
+
+/**
+ * An outlet wrapper which adds debug information to the outlet.
+ *
+ * @version $Id: $
+ */
+public class DebuggingOutletWrapper implements Outlet
+{
+    /** The wrapped outlet, not null. */
+    private Outlet delegate;
+
+    /**
+     * Constructor.
+     *
+     * @param delegate the wrapped outlet, not null.
+     */
+    public DebuggingOutletWrapper(Outlet delegate)
+    {
+        if (delegate == null)
+        {
+            throw new NullPointerException("delegate must not be null");
+        }
+        this.delegate = delegate;
+    }
+
+    /**
+     * Returns the name of the delegate.
+     *
+     * @return the name of the delegate, not null.
+     */
+    public QualifiedName getName()
+    {
+        return delegate.getName();
+    }
+
+    /**
+     * Adds the mergepoint mapping to the delegate.
+     *
+     * @param mergepointMapping the mergepoint mapping to add, not null.
+     *
+     * @throws NullPointerException if mergepointMapping is null.
+     * @throws ConfigurationException if an mergepointMapping
+     *          for the given name already exists.
+     */
+    public void addMergepointMapping(MergepointMapping mergepointMapping)
+            throws ConfigurationException
+    {
+        delegate.addMergepointMapping(mergepointMapping);
+    }
+
+    /**
+     * Sets an mergepoint mapping in the delegate.
+     *
+     * @param mergepointMapping the mergepointMapping to add, not null.
+     *
+     * @return the replaced mergepoint mapping, not null.
+     *
+     * @throws NullPointerException if mergepointMapping is null.
+     */
+    public MergepointMapping setMergepointMapping(
+            MergepointMapping mergepointMapping)
+    {
+        return delegate.setMergepointMapping(mergepointMapping);
+    }
+
+    /**
+     * Retrieves the mergepoint mapping for the given mergepoint name
+     * from the delegate and returns it.
+     *
+     * @param name the name of the mergepoint mapping.
+     *
+     * @return the mergepoint mapping for the given name, or null if no
+     *           mergepoint mapping exists for this name.
+     */
+    public MergepointMapping getMergepointMapping(String name)
+    {
+        return delegate.getMergepointMapping(name);
+    }
+
+    /**
+     * Returns the map of all mergepoint mappings in the delegate,
+     * keyed by their name.
+     *
+     * @return the map of mergepoint mappings, not null.
+     */
+    public Map<String, MergepointMapping> getMergepointMappings()
+    {
+        return delegate.getMergepointMappings();
+    }
+
+    /**
+     * Sets the name of the input root element in the delegate.
+     *
+     * @param inputName the name of the root element of the source,
+     *        or null to accept any input name.
+     */
+    public void setInputElementName(String inputName)
+    {
+        delegate.setInputElementName(inputName);
+    }
+
+    /**
+     * Returns the name of the input root element from the delegate.
+     *
+     * @return inputName the name of the root element of the source,
+     *          or if any input name is accepted.
+     */
+    public String getInputElementName()
+    {
+        return delegate.getInputElementName();
+    }
+
+    /**
+     * Calls the beforeExecute method in the delegate.
+     *
+     * @param controllerState the current controller state, not null.
+     *
+     * @throws GeneratorException if adjusting the controller state fails.
+     */
+    public void beforeExecute(ControllerState controllerState)
+            throws GeneratorException
+    {
+        delegate.beforeExecute(controllerState);
+    }
+
+    /**
+     * Calls the afterExecute method in the delegate.
+     *
+     * @param controllerState the current controller state, not null.
+     *
+     * @throws GeneratorException if adjusting the controller state fails.
+     */
+    public void afterExecute(ControllerState controllerState)
+            throws GeneratorException
+    {
+        delegate.afterExecute(controllerState);
+    }
+
+    /**
+     * Executes the delegate generation and adds debugging output
+     * before and after the generated content, if the result is a String result.
+     *
+     * @param controllerState the current controller state, not null.
+     *
+     * @return the result of the generation plus possibly debugging information.
+     *
+     * @throws GeneratorException if adjusting the controller state fails.
+     */
+    public OutletResult execute(ControllerState controllerState)
+            throws GeneratorException
+    {
+        OutletResult outletResult = delegate.execute(controllerState);
+        if (outletResult.isByteArrayResult())
+        {
+            // do nothing, no debugging for binary result
+            return outletResult;
+        }
+        Output output = controllerState.getOutput();
+        String lineBreak = output.getOrDetermineLineBreak(
+                outletResult.getStringResult());
+        String outputTypeString = output.getType();
+        Map<String, OutputType> outputTypes
+                = controllerState.getUnitConfiguration()
+                    .getConfigurationHandlers()
+                    .getOutputTypes();
+        OutputType outputType = outputTypes.get(outputTypeString);
+        if (outputType == null)
+        {
+            throw new GeneratorException("Unknown output type "
+                    + outputTypeString
+                    + " in output "
+                    + output.getName());
+        }
+        String commentStart = outputType.getCommentStart(lineBreak);
+        String commentAtStart = getCommentAtStart(controllerState);
+        String commentAtEnd = getCommentAtEnd(controllerState);
+        String commentEnd = outputType.getCommentEnd(lineBreak);
+        return new OutletResult(commentStart + commentAtStart + commentEnd
+                + outletResult.getStringResult()
+                + commentStart + commentAtEnd + commentEnd);
+    }
+
+    /**
+     * Returns the debug information to be added at the start of the outlet's
+     * output.
+     *
+     * @param controllerState The current controller state, not null.
+     *
+     * @return the debug information, not null.
+     */
+    protected String getCommentAtStart(ControllerState controllerState)
+    {
+        return "start output of outlet " + controllerState.getOutlet().getName()
+                + ", current source element is "
+                + controllerState.getSourceElement().getName();
+    }
+
+    /**
+     * Returns the debug information to be added at the end of the outlet's
+     * output.
+     *
+     * @param controllerState The current controller state, not null.
+     *
+     * @return the debug information, not null.
+     */
+    protected String getCommentAtEnd(ControllerState controllerState)
+    {
+        return "end output of outlet " + controllerState.getOutlet().getName()
+                + ", current source element is "
+                + controllerState.getSourceElement().getName();
+    }
+}

Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/Outlet.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/Outlet.java?rev=1401885&r1=1401884&r2=1401885&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/Outlet.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/Outlet.java Wed Oct 24 21:13:09 2012
@@ -33,10 +33,10 @@ import org.apache.torque.generator.qname
 public interface Outlet
 {
     /**
-     * Returns the name of the Template. The namespace part of the name defines
-     * the default context of the template.
+     * Returns the name of the outlet. The namespace part of the name defines
+     * the default context of the outlet.
      *
-     * @return the name of the Template, not null.
+     * @return the name of the outlet, not null.
      */
     QualifiedName getName();
 

Modified: db/torque/torque4/trunk/torque-generator/src/main/resources/org/apache/torque/generator/configuration/configuration.xsd
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/resources/org/apache/torque/generator/configuration/configuration.xsd?rev=1401885&r1=1401884&r2=1401885&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/resources/org/apache/torque/generator/configuration/configuration.xsd (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/resources/org/apache/torque/generator/configuration/configuration.xsd Wed Oct 24 21:13:09 2012
@@ -143,6 +143,23 @@
         </restriction>
       </simpleType>
     </attribute>
+    <attribute name="type" use="optional">
+      <annotation>
+        <documentation>
+          The type of the output, e.g. java, html, xml, unknown.
+          Default is "unknown"
+        </documentation>
+      </annotation>
+      <simpleType>
+        <restriction base="string">
+          <enumeration value="java"/>
+          <enumeration value="html"/>
+          <enumeration value="xml"/>
+          <enumeration value="properties"/>
+          <enumeration value="unknown"/>
+        </restriction>
+      </simpleType>
+    </attribute>
     <attribute name="outputDirKey" type="string" use="optional">
       <annotation>
         <documentation>

Modified: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/outlet/OutletConfigurationTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/outlet/OutletConfigurationTest.java?rev=1401885&r1=1401884&r2=1401885&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/outlet/OutletConfigurationTest.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/configuration/outlet/OutletConfigurationTest.java Wed Oct 24 21:13:09 2012
@@ -21,11 +21,16 @@ package org.apache.torque.generator.conf
 
 import static org.junit.Assert.assertEquals;
 
+import java.io.File;
 import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.torque.generator.configuration.ConfigurationException;
+import org.apache.torque.generator.configuration.UnitDescriptor;
+import org.apache.torque.generator.configuration.UnitDescriptor.Packaging;
 import org.apache.torque.generator.configuration.mergepoint.MergepointMapping;
+import org.apache.torque.generator.configuration.paths.DefaultTorqueGeneratorPaths;
+import org.apache.torque.generator.configuration.paths.Maven2DirectoryProjectPaths;
 import org.apache.torque.generator.control.action.ApplyAction;
 import org.apache.torque.generator.java.JavaOutlet;
 import org.apache.torque.generator.outlet.Outlet;
@@ -35,6 +40,12 @@ import org.junit.Test;
 
 public class OutletConfigurationTest
 {
+    /** Unit descriptor for the tests. */
+    private UnitDescriptor unitDescriptor = new UnitDescriptor(
+            Packaging.JAR,
+            new Maven2DirectoryProjectPaths(new File(".")),
+            new DefaultTorqueGeneratorPaths());
+
     /**
      * Tests that getOutlets returns the correct result.
      *
@@ -51,8 +62,10 @@ public class OutletConfigurationTest
         List<MergepointMapping> mergepointMappings
                 = new ArrayList<MergepointMapping>();
 
-        OutletConfiguration outletConfiguration
-                = new OutletConfiguration(outlets, mergepointMappings);
+        OutletConfiguration outletConfiguration = new OutletConfiguration(
+                outlets,
+                mergepointMappings,
+                unitDescriptor);
         outletConfiguration.resolveMergepointMappings();
 
         assertEquals(2, outletConfiguration.getOutlets().size());
@@ -84,7 +97,7 @@ public class OutletConfigurationTest
         List<MergepointMapping> mergepointMappings
                 = new ArrayList<MergepointMapping>();
 
-        new OutletConfiguration(outlets, mergepointMappings);
+        new OutletConfiguration(outlets, mergepointMappings, unitDescriptor);
     }
 
     /**
@@ -106,8 +119,10 @@ public class OutletConfigurationTest
         mergepointMappings.get(0).addAction(
                 new ApplyAction(".", "test.outlet.2", false));
 
-        OutletConfiguration outletConfiguration
-                = new OutletConfiguration(outlets, mergepointMappings);
+        OutletConfiguration outletConfiguration = new OutletConfiguration(
+                outlets,
+                mergepointMappings,
+                unitDescriptor);
         outletConfiguration.resolveMergepointMappings();
 
         Outlet outlet = outletConfiguration.getOutlet(
@@ -135,8 +150,10 @@ public class OutletConfigurationTest
         mergepointMappings.add(
                 new MergepointMapping("not.existing.outlet.testMergepoint"));
 
-        OutletConfiguration outletConfiguration
-                = new OutletConfiguration(outlets, mergepointMappings);
+        OutletConfiguration outletConfiguration = new OutletConfiguration(
+                outlets,
+                mergepointMappings,
+                unitDescriptor);
         outletConfiguration.resolveMergepointMappings();
     }
 
@@ -156,8 +173,10 @@ public class OutletConfigurationTest
         mergepointMappings.add(
                 new MergepointMapping("testMergepoint"));
 
-        OutletConfiguration outletConfiguration
-                = new OutletConfiguration(outlets, mergepointMappings);
+        OutletConfiguration outletConfiguration = new OutletConfiguration(
+                outlets,
+                mergepointMappings,
+                unitDescriptor);
         outletConfiguration.resolveMergepointMappings();
     }
 }

Modified: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/control/PropertyToJavaGenerationTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/control/PropertyToJavaGenerationTest.java?rev=1401885&r1=1401884&r2=1401885&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/control/PropertyToJavaGenerationTest.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/control/PropertyToJavaGenerationTest.java Wed Oct 24 21:13:09 2012
@@ -20,6 +20,7 @@ package org.apache.torque.generator.cont
  */
 
 import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
@@ -36,9 +37,15 @@ import org.junit.Test;
 
 public class PropertyToJavaGenerationTest extends BaseTest
 {
+    /**
+     * Tests that the property to java generation works.
+     *
+     * @throws Exception if the test fails.
+     */
     @Test
     public void testPropertyToJavaGeneration() throws Exception
     {
+        // prepare
         File targetDir = new File("target/test/propertyToJava");
         FileUtils.deleteDirectory(targetDir);
         Controller controller = new Controller();
@@ -51,8 +58,11 @@ public class PropertyToJavaGenerationTes
                 UnitDescriptor.Packaging.DIRECTORY,
                 projectPaths,
                 new DefaultTorqueGeneratorPaths()));
+
+        // execute
         controller.run(unitDescriptors);
-        // TODO: check outcome against reference file
+
+        // verify
         assertTrue(targetDir.exists());
         File logoResultFile = new File(targetDir, "logo.png");
         assertTrue(logoResultFile.exists());
@@ -61,5 +71,58 @@ public class PropertyToJavaGenerationTes
         assertArrayEquals(
                 expectedContent,
                 FileUtils.readFileToByteArray(logoResultFile));
+        File propertiesResultFile
+                = new File(targetDir, "Properties.properties");
+        assertTrue(propertiesResultFile.exists());
+        File propertiesExpectedFile
+            = new File("src/test/propertyToJava/expectedProperties.properties");
+        assertEquals(FileUtils.readFileToString(propertiesExpectedFile),
+                FileUtils.readFileToString(propertiesResultFile));
+    }
+
+    /**
+     * Tests that the property to java generation works with debug output
+     * switched on.
+     *
+     * @throws Exception if the test fails.
+     */
+    @Test
+    public void testPropertyToJavaGenerationDebugOutput() throws Exception
+    {
+        // prepare
+        File targetDir = new File("target/test/propertyToJava");
+        FileUtils.deleteDirectory(targetDir);
+        Controller controller = new Controller();
+        List<UnitDescriptor> unitDescriptors = new ArrayList<UnitDescriptor>();
+        CustomProjectPaths projectPaths = new CustomProjectPaths(
+                new Maven2DirectoryProjectPaths(
+                        new File("src/test/propertyToJava")));
+        projectPaths.setOutputDirectory(null, targetDir);
+        UnitDescriptor unitDescriptor = new UnitDescriptor(
+                UnitDescriptor.Packaging.DIRECTORY,
+                projectPaths,
+                new DefaultTorqueGeneratorPaths());
+        unitDescriptor.setAddDebuggingInfoToOutput(true);
+        unitDescriptors.add(unitDescriptor);
+
+        // execute
+        controller.run(unitDescriptors);
+
+        // verify
+        assertTrue(targetDir.exists());
+        File logoResultFile = new File(targetDir, "logo.png");
+        assertTrue(logoResultFile.exists());
+        byte[] expectedContent = FileUtils.readFileToByteArray(
+                new File("src/test/propertyToJava/src/main/torque-gen/resources/torque-logo-new.png"));
+        assertArrayEquals(
+                expectedContent,
+                FileUtils.readFileToByteArray(logoResultFile));
+        File propertiesResultFile
+                = new File(targetDir, "Properties.properties");
+        assertTrue(propertiesResultFile.exists());
+        File propertiesExpectedFile
+                = new File("src/test/propertyToJava/expectedPropertiesDebugOutput.properties");
+        assertEquals(FileUtils.readFileToString(propertiesExpectedFile),
+                FileUtils.readFileToString(propertiesResultFile));
     }
 }

Added: db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/expectedProperties.properties
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/expectedProperties.properties?rev=1401885&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/expectedProperties.properties (added)
+++ db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/expectedProperties.properties Wed Oct 24 21:13:09 2012
@@ -0,0 +1,2 @@
+propertyName1 = propertyValue1
+propertyName2 = propertyValue2

Added: db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/expectedPropertiesDebugOutput.properties
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/expectedPropertiesDebugOutput.properties?rev=1401885&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/expectedPropertiesDebugOutput.properties (added)
+++ db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/expectedPropertiesDebugOutput.properties Wed Oct 24 21:13:09 2012
@@ -0,0 +1,8 @@
+# start output of outlet org.apache.torque.generator.velocity.propertiesCopy, current source element is properties
+# start output of outlet org.apache.torque.generator.velocity.propertyCopy, current source element is entry
+propertyName1 = propertyValue1
+# end output of outlet org.apache.torque.generator.velocity.propertyCopy, current source element is entry
+# start output of outlet org.apache.torque.generator.velocity.propertyCopy, current source element is entry
+propertyName2 = propertyValue2
+# end output of outlet org.apache.torque.generator.velocity.propertyCopy, current source element is entry
+# end output of outlet org.apache.torque.generator.velocity.propertiesCopy, current source element is properties

Added: db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/package.html
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/package.html?rev=1401885&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/package.html (added)
+++ db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/package.html Wed Oct 24 21:13:09 2012
@@ -0,0 +1,23 @@
+<!--
+ Copyright 2001-2006 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License")
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<h2>Test configuration for the PropertyToJavaGenerationTest</h2>
+
+<p>
+  This directory and its subdirectories contain a test configuration
+  which is used by the PropertyToJavaGenerationTest.
+</p>
+ 
\ No newline at end of file

Modified: db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/src/main/torque-gen/conf/control.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/src/main/torque-gen/conf/control.xml?rev=1401885&r1=1401884&r2=1401885&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/src/main/torque-gen/conf/control.xml (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/src/main/torque-gen/conf/control.xml Wed Oct 24 21:13:09 2012
@@ -24,7 +24,7 @@
     xmlns="http://db.apache.org/torque/4.0/generator/configuration"
     loglevel="debug">
   <options path="options.properties" xsi:type="propertiesOptions"/> 
-  <output name="propertiesClass">
+  <output name="propertiesClass" type="java">
     <filenameOutlet xsi:type="javaOutlet" 
         class="org.apache.torque.generator.outlet.java.JavaFilenameOutlet">
       <mergepoint name="classname">
@@ -39,7 +39,7 @@
     </source>
     <outlet name="org.apache.torque.generator.velocity.propertiesToJava" />
   </output>
-  <output name="extendingClass">
+  <output name="extendingClass" type="java">
     <filenameOutlet xsi:type="javaOutlet" 
         class="org.apache.torque.generator.outlet.java.JavaFilenameOutlet">
       <mergepoint name="classname">
@@ -54,7 +54,7 @@
     </source>
     <outlet name="org.apache.torque.generator.velocity.propertiesExtendedToJava" />
   </output>
-  <output name="properties" file="Properties.properties">
+  <output name="properties" file="Properties.properties" type="properties">
     <source xsi:type="fileSource" elements="properties">
       <include>propertiesData.properties</include>
     </source>

Modified: db/torque/torque4/trunk/torque-maven-plugin/src/main/java/org/apache/torque/generator/maven/TorqueGeneratorMojo.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-maven-plugin/src/main/java/org/apache/torque/generator/maven/TorqueGeneratorMojo.java?rev=1401885&r1=1401884&r2=1401885&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-maven-plugin/src/main/java/org/apache/torque/generator/maven/TorqueGeneratorMojo.java (original)
+++ db/torque/torque4/trunk/torque-maven-plugin/src/main/java/org/apache/torque/generator/maven/TorqueGeneratorMojo.java Wed Oct 24 21:13:09 2012
@@ -360,6 +360,13 @@ public class TorqueGeneratorMojo extends
     private String loglevel;
 
     /**
+     * Whether to add debug information to the output.
+     *
+     * @parameter
+     */
+    private boolean addDebuggingInfoToOutput = false;
+
+    /**
      * Additional options which can be added to the generation process.
      * This overrides both the options set in the templates
      * and the options in optionsFile.
@@ -626,6 +633,7 @@ public class TorqueGeneratorMojo extends
         unitDescriptor.setOverrideOptions(optionConfiguration);
         unitDescriptor.setLoglevel(convertedLoglevel);
         unitDescriptor.setDefaultOutputEncoding(encoding);
+        unitDescriptor.setAddDebuggingInfoToOutput(addDebuggingInfoToOutput);
         getLog().debug("unit descriptor created");
         if (overrideConfigDir != null)
         {
@@ -1028,5 +1036,14 @@ public class TorqueGeneratorMojo extends
         this.optionsFile = optionsFile;
     }
 
-
+    /**
+     * Sets whether debugging information should be added to the output.
+     *
+     * @param addDebuggingInfoToOutput true if debugging information
+     *        should be added to the output, false otherwise.
+     */
+    public void setAddDebuggingInfoToOutput(boolean addDebuggingInfoToOutput)
+    {
+        this.addDebuggingInfoToOutput = addDebuggingInfoToOutput;
+    }
 }

Modified: db/torque/torque4/trunk/torque-site/src/site/xdoc/documentation/modules/generator/reference/configuration.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-site/src/site/xdoc/documentation/modules/generator/reference/configuration.xml?rev=1401885&r1=1401884&r2=1401885&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-site/src/site/xdoc/documentation/modules/generator/reference/configuration.xml (original)
+++ db/torque/torque4/trunk/torque-site/src/site/xdoc/documentation/modules/generator/reference/configuration.xml Wed Oct 24 21:13:09 2012
@@ -47,12 +47,18 @@
         All outlet properties can be overridden in the controller
         configuration.
       </li>
-      <li>
-        If you are using template based generation (e.g. using velocity), 
-        of course the templates need to be provided. If you use java generation,
-        the java classes need to be present in the generator's classpath. 
-      </li>
     </ul>
+    <p>
+      Some settings can also be passed directly when calling the generator.
+      Typically these settings specify which config directory resp. package
+      is used, which source directory is used, which source files
+      are included and excluded etc. 
+      Also, debug output can be added to the output which helps determine
+      which output snippet stems from which outlet.
+      <br/>
+      These settings are typically made available through the build system
+      adapter, e.g.the maven plugin or the ant tasks.
+    </p>
   </section>
   <section name="Standard directory layout">
     The Torque generator uses a standard directory layout for its
@@ -71,6 +77,7 @@
         - resources (only if xsd schema validation is used for sources)
           - schema_example.xsd (name not fixed)
           - ... (other xsd schemata)
+          - binary resources (images etc.)
     </source>
     The sources are not considered part of the configuration; thus they do not
     appear here (If you have no idea where to put the sources,



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