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/08/02 13:46:39 UTC
svn commit: r1368426 [1/2] - in
/db/torque/torque4/trunk/torque-generator/src:
main/java/org/apache/torque/generator/configuration/controller/
main/java/org/apache/torque/generator/configuration/outlet/
main/java/org/apache/torque/generator/control/ ma...
Author: tfischer
Date: Thu Aug 2 11:46:37 2012
New Revision: 1368426
URL: http://svn.apache.org/viewvc?rev=1368426&view=rev
Log:
new outlet type "copyOutlet" implemented
Added:
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/CopyOutletSaxHandler.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/CopyOutletSaxHandlerFactory.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/existingtargetstrategy/
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/existingtargetstrategy/AppendToTargetFileStrategy.java
- copied, changed from r1356516, db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/AppendToTargetFileStrategy.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/existingtargetstrategy/ExistingTargetStrategy.java
- copied, changed from r1356516, db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/ExistingTargetStrategy.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/existingtargetstrategy/MergeTargetFileStrategy.java
- copied, changed from r1356516, db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/MergeTargetFileStrategy.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/existingtargetstrategy/ReplaceTargetFileStrategy.java
- copied, changed from r1356516, db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/ReplaceTargetFileStrategy.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/existingtargetstrategy/SkipExistingTargetFileStrategy.java
- copied, changed from r1356516, db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/SkipExistingTargetFileStrategy.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/existingtargetstrategy/package.html
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/OutletResult.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/copy/
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/copy/CopyOutlet.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/copy/package.html
db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/src/main/torque-gen/outlets/logoCopyOutlet.xml
db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/src/main/torque-gen/resources/
db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/src/main/torque-gen/resources/torque-logo-new.png (with props)
Removed:
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/AppendToTargetFileStrategy.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/ExistingTargetStrategy.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/MergeTargetFileStrategy.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/ReplaceTargetFileStrategy.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/SkipExistingTargetFileStrategy.java
Modified:
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/control/Controller.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/ControllerHelper.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/action/ApplyAction.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/action/MergepointAction.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/action/OptionAction.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/action/OutputAction.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/action/SourceElementAttributeAction.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/action/TraverseAllAction.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/java/org/apache/torque/generator/outlet/OutletImpl.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/CamelbackOutlet.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/ConstantNameOutlet.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/JavaFilenameOutlet.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/JavadocOutlet.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/ModifySourcenameOutlet.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/NewlineOutlet.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/OptionOutlet.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/PackageToPathOutlet.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/XmlOutlet.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/template/velocity/VelocityOutlet.java
db/torque/torque4/trunk/torque-generator/src/main/resources/org/apache/torque/generator/configuration/outlet.xsd
db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/control/PropertyToJavaGenerationTest.java
db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/java/JavaOutlet.java
db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/outlet/java/JavadocOutletTest.java
db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/outlet/java/ModifySourcenameOutletTest.java
db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/outlet/java/NewlineOutletTest.java
db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/outlet/java/XmlOutletTest.java
db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/template/groovy/GroovyOutlet.java
db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/src/main/torque-gen/conf/control.xml
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=1368426&r1=1368425&r2=1368426&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 Thu Aug 2 11:46:37 2012
@@ -19,7 +19,7 @@ package org.apache.torque.generator.conf
* under the License.
*/
-import org.apache.torque.generator.control.ReplaceTargetFileStrategy;
+import org.apache.torque.generator.control.existingtargetstrategy.ReplaceTargetFileStrategy;
import org.apache.torque.generator.outlet.Outlet;
import org.apache.torque.generator.qname.QualifiedName;
import org.apache.torque.generator.source.SourceProcessConfiguration;
Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/CopyOutletSaxHandler.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/CopyOutletSaxHandler.java?rev=1368426&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/CopyOutletSaxHandler.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/CopyOutletSaxHandler.java Thu Aug 2 11:46:37 2012
@@ -0,0 +1,130 @@
+package org.apache.torque.generator.configuration.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 static org.apache.torque.generator.configuration.outlet.OutletConfigurationTags.OUTLET_NAME_ATTRIBUTE;
+import static org.apache.torque.generator.configuration.outlet.OutletConfigurationTags.OUTLET_PATH_ATTRIBUTE;
+
+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.paths.ProjectPaths;
+import org.apache.torque.generator.outlet.copy.CopyOutlet;
+import org.apache.torque.generator.qname.QualifiedName;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * Handles a declaration of a copy outlet within a outlet configuration
+ * file.
+ */
+class CopyOutletSaxHandler extends OutletSaxHandler
+{
+ /**
+ * Constructor.
+ *
+ * @param outletName the name for the outlet which configuration
+ * will be read in by the generated SaxHandlerFactory,
+ * or null if the name of the outlet should be determined from
+ * the parsed xml.
+ * @param configurationProvider The access object for the configuration
+ * files, not null.
+ * @param projectPaths The paths of the surrounding project, not null.
+ * @param configurationHandlers the available configuration handlers,
+ * not null.
+ *
+ * @throws SAXException if an error occurs during creation of the outlet.
+ */
+ public CopyOutletSaxHandler(
+ QualifiedName outletName,
+ ConfigurationProvider configurationProvider,
+ ProjectPaths projectPaths,
+ ConfigurationHandlers configurationHandlers)
+ throws SAXException
+ {
+ super(outletName,
+ configurationProvider,
+ projectPaths,
+ configurationHandlers);
+ }
+
+ /**
+ * Instantiates and configures a velocity outlet.
+ *
+ * @param outletName the name for the outlet which configuration
+ * will be read in by the generated SaxHandlerFactory,
+ * or null if the name of the outlet should be determined from
+ * the parsed xml.
+ * @param uri - The Namespace URI, or the empty string if the
+ * element has no Namespace URI or if Namespace processing is not
+ * being performed.
+ * @param localName - The local name (without prefix), or
+ * the empty string if Namespace processing is not being performed.
+ * @param rawName - The qualified name (with prefix), or the empty string if
+ * qualified names are not available.
+ * @param attributes - The attributes attached to the element.
+ * If there are no attributes, it shall be an empty Attributes
+ * object.
+ *
+ * @return the created outlet, not null.
+ *
+ * @throws SAXException if an error occurs during creation.
+ */
+ @Override
+ protected CopyOutlet createOutlet(
+ QualifiedName outletName,
+ String uri,
+ String localName,
+ String rawName,
+ Attributes attributes)
+ throws SAXException
+ {
+ if (outletName == null)
+ {
+ String nameAttribute
+ = attributes.getValue(OUTLET_NAME_ATTRIBUTE);
+ if (nameAttribute == null)
+ {
+ throw new SAXException("The attribute "
+ + OUTLET_NAME_ATTRIBUTE
+ + " must be set on the element "
+ + rawName
+ + " for Velocity Outlets");
+ }
+ outletName = new QualifiedName(nameAttribute);
+ }
+
+ String path = attributes.getValue(OUTLET_PATH_ATTRIBUTE);
+
+ try
+ {
+ CopyOutlet result
+ = new CopyOutlet(
+ outletName,
+ getConfigurationProvider(),
+ path);
+ return result;
+ }
+ catch (ConfigurationException e)
+ {
+ throw new SAXException(e);
+ }
+ }
+}
Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/CopyOutletSaxHandlerFactory.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/CopyOutletSaxHandlerFactory.java?rev=1368426&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/CopyOutletSaxHandlerFactory.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/CopyOutletSaxHandlerFactory.java Thu Aug 2 11:46:37 2012
@@ -0,0 +1,80 @@
+package org.apache.torque.generator.configuration.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 org.apache.torque.generator.configuration.ConfigurationHandlers;
+import org.apache.torque.generator.configuration.ConfigurationProvider;
+import org.apache.torque.generator.configuration.paths.ProjectPaths;
+import org.apache.torque.generator.qname.QualifiedName;
+import org.xml.sax.SAXException;
+
+/**
+ * Creates copy outlet SAX handlers.
+ */
+public class CopyOutletSaxHandlerFactory
+ implements TypedOutletSaxHandlerFactory
+{
+ /**
+ * The type of the outlets which can be processed by the
+ * OutletSaxHandlers created by this factory.
+ */
+ private static final String OUTLET_TYPE = "copyOutlet";
+
+ /**
+ * Returns the outlet type which can be handled by the
+ * OutletSaxHandlers created by this factory.
+ * @return "copyOutlet".
+ */
+ public String getType()
+ {
+ return OUTLET_TYPE;
+ }
+
+ /**
+ * Returns a JavaOutletSaxHandler for reading the configuration of
+ * Java outlets. This implementation uses the provided name
+ * as outlet name.
+ *
+ * @param outletName the name for the outlet which configuration
+ * will be read in by the generated SaxHandlerFactory,
+ * or null if the name of the outlet should be determined from
+ * the parsed XML.
+ * @param configurationProvider The access object for the configuration
+ * files, not null.
+ * @param projectPaths The paths of the surrounding project, not null.
+ * @param configurationHandlers the available configuration handlers,
+ * not null.
+ *
+ * @return a new JavaOutletSaxHandler.
+ */
+ public final OutletSaxHandler getOutletSaxHandler(
+ QualifiedName outletName,
+ ConfigurationProvider configurationProvider,
+ ProjectPaths projectPaths,
+ ConfigurationHandlers configurationHandlers)
+ throws SAXException
+ {
+ return new CopyOutletSaxHandler(
+ outletName,
+ configurationProvider,
+ projectPaths,
+ configurationHandlers);
+ }
+}
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/Controller.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/Controller.java?rev=1368426&r1=1368425&r2=1368426&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/Controller.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/Controller.java Thu Aug 2 11:46:37 2012
@@ -39,7 +39,13 @@ import org.apache.torque.generator.confi
import org.apache.torque.generator.configuration.controller.OutletReference;
import org.apache.torque.generator.configuration.controller.Output;
import org.apache.torque.generator.configuration.outlet.OutletConfiguration;
+import org.apache.torque.generator.control.existingtargetstrategy.AppendToTargetFileStrategy;
+import org.apache.torque.generator.control.existingtargetstrategy.ExistingTargetStrategy;
+import org.apache.torque.generator.control.existingtargetstrategy.MergeTargetFileStrategy;
+import org.apache.torque.generator.control.existingtargetstrategy.ReplaceTargetFileStrategy;
+import org.apache.torque.generator.control.existingtargetstrategy.SkipExistingTargetFileStrategy;
import org.apache.torque.generator.outlet.Outlet;
+import org.apache.torque.generator.outlet.OutletResult;
import org.apache.torque.generator.source.Source;
import org.apache.torque.generator.source.SourceElement;
import org.apache.torque.generator.source.SourceException;
@@ -328,7 +334,15 @@ public class Controller
controllerState.setOutletNamespace(
output.getContentOutlet().getNamespace());
filenameOutlet.beforeExecute(controllerState);
- String filename = filenameOutlet.execute(controllerState);
+ OutletResult filenameResult
+ = filenameOutlet.execute(controllerState);
+ if (!filenameResult.isStringResult())
+ {
+ throw new GeneratorException(
+ "The result of a filename generation must be a String,"
+ + " not a byte array");
+ }
+ String filename = filenameResult.getStringResult();
filenameOutlet.afterExecute(controllerState);
if (log.isDebugEnabled())
{
@@ -473,7 +487,7 @@ public class Controller
}
outlet.beforeExecute(controllerState);
- String result = outlet.execute(controllerState);
+ OutletResult result = outlet.execute(controllerState);
outlet.afterExecute(controllerState);
existingTargetStrategy.afterGeneration(
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/ControllerHelper.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/ControllerHelper.java?rev=1368426&r1=1368425&r2=1368426&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/ControllerHelper.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/ControllerHelper.java Thu Aug 2 11:46:37 2012
@@ -47,7 +47,7 @@ public final class ControllerHelper
*
* @return the output File, not null.
*/
- static File getOutputFile(
+ public static File getOutputFile(
String outputDirKey,
String outputPath,
UnitConfiguration unitConfiguration)
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/action/ApplyAction.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/action/ApplyAction.java?rev=1368426&r1=1368425&r2=1368426&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/action/ApplyAction.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/action/ApplyAction.java Thu Aug 2 11:46:37 2012
@@ -25,6 +25,7 @@ import org.apache.torque.generator.Gener
import org.apache.torque.generator.control.ControllerState;
import org.apache.torque.generator.control.TokenReplacer;
import org.apache.torque.generator.outlet.Outlet;
+import org.apache.torque.generator.outlet.OutletResult;
import org.apache.torque.generator.qname.Namespace;
import org.apache.torque.generator.qname.QualifiedName;
import org.apache.torque.generator.source.SourceElement;
@@ -44,7 +45,7 @@ public class ApplyAction implements Merg
/**
* The name of the outlet to be invoked on the element, not null.
*/
- private String outletName;
+ private final String outletName;
/**
* Whether it is correct to have no element to apply.
@@ -89,7 +90,7 @@ public class ApplyAction implements Merg
* The output of the outlet is appended to the output.
* ${...} Tokens are replaced within outletName and path.
*/
- public String execute(ControllerState controllerState)
+ public OutletResult execute(ControllerState controllerState)
throws GeneratorException
{
TokenReplacer tokenReplacer = new TokenReplacer(controllerState);
@@ -112,13 +113,17 @@ public class ApplyAction implements Merg
List<SourceElement> selectedElements
= SourcePath.getElements(currentElement, detokenizedPath);
- if (!acceptNotSet && selectedElements.isEmpty())
+ if (selectedElements.isEmpty())
{
- throw new GeneratorException(
- "ApplyAction : selected path "
- + path
- + " does not match an element"
- + " and acceptNotSet was set to false");
+ if (!acceptNotSet)
+ {
+ throw new GeneratorException(
+ "ApplyAction : selected path "
+ + path
+ + " does not match an element"
+ + " and acceptNotSet was set to false");
+ }
+ return new OutletResult("");
}
if (selectedElements.size() > 1)
{
@@ -129,16 +134,13 @@ public class ApplyAction implements Merg
+ selectedElements.size()
+ " times)");
}
- StringBuffer result = new StringBuffer();
- for (SourceElement sourceElement : selectedElements)
- {
- controllerState.setSourceElement(sourceElement);
- outlet.beforeExecute(controllerState);
- result.append(outlet.execute(controllerState));
- outlet.afterExecute(controllerState);
- }
+ // selectedElements has size 1
+ controllerState.setSourceElement(selectedElements.get(0));
+ outlet.beforeExecute(controllerState);
+ OutletResult result = outlet.execute(controllerState);
+ outlet.afterExecute(controllerState);
controllerState.setSourceElement(currentElement);
- return result.toString();
+ return result;
}
@Override
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/action/MergepointAction.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/action/MergepointAction.java?rev=1368426&r1=1368425&r2=1368426&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/action/MergepointAction.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/action/MergepointAction.java Thu Aug 2 11:46:37 2012
@@ -21,6 +21,7 @@ package org.apache.torque.generator.cont
import org.apache.torque.generator.GeneratorException;
import org.apache.torque.generator.control.ControllerState;
+import org.apache.torque.generator.outlet.OutletResult;
/**
* An action which can be executed in a mergepoint.
@@ -36,7 +37,7 @@ public interface MergepointAction
*
* @throws GeneratorException if an error occurs during generation.
*/
- String execute(ControllerState controllerState)
+ OutletResult execute(ControllerState controllerState)
throws GeneratorException;
}
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/action/OptionAction.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/action/OptionAction.java?rev=1368426&r1=1368425&r2=1368426&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/action/OptionAction.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/action/OptionAction.java Thu Aug 2 11:46:37 2012
@@ -21,6 +21,7 @@ package org.apache.torque.generator.cont
import org.apache.torque.generator.GeneratorException;
import org.apache.torque.generator.control.ControllerState;
+import org.apache.torque.generator.outlet.OutletResult;
/**
* Inserts the value of an option into a mergepoint.
@@ -30,7 +31,7 @@ public class OptionAction implements Mer
/**
* The name of the option to insert.
*/
- private String optionName;
+ private final String optionName;
/**
* Whether it is acceptable that the option is not set.
@@ -72,7 +73,7 @@ public class OptionAction implements Mer
* @throws GeneratorException if acceptNotSet is false and the option
* is not set.
*/
- public String execute(ControllerState controllerState)
+ public OutletResult execute(ControllerState controllerState)
throws GeneratorException
{
Object option = controllerState.getOption(optionName);
@@ -80,13 +81,13 @@ public class OptionAction implements Mer
{
if (acceptNotSet)
{
- return "";
+ return new OutletResult("");
}
throw new GeneratorException("OptionAction: The option "
+ optionName
+ " is not set");
}
- return option.toString();
+ return new OutletResult(option.toString());
}
@Override
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/action/OutputAction.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/action/OutputAction.java?rev=1368426&r1=1368425&r2=1368426&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/action/OutputAction.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/action/OutputAction.java Thu Aug 2 11:46:37 2012
@@ -22,6 +22,7 @@ package org.apache.torque.generator.cont
import org.apache.torque.generator.GeneratorException;
import org.apache.torque.generator.control.ControllerState;
import org.apache.torque.generator.control.TokenReplacer;
+import org.apache.torque.generator.outlet.OutletResult;
/**
* Inserts a fixed String into a mergepoint.
@@ -31,7 +32,7 @@ public class OutputAction implements Mer
/**
* The fixed value to insert.
*/
- private String value;
+ private final String value;
/**
* Constructor.
@@ -59,12 +60,12 @@ public class OutputAction implements Mer
* @throws GeneratorException if acceptNotSet is false and the option
* is not set.
*/
- public String execute(ControllerState controllerState)
+ public OutletResult execute(ControllerState controllerState)
throws GeneratorException
{
TokenReplacer tokenReplacer = new TokenReplacer(controllerState);
String detokenizedValue = tokenReplacer.process(value);
- return detokenizedValue;
+ return new OutletResult(detokenizedValue);
}
@Override
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/action/SourceElementAttributeAction.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/action/SourceElementAttributeAction.java?rev=1368426&r1=1368425&r2=1368426&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/action/SourceElementAttributeAction.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/action/SourceElementAttributeAction.java Thu Aug 2 11:46:37 2012
@@ -22,6 +22,7 @@ package org.apache.torque.generator.cont
import org.apache.torque.generator.GeneratorException;
import org.apache.torque.generator.control.ControllerState;
import org.apache.torque.generator.control.TokenReplacer;
+import org.apache.torque.generator.outlet.OutletResult;
import org.apache.torque.generator.source.SourceElement;
import org.apache.torque.generator.source.SourcePath;
@@ -34,12 +35,12 @@ public class SourceElementAttributeActio
* The SourePath to find the element which should be used as input
* relative to the current element.
*/
- private String elementPath;
+ private final String elementPath;
/**
* The name of the attribute which should be output.
*/
- private String attributeName;
+ private final String attributeName;
/**
* Whether it is acceptable that the element does not exist or the given
@@ -88,7 +89,7 @@ public class SourceElementAttributeActio
* @throws GeneratorException if acceptNotSet is false and either no
* source element can be found or the attribute is not set.
*/
- public String execute(ControllerState controllerState)
+ public OutletResult execute(ControllerState controllerState)
throws GeneratorException
{
TokenReplacer tokenReplacer = new TokenReplacer(controllerState);
@@ -102,7 +103,7 @@ public class SourceElementAttributeActio
{
if (acceptNotSet)
{
- return "";
+ return new OutletResult("");
}
else
{
@@ -112,13 +113,13 @@ public class SourceElementAttributeActio
+ "can be found.");
}
}
- String detonizedAttributeName = tokenReplacer.process(attributeName);
- Object result = sourceElement.getAttribute(detonizedAttributeName);
+ String detokenizedAttributeName = tokenReplacer.process(attributeName);
+ Object result = sourceElement.getAttribute(detokenizedAttributeName);
if (result == null)
{
if (acceptNotSet)
{
- return "";
+ return new OutletResult("");
}
throw new GeneratorException("SourceElementAttributeAction: "
+ "The attribute "
@@ -129,7 +130,7 @@ public class SourceElementAttributeActio
+ elementPath
+ ")");
}
- return result.toString();
+ return new OutletResult(result.toString());
}
@Override
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/action/TraverseAllAction.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/action/TraverseAllAction.java?rev=1368426&r1=1368425&r2=1368426&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/action/TraverseAllAction.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/action/TraverseAllAction.java Thu Aug 2 11:46:37 2012
@@ -19,6 +19,7 @@ package org.apache.torque.generator.cont
* under the License.
*/
+import java.util.ArrayList;
import java.util.List;
import org.apache.torque.generator.GeneratorException;
@@ -26,6 +27,7 @@ import org.apache.torque.generator.confi
import org.apache.torque.generator.control.ControllerState;
import org.apache.torque.generator.control.TokenReplacer;
import org.apache.torque.generator.outlet.Outlet;
+import org.apache.torque.generator.outlet.OutletResult;
import org.apache.torque.generator.qname.Namespace;
import org.apache.torque.generator.qname.QualifiedName;
import org.apache.torque.generator.source.SourceElement;
@@ -40,12 +42,12 @@ public class TraverseAllAction implement
/**
* The filter for the elements to traverse, not null.
*/
- private String elementsToTraverseName;
+ private final String elementsToTraverseName;
/**
* The name of the outlet to be invoked for each element, not null.
*/
- private String outletName;
+ private final String outletName;
/**
* Whether it is correct to have no element to traverse.
@@ -93,7 +95,7 @@ public class TraverseAllAction implement
* ${...} Tokens are replaced within outletName and
* elementsToTraverseName.
*/
- public String execute(ControllerState controllerState)
+ public OutletResult execute(ControllerState controllerState)
throws GeneratorException
{
TokenReplacer tokenReplacer = new TokenReplacer(controllerState);
@@ -134,16 +136,21 @@ public class TraverseAllAction implement
+ " does not exist and acceptEmpty was set to false");
}
- StringBuffer result = new StringBuffer();
+ List<OutletResult> resultList
+ = new ArrayList<OutletResult>(selectedElements.size());
for (SourceElement sourceElement : selectedElements)
{
controllerState.setSourceElement(sourceElement);
outlet.beforeExecute(controllerState);
- result.append(outlet.execute(controllerState));
+ resultList.add(outlet.execute(controllerState));
outlet.afterExecute(controllerState);
}
controllerState.setSourceElement(currentElement);
- return result.toString();
+ if (resultList.isEmpty())
+ {
+ return new OutletResult("");
+ }
+ return OutletResult.concatenate(resultList);
}
@Override
Copied: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/existingtargetstrategy/AppendToTargetFileStrategy.java (from r1356516, db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/AppendToTargetFileStrategy.java)
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/existingtargetstrategy/AppendToTargetFileStrategy.java?p2=db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/existingtargetstrategy/AppendToTargetFileStrategy.java&p1=db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/AppendToTargetFileStrategy.java&r1=1356516&r2=1368426&rev=1368426&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/AppendToTargetFileStrategy.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/existingtargetstrategy/AppendToTargetFileStrategy.java Thu Aug 2 11:46:37 2012
@@ -1,4 +1,4 @@
-package org.apache.torque.generator.control;
+package org.apache.torque.generator.control.existingtargetstrategy;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -25,6 +25,9 @@ import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.apache.torque.generator.GeneratorException;
import org.apache.torque.generator.configuration.UnitConfiguration;
+import org.apache.torque.generator.control.ControllerException;
+import org.apache.torque.generator.control.ControllerHelper;
+import org.apache.torque.generator.outlet.OutletResult;
/**
* A handler which implements the strategy to append the generation result
@@ -81,7 +84,7 @@ public class AppendToTargetFileStrategy
String outputDirKey,
String outputPath,
String encoding,
- String generationResult,
+ OutletResult generationResult,
UnitConfiguration unitConfiguration)
throws GeneratorException
{
@@ -91,17 +94,46 @@ public class AppendToTargetFileStrategy
unitConfiguration);
try
{
- String originalContent = "";
- if (outputFile.exists())
+ if (generationResult.isStringResult())
{
- originalContent = FileUtils.readFileToString(
+ String originalContent = "";
+ if (outputFile.exists())
+ {
+ originalContent = FileUtils.readFileToString(
+ outputFile,
+ encoding);
+ }
+ FileUtils.writeStringToFile(
outputFile,
+ originalContent + generationResult.getStringResult(),
encoding);
}
- FileUtils.writeStringToFile(
- outputFile,
- originalContent + generationResult,
- encoding);
+ else
+ {
+ byte[] originalContent = new byte[] {};
+ if (outputFile.exists())
+ {
+ originalContent = FileUtils.readFileToByteArray(
+ outputFile);
+ }
+ byte[] result = new byte[originalContent.length
+ + generationResult.getByteArrayResult().length];
+ System.arraycopy(
+ originalContent,
+ 0,
+ result,
+ 0,
+ originalContent.length);
+ System.arraycopy(generationResult.getByteArrayResult(),
+ 0,
+ result,
+ originalContent.length,
+ generationResult.getByteArrayResult().length);
+
+ FileUtils.writeByteArrayToFile(
+ outputFile,
+ result);
+ }
}
catch (IOException e)
{
Copied: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/existingtargetstrategy/ExistingTargetStrategy.java (from r1356516, db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/ExistingTargetStrategy.java)
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/existingtargetstrategy/ExistingTargetStrategy.java?p2=db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/existingtargetstrategy/ExistingTargetStrategy.java&p1=db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/ExistingTargetStrategy.java&r1=1356516&r2=1368426&rev=1368426&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/ExistingTargetStrategy.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/existingtargetstrategy/ExistingTargetStrategy.java Thu Aug 2 11:46:37 2012
@@ -1,4 +1,4 @@
-package org.apache.torque.generator.control;
+package org.apache.torque.generator.control.existingtargetstrategy;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -21,6 +21,7 @@ package org.apache.torque.generator.cont
import org.apache.torque.generator.GeneratorException;
import org.apache.torque.generator.configuration.UnitConfiguration;
+import org.apache.torque.generator.outlet.OutletResult;
/**
* A handler which implements a strategy on how to deal with existing targets.
@@ -75,7 +76,7 @@ public interface ExistingTargetStrategy
String outputDirKey,
String outputPath,
String encoding,
- String generationResult,
+ OutletResult generationResult,
UnitConfiguration unitConfiguration)
throws GeneratorException;
Copied: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/existingtargetstrategy/MergeTargetFileStrategy.java (from r1356516, db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/MergeTargetFileStrategy.java)
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/existingtargetstrategy/MergeTargetFileStrategy.java?p2=db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/existingtargetstrategy/MergeTargetFileStrategy.java&p1=db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/MergeTargetFileStrategy.java&r1=1356516&r2=1368426&rev=1368426&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/MergeTargetFileStrategy.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/existingtargetstrategy/MergeTargetFileStrategy.java Thu Aug 2 11:46:37 2012
@@ -1,4 +1,4 @@
-package org.apache.torque.generator.control;
+package org.apache.torque.generator.control.existingtargetstrategy;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -28,7 +28,10 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.torque.generator.GeneratorException;
import org.apache.torque.generator.configuration.UnitConfiguration;
+import org.apache.torque.generator.control.ControllerException;
+import org.apache.torque.generator.control.ControllerHelper;
import org.apache.torque.generator.merge.ThreeWayMerger;
+import org.apache.torque.generator.outlet.OutletResult;
/**
* A handler which implements the strategy to replace existing target files.
@@ -47,7 +50,7 @@ public class MergeTargetFileStrategy imp
private static Log log = LogFactory.getLog(MergeTargetFileStrategy.class);
/** The merger. */
- private ThreeWayMerger merger = new ThreeWayMerger();
+ private final ThreeWayMerger merger = new ThreeWayMerger();
/**
* Will be called before the generation is started and decides whether
@@ -92,7 +95,7 @@ public class MergeTargetFileStrategy imp
String outputDirKey,
String outputPath,
String encoding,
- String generationResult,
+ OutletResult generationResult,
UnitConfiguration unitConfiguration)
throws GeneratorException
{
@@ -124,11 +127,19 @@ public class MergeTargetFileStrategy imp
targetFile,
encoding);
+ if (!generationResult.isStringResult())
+ {
+ throw new GeneratorException(
+ "The merge target file strategy onlys works"
+ + " for String generation results (target file="
+ + targetFile.getAbsolutePath() + ")");
+ }
+
String newTargetContent = null;
if (oldTargetContent == null)
{
log.debug("no old target content found, using generation result");
- newTargetContent = generationResult;
+ newTargetContent = generationResult.getStringResult();
}
else if (oldGenerationContent == null)
{
@@ -136,19 +147,22 @@ public class MergeTargetFileStrategy imp
+ "using old target content."
+ " This is a bit unusual, but may be ok"
+ " depending on the circumstances");
- newTargetContent = generationResult;
+ newTargetContent = generationResult.getStringResult();
}
else
{
log.debug("merging generation result and old target content");
newTargetContent = merger.merge(
oldGenerationContent,
- generationResult,
+ generationResult.getStringResult(),
oldTargetContent,
encoding);
}
writeStringToFile(targetFile, newTargetContent, encoding);
- writeStringToFile(generationStorageFile, generationResult, encoding);
+ writeStringToFile(
+ generationStorageFile,
+ generationResult.getStringResult(),
+ encoding);
}
/**
Copied: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/existingtargetstrategy/ReplaceTargetFileStrategy.java (from r1356516, db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/ReplaceTargetFileStrategy.java)
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/existingtargetstrategy/ReplaceTargetFileStrategy.java?p2=db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/existingtargetstrategy/ReplaceTargetFileStrategy.java&p1=db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/ReplaceTargetFileStrategy.java&r1=1356516&r2=1368426&rev=1368426&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/ReplaceTargetFileStrategy.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/existingtargetstrategy/ReplaceTargetFileStrategy.java Thu Aug 2 11:46:37 2012
@@ -1,4 +1,4 @@
-package org.apache.torque.generator.control;
+package org.apache.torque.generator.control.existingtargetstrategy;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -25,6 +25,9 @@ import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.apache.torque.generator.GeneratorException;
import org.apache.torque.generator.configuration.UnitConfiguration;
+import org.apache.torque.generator.control.ControllerException;
+import org.apache.torque.generator.control.ControllerHelper;
+import org.apache.torque.generator.outlet.OutletResult;
/**
* A handler which implements the strategy to replace existing target files.
@@ -80,7 +83,7 @@ public class ReplaceTargetFileStrategy i
String outputDirKey,
String outputPath,
String encoding,
- String generationResult,
+ OutletResult generationResult,
UnitConfiguration unitConfiguration)
throws GeneratorException
{
@@ -90,7 +93,19 @@ public class ReplaceTargetFileStrategy i
unitConfiguration);
try
{
- FileUtils.writeStringToFile(outputFile, generationResult, encoding);
+ if (generationResult.isStringResult())
+ {
+ FileUtils.writeStringToFile(
+ outputFile,
+ generationResult.getStringResult(),
+ encoding);
+ }
+ else
+ {
+ FileUtils.writeByteArrayToFile(
+ outputFile,
+ generationResult.getByteArrayResult());
+ }
}
catch (IOException e)
{
Copied: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/existingtargetstrategy/SkipExistingTargetFileStrategy.java (from r1356516, db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/SkipExistingTargetFileStrategy.java)
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/existingtargetstrategy/SkipExistingTargetFileStrategy.java?p2=db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/existingtargetstrategy/SkipExistingTargetFileStrategy.java&p1=db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/SkipExistingTargetFileStrategy.java&r1=1356516&r2=1368426&rev=1368426&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/SkipExistingTargetFileStrategy.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/existingtargetstrategy/SkipExistingTargetFileStrategy.java Thu Aug 2 11:46:37 2012
@@ -1,4 +1,4 @@
-package org.apache.torque.generator.control;
+package org.apache.torque.generator.control.existingtargetstrategy;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -22,6 +22,7 @@ package org.apache.torque.generator.cont
import java.io.File;
import org.apache.torque.generator.configuration.UnitConfiguration;
+import org.apache.torque.generator.control.ControllerHelper;
/**
* A handler which implements the strategy to skip existing target files.
Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/existingtargetstrategy/package.html
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/existingtargetstrategy/package.html?rev=1368426&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/existingtargetstrategy/package.html (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/control/existingtargetstrategy/package.html Thu Aug 2 11:46:37 2012
@@ -0,0 +1,26 @@
+<!--
+ 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.
+-->
+<html>
+ <head>
+ <title>Torque generator control</title>
+ </head>
+ <body>
+ <p>
+ This package defines and implements strategies for dealing with the
+ situation that a target file already exists.
+ </p>
+ </body>
+</html>
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=1368426&r1=1368425&r2=1368426&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 Thu Aug 2 11:46:37 2012
@@ -131,6 +131,6 @@ public interface Outlet
*
* @throws GeneratorException if generation fails.
*/
- String execute(ControllerState controllerState)
+ OutletResult execute(ControllerState controllerState)
throws GeneratorException;
}
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/OutletImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/OutletImpl.java?rev=1368426&r1=1368425&r2=1368426&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/OutletImpl.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/OutletImpl.java Thu Aug 2 11:46:37 2012
@@ -50,13 +50,13 @@ public abstract class OutletImpl impleme
/**
* The mergepoint mappings configured for this outlet.
*/
- private Map<String, MergepointMapping> mergepointMappings
+ private final Map<String, MergepointMapping> mergepointMappings
= new HashMap<String, MergepointMapping>();
/**
* The name of the outlet. Is immutable.
*/
- private QualifiedName name;
+ private final QualifiedName name;
/**
* The name of the input elements to process. If null, the input
@@ -176,7 +176,7 @@ public abstract class OutletImpl impleme
controllerState.popOutlet();
}
- public abstract String execute(ControllerState controllerState)
+ public abstract OutletResult execute(ControllerState controllerState)
throws GeneratorException;
@Override
@@ -323,11 +323,21 @@ public abstract class OutletImpl impleme
log.debug("mergepoint() : Executing action " + action);
}
- // velocity does not chain exceptions, so catch and log exceptions
- // here
+ // some engines (e.g. velocity) does not chain exceptions,
+ // so catch and log exceptions here
try
{
- result.append(action.execute(controllerState));
+ OutletResult actionResult = action.execute(controllerState);
+ if (!actionResult.isStringResult())
+ {
+ throw new GeneratorException(
+ "mergepoint actions "
+ + "must return a String result! Mergepoint name: "
+ + mergepointName
+ + ", outlet name: "
+ + controllerState.getOutlet().getName().toString());
+ }
+ result.append(actionResult.getStringResult());
}
catch (GeneratorException e)
{
Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/OutletResult.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/OutletResult.java?rev=1368426&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/OutletResult.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/OutletResult.java Thu Aug 2 11:46:37 2012
@@ -0,0 +1,196 @@
+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.Arrays;
+
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.torque.generator.GeneratorException;
+
+/**
+ * The result of an outlet. Can either be a String or a byte array.
+ */
+public class OutletResult
+{
+ /** The string result. */
+ private String stringResult;
+
+ /** The byte array result. */
+ private byte[] byteArrayResult;
+
+ /**
+ * Constructor for a String result.
+ *
+ * @param stringResult the String result.
+ */
+ public OutletResult(String stringResult)
+ {
+ this.stringResult = stringResult;
+ }
+
+ /**
+ * Constructor for a byte array result.
+ *
+ * @param byteArrayResult the byte array result.
+ */
+ public OutletResult(byte[] byteArrayResult)
+ {
+ this.byteArrayResult = byteArrayResult;
+ }
+
+ /**
+ * Returns the string result.
+ *
+ * @return the string result, or null if this class contains
+ * a byte array result.
+ */
+ public String getStringResult()
+ {
+ return stringResult;
+ }
+
+ /**
+ * Returns the byte array result.
+ *
+ * @return the byte array result, or null if this class contains
+ * a string result.
+ */
+ public byte[] getByteArrayResult()
+ {
+ return byteArrayResult;
+ }
+
+ public boolean isStringResult()
+ {
+ return (byteArrayResult == null);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ HashCodeBuilder hashCodeBuilder = new HashCodeBuilder()
+ .append(stringResult)
+ .append(byteArrayResult);
+ return hashCodeBuilder.toHashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+ if (obj == null)
+ {
+ return false;
+ }
+ if (getClass() != obj.getClass())
+ {
+ return false;
+ }
+ OutletResult other = (OutletResult) obj;
+ EqualsBuilder equalsBuilder = new EqualsBuilder()
+ .append(stringResult, other.stringResult)
+ .append(byteArrayResult, other.byteArrayResult);
+ return equalsBuilder.isEquals();
+ }
+
+ /**
+ * Concatenates an array of OutletResults.
+ *
+ * @param input the OutletResults to concatenate,
+ * not null, not empty, must not contain null, all of the same type
+ * (either all string or all byte array).
+ * @return the concatenated input.
+ *
+ * @throws GeneratorException if the input outlet results are
+ * of a different type.
+ */
+ public static OutletResult concatenate(OutletResult... input)
+ throws GeneratorException
+ {
+ return concatenate(Arrays.asList(input));
+ }
+
+ /**
+ * Concatenates a list of OutletResults.
+ *
+ * @param input the OutletResults to concatenate,
+ * not null, not empty, must not contain null, all of the same type
+ * (either all string or all byte array).
+ * @return the concatenated input.
+ *
+ * @throws GeneratorException if the input outlet results are
+ * of a different type.
+ */
+ public static OutletResult concatenate(Iterable<OutletResult> input)
+ throws GeneratorException
+ {
+ boolean isStringResult = input.iterator().next().isStringResult();
+ if (isStringResult)
+ {
+ StringBuilder result = new StringBuilder();
+ for (OutletResult part : input)
+ {
+ if (!part.isStringResult())
+ {
+ throw new GeneratorException(
+ "first OutletResult to concatenate is a "
+ + "String result but a following result is a "
+ + "byte array."
+ + " All concatenated results must be "
+ + "of the same type");
+ }
+ result.append(part.getStringResult());
+ }
+ return new OutletResult(result.toString());
+ }
+ int totalLength = 0;
+ for (OutletResult part : input)
+ {
+ if (part.isStringResult())
+ {
+ throw new GeneratorException(
+ "first OutletResult to concatenate is a "
+ + "byte array result but a following result is a "
+ + "String result."
+ + " All concatenated results must be "
+ + "of the same type");
+ }
+ totalLength += part.getByteArrayResult().length;
+
+ }
+ byte[] result = new byte[totalLength];
+ int alreadyFilledBytes = 0;
+ for (OutletResult part : input)
+ {
+ System.arraycopy(part.getByteArrayResult(),
+ 0,
+ result,
+ alreadyFilledBytes,
+ part.getByteArrayResult().length);
+ alreadyFilledBytes += part.getByteArrayResult().length;
+
+ }
+ return new OutletResult(result.toString());
+ }
+}
Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/copy/CopyOutlet.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/copy/CopyOutlet.java?rev=1368426&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/copy/CopyOutlet.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/copy/CopyOutlet.java Thu Aug 2 11:46:37 2012
@@ -0,0 +1,132 @@
+package org.apache.torque.generator.outlet.copy;
+
+/*
+ * 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.io.IOException;
+import java.io.InputStream;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.torque.generator.GeneratorException;
+import org.apache.torque.generator.configuration.ConfigurationException;
+import org.apache.torque.generator.configuration.ConfigurationProvider;
+import org.apache.torque.generator.control.ControllerState;
+import org.apache.torque.generator.outlet.OutletImpl;
+import org.apache.torque.generator.outlet.OutletResult;
+import org.apache.torque.generator.qname.QualifiedName;
+
+/**
+ * A Outlet which copies a given resource unchanged.
+ */
+public class CopyOutlet extends OutletImpl
+{
+ /** The log. */
+ private static Log log = LogFactory.getLog(CopyOutlet.class);
+
+ /**
+ * The path to the resource to copy.
+ * Relative paths are relative to the resources directory.
+ */
+ private final String path;
+
+ /**
+ * The configuration provider to use.
+ */
+ private final ConfigurationProvider configurationProvider;
+
+ /**
+ * Constructs a new CopyOutlet.
+ *
+ * @param name the name of this outlet, not null.
+ * @param configurationProvider the provider for reading the resources,
+ * not null.
+ * @param path the path to the resource, not null.
+ * May contain tokens of the form ${....}, these are parsed.
+ *
+ * @throws NullPointerException if name, path or configurationProvider
+ * are null.
+ * @throws ConfigurationException if an error occurs while reading the
+ * template.
+ */
+ public CopyOutlet(
+ QualifiedName name,
+ ConfigurationProvider configurationProvider,
+ String path)
+ throws ConfigurationException
+ {
+ super(name);
+ if (path == null)
+ {
+ throw new NullPointerException("path is null");
+ }
+ if (configurationProvider == null)
+ {
+ throw new NullPointerException("configurationProvider is null");
+ }
+ this.path = path;
+ this.configurationProvider = configurationProvider;
+ }
+
+ /**
+ * Executes the generation process; the result is returned.
+ *
+ * @param controllerState the current controller state.
+ *
+ * @return the result of the generation, not null.
+ *
+ * @see org.apache.torque.generator.outlet.Outlet#execute(ControllerState)
+ */
+ @Override
+ public OutletResult execute(ControllerState controllerState)
+ throws GeneratorException
+
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Start executing CopyOutlet " + getName());
+ }
+
+ try
+ {
+ InputStream inputStream
+ = configurationProvider.getResourceInputStream(path);
+ OutletResult result = new OutletResult(
+ IOUtils.toByteArray(inputStream));
+ return result;
+ }
+ catch (IOException e)
+ {
+ throw new GeneratorException("CopyOutlet with name "
+ + getName()
+ + ": cannot read Resource "
+ + path,
+ e);
+ }
+ finally
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("End executing CopyOutlet " + getName());
+ }
+ }
+ }
+
+}
Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/copy/package.html
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/copy/package.html?rev=1368426&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/copy/package.html (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/copy/package.html Thu Aug 2 11:46:37 2012
@@ -0,0 +1,25 @@
+<!--
+ 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.
+-->
+<html>
+ <head>
+ <title>Torque generator copy outlets</title>
+ </head>
+ <body>
+ <p>
+ This package defines and implements copy outlets.
+ </p>
+ </body>
+</html>
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/CamelbackOutlet.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/CamelbackOutlet.java?rev=1368426&r1=1368425&r2=1368426&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/CamelbackOutlet.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/CamelbackOutlet.java Thu Aug 2 11:46:37 2012
@@ -21,6 +21,7 @@ package org.apache.torque.generator.outl
import org.apache.torque.generator.GeneratorException;
import org.apache.torque.generator.control.ControllerState;
+import org.apache.torque.generator.outlet.OutletResult;
import org.apache.torque.generator.processor.string.Camelbacker;
import org.apache.torque.generator.processor.string.WrapReservedJavaWords;
import org.apache.torque.generator.qname.QualifiedName;
@@ -42,12 +43,12 @@ public class CamelbackOutlet extends Str
/**
* The processor which does the camelback processing.
*/
- private Camelbacker camelbacker = new Camelbacker();
+ private final Camelbacker camelbacker = new Camelbacker();
/**
* The processor which wraps reserved java words.
*/
- private WrapReservedJavaWords reservedWordsWrapper
+ private final WrapReservedJavaWords reservedWordsWrapper
= new WrapReservedJavaWords();
/** Whether reserved java words are wrapped. */
@@ -188,7 +189,7 @@ public class CamelbackOutlet extends Str
* @throws GeneratorException in processing fails.
*/
@Override
- public String execute(ControllerState controllerState)
+ public OutletResult execute(ControllerState controllerState)
throws GeneratorException
{
String classnameInput = getInput(controllerState);
@@ -198,6 +199,6 @@ public class CamelbackOutlet extends Str
{
result = reservedWordsWrapper.process(result);
}
- return result;
+ return new OutletResult(result);
}
}
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/ConstantNameOutlet.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/ConstantNameOutlet.java?rev=1368426&r1=1368425&r2=1368426&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/ConstantNameOutlet.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/ConstantNameOutlet.java Thu Aug 2 11:46:37 2012
@@ -21,6 +21,7 @@ package org.apache.torque.generator.outl
import org.apache.torque.generator.GeneratorException;
import org.apache.torque.generator.control.ControllerState;
+import org.apache.torque.generator.outlet.OutletResult;
import org.apache.torque.generator.processor.string.ConstantNameCreator;
import org.apache.torque.generator.qname.QualifiedName;
@@ -33,7 +34,7 @@ public class ConstantNameOutlet extends
/**
* The processor which does the character replacement.
*/
- private ConstantNameCreator constantNameCreator = new ConstantNameCreator();
+ private final ConstantNameCreator constantNameCreator = new ConstantNameCreator();
/**
* Constructor.
@@ -53,13 +54,13 @@ public class ConstantNameOutlet extends
* @throws GeneratorException in processing fails.
*/
@Override
- public String execute(ControllerState controllerState)
+ public OutletResult execute(ControllerState controllerState)
throws GeneratorException
{
String input = getInput(controllerState);
String result = constantNameCreator.process(input);
- return result;
+ return new OutletResult(result);
}
}
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/JavaFilenameOutlet.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/JavaFilenameOutlet.java?rev=1368426&r1=1368425&r2=1368426&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/JavaFilenameOutlet.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/JavaFilenameOutlet.java Thu Aug 2 11:46:37 2012
@@ -22,6 +22,7 @@ package org.apache.torque.generator.outl
import org.apache.torque.generator.GeneratorException;
import org.apache.torque.generator.control.ControllerState;
import org.apache.torque.generator.outlet.OutletImpl;
+import org.apache.torque.generator.outlet.OutletResult;
import org.apache.torque.generator.qname.QualifiedName;
/**
@@ -52,7 +53,7 @@ public class JavaFilenameOutlet extends
}
@Override
- public String execute(ControllerState controllerState)
+ public OutletResult execute(ControllerState controllerState)
throws GeneratorException
{
String packageName
@@ -64,6 +65,6 @@ public class JavaFilenameOutlet extends
+ "/"
+ className
+ ".java";
- return result;
+ return new OutletResult(result);
}
}
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/JavadocOutlet.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/JavadocOutlet.java?rev=1368426&r1=1368425&r2=1368426&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/JavadocOutlet.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/JavadocOutlet.java Thu Aug 2 11:46:37 2012
@@ -27,6 +27,7 @@ import org.apache.commons.lang.StringUti
import org.apache.torque.generator.GeneratorException;
import org.apache.torque.generator.control.ControllerState;
import org.apache.torque.generator.outlet.OutletImpl;
+import org.apache.torque.generator.outlet.OutletResult;
import org.apache.torque.generator.qname.QualifiedName;
/**
@@ -89,7 +90,7 @@ public class JavadocOutlet extends Outle
}
@Override
- public String execute(ControllerState controllerState)
+ public OutletResult execute(ControllerState controllerState)
throws GeneratorException
{
StringBuilder result = new StringBuilder();
@@ -112,7 +113,7 @@ public class JavadocOutlet extends Outle
}
result.append(indent).append(END_LINE).append(lineBreak);
- return result.toString();
+ return new OutletResult(result.toString());
}
/**
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/ModifySourcenameOutlet.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/ModifySourcenameOutlet.java?rev=1368426&r1=1368425&r2=1368426&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/ModifySourcenameOutlet.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/ModifySourcenameOutlet.java Thu Aug 2 11:46:37 2012
@@ -27,6 +27,7 @@ import org.apache.log4j.Logger;
import org.apache.torque.generator.GeneratorException;
import org.apache.torque.generator.control.ControllerState;
import org.apache.torque.generator.outlet.OutletImpl;
+import org.apache.torque.generator.outlet.OutletResult;
import org.apache.torque.generator.qname.QualifiedName;
/**
@@ -71,7 +72,7 @@ public class ModifySourcenameOutlet exte
}
@Override
- public String execute(ControllerState controllerState)
+ public OutletResult execute(ControllerState controllerState)
throws GeneratorException
{
@@ -82,7 +83,7 @@ public class ModifySourcenameOutlet exte
{
logger.warn("execute(): sourceFile is null, "
+ "returning the empty String");
- return "";
+ return new OutletResult("");
}
sourceName = sourceFile.getName();
}
@@ -117,7 +118,7 @@ public class ModifySourcenameOutlet exte
result = "";
}
result = prefix + result + suffix;
- return result;
+ return new OutletResult(result);
}
/**
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/NewlineOutlet.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/NewlineOutlet.java?rev=1368426&r1=1368425&r2=1368426&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/NewlineOutlet.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/NewlineOutlet.java Thu Aug 2 11:46:37 2012
@@ -21,6 +21,7 @@ package org.apache.torque.generator.outl
import org.apache.torque.generator.GeneratorException;
import org.apache.torque.generator.control.ControllerState;
+import org.apache.torque.generator.outlet.OutletResult;
import org.apache.torque.generator.qname.QualifiedName;
/**
@@ -51,7 +52,7 @@ public class NewlineOutlet extends Outle
}
@Override
- public String execute(ControllerState controllerState)
+ public OutletResult execute(ControllerState controllerState)
throws GeneratorException
{
if (count < 0)
@@ -68,7 +69,7 @@ public class NewlineOutlet extends Outle
}
result.append(NEWLINE);
}
- return result.toString();
+ return new OutletResult(result.toString());
}
/**
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/OptionOutlet.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/OptionOutlet.java?rev=1368426&r1=1368425&r2=1368426&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/OptionOutlet.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/OptionOutlet.java Thu Aug 2 11:46:37 2012
@@ -21,6 +21,7 @@ package org.apache.torque.generator.outl
import org.apache.torque.generator.GeneratorException;
import org.apache.torque.generator.control.ControllerState;
+import org.apache.torque.generator.outlet.OutletResult;
import org.apache.torque.generator.qname.QualifiedName;
/**
@@ -44,13 +45,13 @@ public class OptionOutlet extends Outlet
}
@Override
- public String execute(ControllerState controllerState)
+ public OutletResult execute(ControllerState controllerState)
throws GeneratorException
{
- return OutletUtils.getOption(
+ return new OutletResult(OutletUtils.getOption(
option,
controllerState,
- OptionOutlet.class);
+ OptionOutlet.class));
}
/**
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/PackageToPathOutlet.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/PackageToPathOutlet.java?rev=1368426&r1=1368425&r2=1368426&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/PackageToPathOutlet.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/PackageToPathOutlet.java Thu Aug 2 11:46:37 2012
@@ -21,6 +21,7 @@ package org.apache.torque.generator.outl
import org.apache.torque.generator.GeneratorException;
import org.apache.torque.generator.control.ControllerState;
+import org.apache.torque.generator.outlet.OutletResult;
import org.apache.torque.generator.qname.QualifiedName;
/**
@@ -44,10 +45,11 @@ public class PackageToPathOutlet extends
* @see org.apache.torque.generator.outlet.Outlet#execute(ControllerState)
*/
@Override
- public String execute(ControllerState controllerState)
+ public OutletResult execute(ControllerState controllerState)
throws GeneratorException
{
String packagenameInput = getInput(controllerState);
- return packagenameInput.replace('.', '/');
+ String result = packagenameInput.replace('.', '/');
+ return new OutletResult(result);
}
}
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/XmlOutlet.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/XmlOutlet.java?rev=1368426&r1=1368425&r2=1368426&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/XmlOutlet.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/outlet/java/XmlOutlet.java Thu Aug 2 11:46:37 2012
@@ -21,6 +21,7 @@ package org.apache.torque.generator.outl
import org.apache.torque.generator.GeneratorException;
import org.apache.torque.generator.control.ControllerState;
+import org.apache.torque.generator.outlet.OutletResult;
import org.apache.torque.generator.qname.QualifiedName;
import org.apache.torque.generator.source.stream.SourceToXml;
@@ -33,7 +34,7 @@ public class XmlOutlet extends OutletWit
private boolean createIdAttributes = false;
/** The XML outputter. */
- private SourceToXml sourceToXml = new SourceToXml();
+ private final SourceToXml sourceToXml = new SourceToXml();
/**
* Constructor.
*
@@ -45,14 +46,14 @@ public class XmlOutlet extends OutletWit
}
@Override
- public String execute(ControllerState controllerState)
+ public OutletResult execute(ControllerState controllerState)
throws GeneratorException
{
String result = sourceToXml.toXml(
controllerState.getRootElement(),
createIdAttributes);
- return result.toString();
+ return new OutletResult(result.toString());
}
/**
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/template/velocity/VelocityOutlet.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/template/velocity/VelocityOutlet.java?rev=1368426&r1=1368425&r2=1368426&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/template/velocity/VelocityOutlet.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/template/velocity/VelocityOutlet.java Thu Aug 2 11:46:37 2012
@@ -32,6 +32,7 @@ import org.apache.torque.generator.confi
import org.apache.torque.generator.control.ControllerState;
import org.apache.torque.generator.option.Option;
import org.apache.torque.generator.option.Options;
+import org.apache.torque.generator.outlet.OutletResult;
import org.apache.torque.generator.qname.Namespace;
import org.apache.torque.generator.qname.QualifiedName;
import org.apache.torque.generator.qname.QualifiedNameMap;
@@ -200,7 +201,7 @@ public class VelocityOutlet extends Temp
* @see org.apache.torque.generator.outlet.Outlet#execute(ControllerState)
*/
@Override
- public String execute(ControllerState controllerState)
+ public OutletResult execute(ControllerState controllerState)
throws GeneratorException
{
@@ -268,7 +269,7 @@ public class VelocityOutlet extends Temp
e);
}
- return writer.toString();
+ return new OutletResult(writer.toString());
}
finally
{
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org