You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by jg...@apache.org on 2008/02/25 23:53:28 UTC
svn commit: r631027 - in
/ibatis/trunk/java/mapper/mapper2/tools/abator/core: build/ doc/ htmldoc/
htmldoc/configreference/ htmldoc/reference/
src/org/apache/ibatis/abator/api/ src/org/apache/ibatis/abator/config/
src/org/apache/ibatis/abator/config/xm...
Author: jgbutler
Date: Mon Feb 25 14:53:25 2008
New Revision: 631027
URL: http://svn.apache.org/viewvc?rev=631027&view=rev
Log:
Abator: Further refinement and documentation for the new Comment Generator
Added:
ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/commentGenerator.html
Modified:
ibatis/trunk/java/mapper/mapper2/tools/abator/core/build/version.properties
ibatis/trunk/java/mapper/mapper2/tools/abator/core/doc/ReleaseNotes.txt
ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/abatorContext.html
ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/table.html
ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/menu.html
ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/reference/building.html
ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/whatsNew.html
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/CommentGenerator.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/AbatorContext.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/PropertyRegistry.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/AbatorConfigurationParser.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/abator-config_1_0.dtd
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/AbatorObjectFactory.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/DefaultCommentGenerator.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/dao/AbstractDAOTemplate.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/dao/BaseDAOGenerator.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/dao/BaseLegacyDAOGenerator.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/model/JavaModelGeneratorJava2Impl.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/model/JavaModelGeneratorJava5Impl.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/model/JavaModelGeneratorLegacyImpl.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/sqlmap/SqlMapGeneratorIterateImpl.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava5/abatortest/abatorConfig.xml
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/build/version.properties
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/build/version.properties?rev=631027&r1=631026&r2=631027&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/build/version.properties (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/build/version.properties Mon Feb 25 14:53:25 2008
@@ -1,4 +1,4 @@
#Abator build version info
-#Tue Feb 19 22:52:24 CST 2008
+#Mon Feb 25 15:55:41 CST 2008
version=1.1.0
-buildNum=405
+buildNum=413
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/doc/ReleaseNotes.txt
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/doc/ReleaseNotes.txt?rev=631027&r1=631026&r2=631027&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/doc/ReleaseNotes.txt (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/doc/ReleaseNotes.txt Mon Feb 25 14:53:25 2008
@@ -46,6 +46,7 @@
19. Allow rootClass and rootInterface to be specified at the table level
20. Allowed specifying a type (pre or post) for the generatedKey
element.
+21. Added a comment generator interface
-------------------------------------------------------------------------------
Version 1.0.0:
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/abatorContext.html
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/abatorContext.html?rev=631027&r1=631026&r2=631027&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/abatorContext.html (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/abatorContext.html Mon Feb 25 14:53:25 2008
@@ -112,6 +112,7 @@
<h2>Child Elements</h2>
<ul>
<li><a href="property.html"><property></a> (0..N)</li>
+ <li><a href="commentGenerator.html"><commentGenerator></a> (0 or 1)</li>
<li><a href="jdbcConnection.html"><jdbcConnection></a> (1 Required)</li>
<li><a href="javaTypeResolver.html"><javaTypeResolver></a> (0 or 1)</li>
<li><a href="javaModelGenerator.html"><javaModelGenerator></a> (1 Required)</li>
Added: ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/commentGenerator.html
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/commentGenerator.html?rev=631027&view=auto
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/commentGenerator.html (added)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/commentGenerator.html Mon Feb 25 14:53:25 2008
@@ -0,0 +1,91 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>The <commentGenerator> Element</title>
+ <link type="text/css" rel="stylesheet" href="../abator.css"/>
+</head>
+<body>
+<h1>The <commentGenerator> Element</h1>
+<p>The <commentGenerator> element is used to define properties of the Comment Generator.
+The Comment Generator is used to generate comments for the various elements generated by Abator
+(Java fields, Java methods, XML elements, etc.).
+The default Comment Generator adds JavaDoc comments to all generated Java elements to enable
+the Java merge functionality in the Eclipse plugin. Also, comments are added to each
+generated XML element. The purpose of the comments is also to inform users that the
+elements are generated and are subject to regeneration (i.e. - they shouldn't be
+altered). This element is an optional child element
+of the <a href="abatorContext.html"><abatorContext></a> element.</p>
+
+<p>The default implementation is <code>org.apache.ibatis.abator.internal.DefaultCommentGenerator</code>.
+The default implementation is designed for extensibility if you only want to modify
+certain behaviors.</p>
+
+<h2>Required Attributes</h2>
+<p>None</p>
+
+<h2>Optional Attributes</h2>
+<table border="1" cellspacing="0" cellpadding="5">
+ <tr>
+ <th>Attribute</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td valign="top">type</td>
+ <td>This may be used to specify the type of the user provided Comment Generator.
+ The class must implement the interface org.apache.ibatis.abator.api.CommentGenerator,
+ and must have a public default constructor. The attribute also accepts
+ the special value DEFAULT in which case the default implementation will
+ be used (this has the same effect as not specifying the type).</td>
+ </tr>
+</table>
+
+<h2>Child Elements</h2>
+<ul>
+ <li><a href="property.html"><property></a> (0..N)</li>
+</ul>
+
+<h2>Supported Properties</h2>
+<p>This table lists the properties of the default comment generator that can be
+specified with the <a href="property.html"><property></a> child element:</p>
+<table border="1" cellspacing="0" cellpadding="5">
+ <tr>
+ <th>Property Name</th>
+ <th>Property Values</th>
+ </tr>
+ <tr>
+ <td valign="top">suppressDate</td>
+ <td>
+ This property is used to specify whether Abator will include the generation
+ timestamp in the generated comments.
+ The property supports these values:
+ <table>
+ <tr>
+ <th valign="top">false</th>
+ <td><i>This is the default value</i>
+ <br/>When the property is false or unspecified, all generated comments
+ will include the timestamp when the element was generated.
+ </td>
+ </tr>
+ <tr>
+ <th valign="top">true</th>
+ <td>When the property is true, no timestamp will be added to the
+ generated comments.
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+</table>
+
+<h2>Example</h2>
+<p>This element specifies that we do not want the timestamp added to any generated comment:</p>
+<pre>
+<commentGenerator>
+ <property name="suppressDate" value="true" />
+</commentGenerator>
+</pre>
+
+</body>
+</html>
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/table.html
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/table.html?rev=631027&r1=631026&r2=631027&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/table.html (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/configreference/table.html Mon Feb 25 14:53:25 2008
@@ -240,6 +240,7 @@
<ul>
<li><a href="property.html"><property></a> (0..N)</li>
<li><a href="generatedKey.html"><generatedKey></a> (0 or 1)</li>
+ <li><a href="columnRenamingRule.html"><columnRenamingRule></a> (0 or 1)</li>
<li><a href="columnOverride.html"><columnOverride></a> (0..N)</li>
<li><a href="ignoreColumn.html"><ignoreColumn></a> (0..N)</li>
</ul>
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/menu.html
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/menu.html?rev=631027&r1=631026&r2=631027&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/menu.html (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/menu.html Mon Feb 25 14:53:25 2008
@@ -21,6 +21,7 @@
<a href="configreference/classPathEntry.html" target="mainFrame"><classPathEntry></a><br/>
<a href="configreference/columnOverride.html" target="mainFrame"><columnOverride></a><br/>
<a href="configreference/columnRenamingRule.html" target="mainFrame"><columnRenamingRule></a><br/>
+ <a href="configreference/commentGenerator.html" target="mainFrame"><commentGenerator></a><br/>
<a href="configreference/daoGenerator.html" target="mainFrame"><daoGenerator></a><br/>
<a href="configreference/generatedKey.html" target="mainFrame"><generatedKey></a><br/>
<a href="configreference/ignoreColumn.html" target="mainFrame"><ignoreColumn></a><br/>
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/reference/building.html
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/reference/building.html?rev=631027&r1=631026&r2=631027&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/reference/building.html (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/reference/building.html Mon Feb 25 14:53:25 2008
@@ -22,6 +22,10 @@
(You may use any SubVersion client you prefer. We are recommend
<a target="_blank" href="http://tortoisesvn.tigris.org/">TortoiseSVN</a>.)
</li>
+ <li>The build file requires that ANT_HOME and JAVA_HOME environment variables be defined.
+ If they are not already defined on your system, then
+ modify the file <code>../build/setupCmdLine.bat</code> to specify
+ the proper values on your machine.</li>
<li>Run the Ant build script by running the batch file <code>../build/build.bat</code>
from the checked out directory.</li>
</ol>
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/whatsNew.html
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/whatsNew.html?rev=631027&r1=631026&r2=631027&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/whatsNew.html (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/whatsNew.html Mon Feb 25 14:53:25 2008
@@ -9,6 +9,11 @@
<body>
<h1>What's New in Abator</h1>
<h2>Version 1.1.0</h2>
+<h3>Announcements</h3>
+<ul>
+ <li>The next release of Abator will require JRE 5.0 or higher.</li>
+</ul>
+
<h3>New Generated Methods</h3>
<p>Abator will generate these new methods:</p>
<dl>
@@ -96,13 +101,17 @@
the entire config file.</li>
<li>Exposed new support for selecting tables and/or contexts to the
command line and the Ant task - this has added an advanced syntax to the command
- line for Abator.</li>
+ line for Abator. See the
+ <a href="running.html">Running Abator</a> reference page for more information.</li>
<li><code>rootClass</code> and <code>rootInterface</code> may now be specified for each table.
See the <a href="configreference/table.html"><table></a>
reference page for more information.</li>
<li>Allowed specifying a type (pre or post) for the generated key element. See the
<a href="configreference/generatedKey.html"><generatedKey></a>
reference page for more information</li>
+ <li>Added a comment generator interface to enable generation of custom comments.
+ See the <a href="configreference/commentGenerator.html"><commentGenerator></a>
+ reference page for more information.</li>
</ul>
<h2>Version 1.0.0</h2>
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/CommentGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/CommentGenerator.java?rev=631027&r1=631026&r2=631027&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/CommentGenerator.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/CommentGenerator.java Mon Feb 25 14:53:25 2008
@@ -15,21 +15,47 @@
*/
package org.apache.ibatis.abator.api;
+import java.util.Properties;
+
import org.apache.ibatis.abator.api.dom.java.CompilationUnit;
import org.apache.ibatis.abator.api.dom.java.Field;
import org.apache.ibatis.abator.api.dom.java.InnerClass;
import org.apache.ibatis.abator.api.dom.java.InnerEnum;
import org.apache.ibatis.abator.api.dom.java.Method;
-import org.apache.ibatis.abator.api.dom.xml.Document;
import org.apache.ibatis.abator.api.dom.xml.XmlElement;
-import org.apache.ibatis.abator.internal.db.ColumnDefinition;
/**
+ * Implementations of this interface are used to generate comments
+ * for the various artifacts generated by abator.
*
* @author Jeff Butler
*/
public interface CommentGenerator {
+ /**
+ * Adds properties for this instance from any properties configured
+ * in the CommentGenerator configuration.
+ *
+ * This method will be called before any of the other methods.
+ *
+ * @param properties
+ * All properties from the configuration
+ */
+ void addConfigurationProperties(Properties properties);
+
+ /**
+ * This method should add a Javadoc comment to the specified field.
+ * The field is related to the specified table and is used to
+ * hold the value of the specified column.<p>
+ *
+ * <b>Important:</b> This method should add a the nonstandard
+ * JavaDoc tag "@abatorgenerated" to the comment. Without this
+ * tag, the Eclipse based Java merge feature will fail.
+ *
+ * @param field
+ * @param table
+ * @param columnName
+ */
public void addFieldComment(Field field, FullyQualifiedTable table, String columnName);
public void addFieldComment(Field field, FullyQualifiedTable table);
@@ -38,19 +64,44 @@
public void addEnumComment(InnerEnum innerEnum, FullyQualifiedTable table);
- public void addGetterComment(Method method, FullyQualifiedTable table, ColumnDefinition columnDefinition);
+ public void addGetterComment(Method method, FullyQualifiedTable table, String columnName);
- public void addSetterComment(Method method, FullyQualifiedTable table, ColumnDefinition columnDefinition);
+ public void addSetterComment(Method method, FullyQualifiedTable table, String columnName);
public void addGeneralMethodComment(Method method, FullyQualifiedTable table);
+ /**
+ * This method is called to add a file level comment to a generated
+ * java file. This method could be used to add a general file
+ * comment (such as a copyright notice). However, note that the Java
+ * file merge function in Eclipse does not deal with this comment.
+ * If you run Abator repeatedly, you will only retain the comment
+ * from the initial run.<p>
+ *
+ * The default implementation does nothing.
+ *
+ * @param compilationUnit
+ */
public void addJavaFileComment(CompilationUnit compilationUnit);
/**
- * Adds a suitable comment to warn users that the element was generated, and
- * when it was generated.
+ * This method should add a suitable comment as a child element of the
+ * specified xmlElement to warn users that the element was generated and
+ * is subject to regeneration.
*/
public void addComment(XmlElement xmlElement);
- public void addComment(Document document);
+ /**
+ * This method is called to add a comment as the first child of
+ * the root element. This method could be used to add a general file
+ * comment (such as a copyright notice). However, note that the XML
+ * file merge function does not deal with this comment. If you run
+ * Abator repeatedly, you will only retain the comment from the
+ * initial run.<p>
+ *
+ * The default implementation does nothing.
+ *
+ * @param rootElement
+ */
+ public void addRootComment(XmlElement rootElement);
}
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/AbatorContext.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/AbatorContext.java?rev=631027&r1=631026&r2=631027&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/AbatorContext.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/AbatorContext.java Mon Feb 25 14:53:25 2008
@@ -33,7 +33,6 @@
import org.apache.ibatis.abator.api.dom.xml.Attribute;
import org.apache.ibatis.abator.api.dom.xml.XmlElement;
import org.apache.ibatis.abator.internal.AbatorObjectFactory;
-import org.apache.ibatis.abator.internal.DefaultCommentGenerator;
import org.apache.ibatis.abator.internal.NullProgressCallback;
import org.apache.ibatis.abator.internal.db.ConnectionFactory;
import org.apache.ibatis.abator.internal.db.DatabaseIntrospector;
@@ -70,6 +69,8 @@
private boolean suppressTypeWarnings;
+ private CommentGeneratorConfiguration commentGeneratorConfiguration;
+
private CommentGenerator commentGenerator;
/**
@@ -102,9 +103,6 @@
}
tableConfigurations = new ArrayList();
-
- // TODO - expose this as a configurable property
- this.commentGenerator = new DefaultCommentGenerator();
}
public void addTableConfiguration(TableConfiguration tc) {
@@ -384,6 +382,10 @@
addPropertyXmlElements(xmlElement);
+ if (commentGeneratorConfiguration != null) {
+ xmlElement.addElement(commentGeneratorConfiguration.toXmlElement());
+ }
+
if (jdbcConnectionConfiguration != null) {
xmlElement.addElement(jdbcConnectionConfiguration.toXmlElement());
}
@@ -442,10 +444,19 @@
}
public CommentGenerator getCommentGenerator() {
+ if (commentGenerator == null) {
+ commentGenerator = AbatorObjectFactory.createCommentGenerator(this);
+ }
+
return commentGenerator;
}
- public void setCommentGenerator(CommentGenerator commentGenerator) {
- this.commentGenerator = commentGenerator;
+ public CommentGeneratorConfiguration getCommentGeneratorConfiguration() {
+ return commentGeneratorConfiguration;
+ }
+
+ public void setCommentGeneratorConfiguration(
+ CommentGeneratorConfiguration commentGeneratorConfiguration) {
+ this.commentGeneratorConfiguration = commentGeneratorConfiguration;
}
}
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/PropertyRegistry.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/PropertyRegistry.java?rev=631027&r1=631026&r2=631027&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/PropertyRegistry.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/PropertyRegistry.java Mon Feb 25 14:53:25 2008
@@ -53,4 +53,6 @@
public static final String TYPE_RESOLVER_FORCE_BIG_DECIMALS = "forceBigDecimals"; //$NON-NLS-1$
public static final String MODEL_GENERATOR_TRIM_STRINGS = "trimStrings"; //$NON-NLS-1$
+
+ public static final String COMMENT_GENERATOR_SUPPRESS_DATE = "suppressDate"; //$NON-NLS-1$
}
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/AbatorConfigurationParser.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/AbatorConfigurationParser.java?rev=631027&r1=631026&r2=631027&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/AbatorConfigurationParser.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/AbatorConfigurationParser.java Mon Feb 25 14:53:25 2008
@@ -33,6 +33,7 @@
import org.apache.ibatis.abator.config.AbatorContext;
import org.apache.ibatis.abator.config.ColumnOverride;
import org.apache.ibatis.abator.config.ColumnRenamingRule;
+import org.apache.ibatis.abator.config.CommentGeneratorConfiguration;
import org.apache.ibatis.abator.config.DAOGeneratorConfiguration;
import org.apache.ibatis.abator.config.GeneratedKey;
import org.apache.ibatis.abator.config.IgnoredColumn;
@@ -255,6 +256,8 @@
if ("property".equals(childNode.getNodeName())) { //$NON-NLS-1$
parseProperty(abatorContext, childNode);
+ } else if ("commentGenerator".equals(childNode.getNodeName())) { //$NON-NLS-1$
+ parseCommentGenerator(abatorContext, childNode);
} else if ("jdbcConnection".equals(childNode.getNodeName())) { //$NON-NLS-1$
parseJdbcConnection(abatorContext, childNode);
} else if ("javaModelGenerator".equals(childNode.getNodeName())) { //$NON-NLS-1$
@@ -697,5 +700,31 @@
}
return newString;
+ }
+
+ private void parseCommentGenerator(AbatorContext abatorContext, Node node) {
+ CommentGeneratorConfiguration commentGeneratorConfiguration = new CommentGeneratorConfiguration();
+
+ abatorContext.setCommentGeneratorConfiguration(commentGeneratorConfiguration);
+
+ Properties attributes = parseAttributes(node);
+ String type = attributes.getProperty("type"); //$NON-NLS-1$
+
+ if (StringUtility.stringHasValue(type)) {
+ commentGeneratorConfiguration.setConfigurationType(type);
+ }
+
+ NodeList nodeList = node.getChildNodes();
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ Node childNode = nodeList.item(i);
+
+ if (childNode.getNodeType() != 1) {
+ continue;
+ }
+
+ if ("property".equals(childNode.getNodeName())) { //$NON-NLS-1$
+ parseProperty(commentGeneratorConfiguration, childNode);
+ }
+ }
}
}
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/abator-config_1_0.dtd
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/abator-config_1_0.dtd?rev=631027&r1=631026&r2=631027&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/abator-config_1_0.dtd (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/abator-config_1_0.dtd Mon Feb 25 14:53:25 2008
@@ -50,7 +50,7 @@
The abatorContext element is used to describe a context for generating files, and the source
tables.
-->
-<!ELEMENT abatorContext (property*, jdbcConnection, javaTypeResolver?, javaModelGenerator,
+<!ELEMENT abatorContext (property*, commentGenerator?, jdbcConnection, javaTypeResolver?, javaModelGenerator,
sqlMapGenerator, daoGenerator?, table+)>
<!ATTLIST abatorContext id ID #IMPLIED
defaultModelType CDATA #IMPLIED
@@ -196,4 +196,12 @@
<!ATTLIST columnRenamingRule
searchString CDATA #REQUIRED
replaceString CDATA #IMPLIED>
+
+<!--
+ The commentGenerator element is used to define properties of the Comment Generator.
+ The Comment Generator adds comments to generated elements.
+-->
+<!ELEMENT commentGenerator (property*)>
+<!ATTLIST commentGenerator
+ type CDATA #IMPLIED>
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/AbatorObjectFactory.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/AbatorObjectFactory.java?rev=631027&r1=631026&r2=631027&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/AbatorObjectFactory.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/AbatorObjectFactory.java Mon Feb 25 14:53:25 2008
@@ -17,11 +17,13 @@
import java.util.List;
+import org.apache.ibatis.abator.api.CommentGenerator;
import org.apache.ibatis.abator.api.DAOGenerator;
import org.apache.ibatis.abator.api.JavaModelGenerator;
import org.apache.ibatis.abator.api.JavaTypeResolver;
import org.apache.ibatis.abator.api.SqlMapGenerator;
import org.apache.ibatis.abator.config.AbatorContext;
+import org.apache.ibatis.abator.config.CommentGeneratorConfiguration;
import org.apache.ibatis.abator.config.DAOGeneratorConfiguration;
import org.apache.ibatis.abator.config.JavaModelGeneratorConfiguration;
import org.apache.ibatis.abator.config.JavaTypeResolverConfiguration;
@@ -162,4 +164,25 @@
return answer;
}
+
+ public static CommentGenerator createCommentGenerator(AbatorContext context) {
+
+ CommentGeneratorConfiguration config = context.getCommentGeneratorConfiguration();
+ CommentGenerator answer;
+
+ String type;
+ if (config == null || config.getConfigurationType() == null) {
+ type = DefaultCommentGenerator.class.getName();
+ } else {
+ type = config.getConfigurationType();
+ }
+
+ answer = (CommentGenerator) createObject(type);
+
+ if (config != null) {
+ answer.addConfigurationProperties(config.getProperties());
+ }
+
+ return answer;
+ }
}
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/DefaultCommentGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/DefaultCommentGenerator.java?rev=631027&r1=631026&r2=631027&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/DefaultCommentGenerator.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/DefaultCommentGenerator.java Mon Feb 25 14:53:25 2008
@@ -17,6 +17,7 @@
package org.apache.ibatis.abator.internal;
import java.util.Date;
+import java.util.Properties;
import org.apache.ibatis.abator.api.CommentGenerator;
import org.apache.ibatis.abator.api.FullyQualifiedTable;
@@ -24,17 +25,27 @@
import org.apache.ibatis.abator.api.dom.java.Field;
import org.apache.ibatis.abator.api.dom.java.InnerClass;
import org.apache.ibatis.abator.api.dom.java.InnerEnum;
+import org.apache.ibatis.abator.api.dom.java.JavaElement;
import org.apache.ibatis.abator.api.dom.java.Method;
-import org.apache.ibatis.abator.api.dom.xml.Document;
+import org.apache.ibatis.abator.api.dom.java.Parameter;
import org.apache.ibatis.abator.api.dom.xml.TextElement;
import org.apache.ibatis.abator.api.dom.xml.XmlElement;
-import org.apache.ibatis.abator.internal.db.ColumnDefinition;
+import org.apache.ibatis.abator.config.PropertyRegistry;
/**
* @author Jeff Butler
*
*/
public class DefaultCommentGenerator implements CommentGenerator {
+
+ private Properties properties;
+ private boolean suppressDate;
+
+ public DefaultCommentGenerator() {
+ super();
+ properties = new Properties();
+ suppressDate = false;
+ }
public void addFieldComment(Field field, FullyQualifiedTable table, String columnName) {
StringBuffer sb = new StringBuffer();
@@ -48,12 +59,7 @@
sb.append(columnName);
field.addJavaDocLine(sb.toString());
- field.addJavaDocLine(" *"); //$NON-NLS-1$
-
- sb.setLength(0);
- sb.append(" * @abatorgenerated "); //$NON-NLS-1$
- sb.append(new Date());
- field.addJavaDocLine(sb.toString());
+ addAbatorJavadocTag(field);
field.addJavaDocLine(" */"); //$NON-NLS-1$
}
@@ -68,12 +74,7 @@
sb.append(table);
field.addJavaDocLine(sb.toString());
- field.addJavaDocLine(" *"); //$NON-NLS-1$
-
- sb.setLength(0);
- sb.append(" * @abatorgenerated "); //$NON-NLS-1$
- sb.append(new Date());
- field.addJavaDocLine(sb.toString());
+ addAbatorJavadocTag(field);
field.addJavaDocLine(" */"); //$NON-NLS-1$
}
@@ -88,12 +89,7 @@
sb.append(table);
innerClass.addJavaDocLine(sb.toString());
- innerClass.addJavaDocLine(" *"); //$NON-NLS-1$
-
- sb.setLength(0);
- sb.append(" * @abatorgenerated "); //$NON-NLS-1$
- sb.append(new Date());
- innerClass.addJavaDocLine(sb.toString());
+ addAbatorJavadocTag(innerClass);
innerClass.addJavaDocLine(" */"); //$NON-NLS-1$
}
@@ -108,17 +104,12 @@
sb.append(table);
innerEnum.addJavaDocLine(sb.toString());
- innerEnum.addJavaDocLine(" *"); //$NON-NLS-1$
-
- sb.setLength(0);
- sb.append(" * @abatorgenerated "); //$NON-NLS-1$
- sb.append(new Date());
- innerEnum.addJavaDocLine(sb.toString());
+ addAbatorJavadocTag(innerEnum);
innerEnum.addJavaDocLine(" */"); //$NON-NLS-1$
}
- public void addGetterComment(Method method, FullyQualifiedTable table, ColumnDefinition columnDefinition) {
+ public void addGetterComment(Method method, FullyQualifiedTable table, String columnName) {
StringBuffer sb = new StringBuffer();
method.addJavaDocLine("/**"); //$NON-NLS-1$
@@ -127,7 +118,7 @@
sb.append(" * This method returns the value of the database column "); //$NON-NLS-1$
sb.append(table);
sb.append('.');
- sb.append(columnDefinition.getActualColumnName());
+ sb.append(columnName);
method.addJavaDocLine(sb.toString());
method.addJavaDocLine(" *"); //$NON-NLS-1$
@@ -136,20 +127,15 @@
sb.append(" * @return the value of "); //$NON-NLS-1$
sb.append(table);
sb.append('.');
- sb.append(columnDefinition.getActualColumnName());
+ sb.append(columnName);
method.addJavaDocLine(sb.toString());
- method.addJavaDocLine(" *"); //$NON-NLS-1$
-
- sb.setLength(0);
- sb.append(" * @abatorgenerated "); //$NON-NLS-1$
- sb.append(new Date());
- method.addJavaDocLine(sb.toString());
+ addAbatorJavadocTag(method);
method.addJavaDocLine(" */"); //$NON-NLS-1$
}
- public void addSetterComment(Method method, FullyQualifiedTable table, ColumnDefinition columnDefinition) {
+ public void addSetterComment(Method method, FullyQualifiedTable table, String columnName) {
StringBuffer sb = new StringBuffer();
method.addJavaDocLine("/**"); //$NON-NLS-1$
@@ -158,26 +144,22 @@
sb.append(" * This method sets the value of the database column "); //$NON-NLS-1$
sb.append(table);
sb.append('.');
- sb.append(columnDefinition.getActualColumnName());
+ sb.append(columnName);
method.addJavaDocLine(sb.toString());
method.addJavaDocLine(" *"); //$NON-NLS-1$
+ Parameter parm = (Parameter) method.getParameters().get(0);
sb.setLength(0);
sb.append(" * @param "); //$NON-NLS-1$
- sb.append(columnDefinition.getJavaProperty());
+ sb.append(parm.getName());
sb.append(" the value for "); //$NON-NLS-1$
sb.append(table);
sb.append('.');
- sb.append(columnDefinition.getActualColumnName());
+ sb.append(columnName);
method.addJavaDocLine(sb.toString());
- method.addJavaDocLine(" *"); //$NON-NLS-1$
-
- sb.setLength(0);
- sb.append(" * @abatorgenerated "); //$NON-NLS-1$
- sb.append(new Date());
- method.addJavaDocLine(sb.toString());
+ addAbatorJavadocTag(method);
method.addJavaDocLine(" */"); //$NON-NLS-1$
}
@@ -192,12 +174,7 @@
sb.append(table);
method.addJavaDocLine(sb.toString());
- method.addJavaDocLine(" *"); //$NON-NLS-1$
-
- sb.setLength(0);
- sb.append(" * @abatorgenerated "); //$NON-NLS-1$
- sb.append(new Date());
- method.addJavaDocLine(sb.toString());
+ addAbatorJavadocTag(method);
method.addJavaDocLine(" */"); //$NON-NLS-1$
}
@@ -216,17 +193,64 @@
xmlElement.addElement(new TextElement(
" WARNING - This element is automatically generated by Abator for iBATIS, do not modify.")); //$NON-NLS-1$
- StringBuffer sb = new StringBuffer();
- sb.append(" This element was generated on "); //$NON-NLS-1$
- sb.append(new Date());
- sb.append('.');
- xmlElement.addElement(new TextElement(sb.toString()));
+ String s = getDateString();
+ if (s != null) {
+ StringBuffer sb = new StringBuffer();
+ sb.append(" This element was generated on "); //$NON-NLS-1$
+ sb.append(s);
+ sb.append('.');
+ xmlElement.addElement(new TextElement(sb.toString()));
+ }
xmlElement.addElement(new TextElement("-->")); //$NON-NLS-1$
}
- public void addComment(Document document) {
+ public void addRootComment(XmlElement rootElement) {
// add no document level comments by default
;
+ }
+
+ public void addConfigurationProperties(Properties properties) {
+ this.properties.putAll(properties);
+
+ if ("true".equalsIgnoreCase(properties.getProperty(PropertyRegistry.COMMENT_GENERATOR_SUPPRESS_DATE))) { //$NON-NLS-1$
+ suppressDate = true;
+ }
+ }
+
+ /**
+ * This method adds the custom javadoc tag for
+ * Abator. You may do nothing if you do not wish to include
+ * the Javadoc tag - however, if you do not include the Javadoc
+ * tag then the Java merge capability of the eclipse plugin will
+ * break.
+ *
+ * @param javaElement
+ */
+ protected void addAbatorJavadocTag(JavaElement javaElement) {
+ javaElement.addJavaDocLine(" *"); //$NON-NLS-1$
+ StringBuffer sb = new StringBuffer();
+ sb.append(" * @abatorgenerated"); //$NON-NLS-1$
+ String s = getDateString();
+ if (s != null) {
+ sb.append(' ');
+ sb.append(s);
+ }
+ javaElement.addJavaDocLine(sb.toString());
+ }
+
+ /**
+ * This method returns a formated date string to include in the
+ * Javadoc tag and XML comments. You may return null if you do not want
+ * the date in these documentation elements.
+ *
+ * @return
+ */
+ protected String getDateString() {
+ if (suppressDate) {
+ return null;
+ } else {
+ return new Date().toString();
+ }
}
}
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/dao/AbstractDAOTemplate.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/dao/AbstractDAOTemplate.java?rev=631027&r1=631026&r2=631027&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/dao/AbstractDAOTemplate.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/dao/AbstractDAOTemplate.java Mon Feb 25 14:53:25 2008
@@ -69,7 +69,6 @@
public Method getConstructorClone(CommentGenerator commentGenerator, FullyQualifiedJavaType type, FullyQualifiedTable table) {
Method answer = new Method();
- commentGenerator.addGeneralMethodComment(answer, table);
answer.setConstructor(true);
answer.setName(type.getShortName());
answer.setVisibility(constructorTemplate.getVisibility());
@@ -86,6 +85,8 @@
answer.addException((FullyQualifiedJavaType) iter.next());
}
+ commentGenerator.addGeneralMethodComment(answer, table);
+
return answer;
}
@@ -152,13 +153,13 @@
Field field = new Field();
Field oldField = (Field) iter.next();
- commentGenerator.addFieldComment(field, table);
field.setInitializationString(oldField.getInitializationString());
field.setModifierFinal(oldField.isModifierFinal());
field.setModifierStatic(oldField.isModifierStatic());
field.setName(oldField.getName());
field.setType(oldField.getType());
field.setVisibility(oldField.getVisibility());
+ commentGenerator.addFieldComment(field, table);
answer.add(field);
}
@@ -182,8 +183,6 @@
method.addException((FullyQualifiedJavaType) iter2.next());
}
- commentGenerator.addGeneralMethodComment(method, table);
-
iter2 = oldMethod.getParameters().iterator();
while (iter2.hasNext()) {
method.addParameter((Parameter) iter2.next());
@@ -195,6 +194,8 @@
method.setName(oldMethod.getName());
method.setReturnType(oldMethod.getReturnType());
method.setVisibility(oldMethod.getVisibility());
+
+ commentGenerator.addGeneralMethodComment(method, table);
answer.add(method);
}
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/dao/BaseDAOGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/dao/BaseDAOGenerator.java?rev=631027&r1=631026&r2=631027&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/dao/BaseDAOGenerator.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/dao/BaseDAOGenerator.java Mon Feb 25 14:53:25 2008
@@ -240,7 +240,6 @@
FullyQualifiedTable table = introspectedTable.getTable();
FullyQualifiedJavaType type = getDAOImplementationType(table);
TopLevelClass answer = new TopLevelClass(type);
- commentGenerator.addJavaFileComment(answer);
answer.setVisibility(JavaVisibility.PUBLIC);
answer.setSuperClass(daoTemplate.getSuperClass());
answer.addImportedType(daoTemplate.getSuperClass());
@@ -251,6 +250,8 @@
while (iter.hasNext()) {
answer.addImportedType((FullyQualifiedJavaType) iter.next());
}
+
+ commentGenerator.addJavaFileComment(answer);
// add constructor
Method method = daoTemplate.getConstructorClone(commentGenerator,
@@ -446,7 +447,6 @@
protected Interface getDAOInterface(IntrospectedTable introspectedTable) {
FullyQualifiedTable table = introspectedTable.getTable();
Interface answer = new Interface(getDAOInterfaceType(table));
- abatorContext.getCommentGenerator().addJavaFileComment(answer);
answer.setVisibility(JavaVisibility.PUBLIC);
String rootInterface = introspectedTable.getTableConfigurationProperty(PropertyRegistry.ANY_ROOT_INTERFACE);
@@ -465,6 +465,8 @@
answer.addImportedType((FullyQualifiedJavaType) iter.next());
}
+ abatorContext.getCommentGenerator().addJavaFileComment(answer);
+
AbatorRules rules = introspectedTable.getRules();
List methods;
@@ -631,7 +633,6 @@
FullyQualifiedTable table = introspectedTable.getTable();
Method method = new Method();
- abatorContext.getCommentGenerator().addGeneralMethodComment(method, table);
FullyQualifiedJavaType returnType;
if (introspectedTable.getGeneratedKey() != null) {
@@ -667,6 +668,8 @@
compilationUnit.addImportedType(fqjt);
}
+ abatorContext.getCommentGenerator().addGeneralMethodComment(method, table);
+
if (!interfaceMethod) {
// generate the implementation method
StringBuffer sb = new StringBuffer();
@@ -723,7 +726,6 @@
compilationUnit.addImportedType(parameterType);
Method method = new Method();
- abatorContext.getCommentGenerator().addGeneralMethodComment(method, table);
method.setVisibility(JavaVisibility.PUBLIC);
method.setReturnType(FullyQualifiedJavaType.getIntInstance());
method.setName(methodNameCalculator.getUpdateByPrimaryKeyWithoutBLOBsMethodName(introspectedTable));
@@ -736,6 +738,8 @@
compilationUnit.addImportedType(fqjt);
}
+ abatorContext.getCommentGenerator().addGeneralMethodComment(method, table);
+
if (!interfaceMethod) {
// generate the implementation method
StringBuffer sb = new StringBuffer();
@@ -771,7 +775,6 @@
compilationUnit.addImportedType(parameterType);
Method method = new Method();
- abatorContext.getCommentGenerator().addGeneralMethodComment(method, table);
method.setVisibility(JavaVisibility.PUBLIC);
method.setReturnType(FullyQualifiedJavaType.getIntInstance());
method.setName(methodNameCalculator.getUpdateByPrimaryKeyWithBLOBsMethodName(introspectedTable));
@@ -784,6 +787,8 @@
compilationUnit.addImportedType(fqjt);
}
+ abatorContext.getCommentGenerator().addGeneralMethodComment(method, table);
+
if (!interfaceMethod) {
// generate the implementation method
StringBuffer sb = new StringBuffer();
@@ -819,7 +824,6 @@
compilationUnit.addImportedType(parameterType);
Method method = new Method();
- abatorContext.getCommentGenerator().addGeneralMethodComment(method, table);
method.setVisibility(JavaVisibility.PUBLIC);
method.setReturnType(FullyQualifiedJavaType.getIntInstance());
method.setName(methodNameCalculator.getUpdateByPrimaryKeySelectiveMethodName(introspectedTable));
@@ -832,6 +836,8 @@
compilationUnit.addImportedType(fqjt);
}
+ abatorContext.getCommentGenerator().addGeneralMethodComment(method, table);
+
if (!interfaceMethod) {
// generate the implementation method
StringBuffer sb = new StringBuffer();
@@ -866,7 +872,6 @@
.getNewListInstance());
Method method = new Method();
- abatorContext.getCommentGenerator().addGeneralMethodComment(method, table);
method.setVisibility(exampleMethodVisibility);
FullyQualifiedJavaType returnType;
@@ -899,6 +904,8 @@
compilationUnit.addImportedType(fqjt);
}
+ abatorContext.getCommentGenerator().addGeneralMethodComment(method, table);
+
if (!interfaceMethod) {
// generate the implementation method
StringBuffer sb = new StringBuffer();
@@ -941,7 +948,6 @@
.getNewListInstance());
Method method = new Method();
- abatorContext.getCommentGenerator().addGeneralMethodComment(method, table);
method.setVisibility(exampleMethodVisibility);
FullyQualifiedJavaType returnType;
@@ -972,6 +978,8 @@
compilationUnit.addImportedType(fqjt);
}
+ abatorContext.getCommentGenerator().addGeneralMethodComment(method, table);
+
if (!interfaceMethod) {
// generate the implementation method
@@ -1007,7 +1015,6 @@
FullyQualifiedTable table = introspectedTable.getTable();
Method method = new Method();
- abatorContext.getCommentGenerator().addGeneralMethodComment(method, table);
method.setVisibility(JavaVisibility.PUBLIC);
FullyQualifiedJavaType returnType =
@@ -1038,6 +1045,8 @@
compilationUnit.addImportedType(fqjt);
}
+ abatorContext.getCommentGenerator().addGeneralMethodComment(method, table);
+
if (!interfaceMethod) {
// generate the implementation method
StringBuffer sb = new StringBuffer();
@@ -1099,7 +1108,6 @@
compilationUnit.addImportedType(type);
Method method = new Method();
- abatorContext.getCommentGenerator().addGeneralMethodComment(method, table);
method.setVisibility(exampleMethodVisibility);
method.setReturnType(FullyQualifiedJavaType.getIntInstance());
method.setName(methodNameCalculator.getDeleteByExampleMethodName(introspectedTable));
@@ -1112,6 +1120,8 @@
compilationUnit.addImportedType(fqjt);
}
+ abatorContext.getCommentGenerator().addGeneralMethodComment(method, table);
+
if (!interfaceMethod) {
// generate the implementation method
StringBuffer sb = new StringBuffer();
@@ -1137,7 +1147,6 @@
FullyQualifiedTable table = introspectedTable.getTable();
Method method = new Method();
- abatorContext.getCommentGenerator().addGeneralMethodComment(method, table);
method.setVisibility(JavaVisibility.PUBLIC);
method.setReturnType(FullyQualifiedJavaType.getIntInstance());
method.setName(methodNameCalculator.getDeleteByPrimaryKeyMethodName(introspectedTable));
@@ -1163,6 +1172,8 @@
compilationUnit.addImportedType(fqjt);
}
+ abatorContext.getCommentGenerator().addGeneralMethodComment(method, table);
+
if (!interfaceMethod) {
// generate the implementation method
StringBuffer sb = new StringBuffer();
@@ -1221,7 +1232,6 @@
compilationUnit.addImportedType(type);
Method method = new Method();
- abatorContext.getCommentGenerator().addGeneralMethodComment(method, table);
method.setVisibility(exampleMethodVisibility);
method.setReturnType(FullyQualifiedJavaType.getIntInstance());
method.setName(methodNameCalculator.getCountByExampleMethodName(introspectedTable));
@@ -1234,6 +1244,8 @@
compilationUnit.addImportedType(fqjt);
}
+ abatorContext.getCommentGenerator().addGeneralMethodComment(method, table);
+
if (!interfaceMethod) {
// generate the implementation method
StringBuffer sb = new StringBuffer();
@@ -1328,14 +1340,12 @@
compilationUnit.addImportedType(parameterType);
Method method = new Method();
- abatorContext.getCommentGenerator().addGeneralMethodComment(method, table);
method.setVisibility(JavaVisibility.PUBLIC);
method.setReturnType(FullyQualifiedJavaType.getIntInstance());
method.setName(methodNameCalculator.getUpdateByExampleSelectiveMethodName(introspectedTable));
method.addParameter(new Parameter(parameterType, "record")); //$NON-NLS-1$
method.addParameter(new Parameter(javaModelGenerator.getExampleType(table), "example")); //$NON-NLS-1$
-
Iterator iter = daoTemplate.getCheckedExceptions().iterator();
while (iter.hasNext()) {
FullyQualifiedJavaType fqjt = (FullyQualifiedJavaType) iter.next();
@@ -1343,6 +1353,8 @@
compilationUnit.addImportedType(fqjt);
}
+ abatorContext.getCommentGenerator().addGeneralMethodComment(method, table);
+
if (!interfaceMethod) {
// generate the implementation method
method.addBodyLine("UpdateByExampleParms parms = new UpdateByExampleParms(record, example);"); //$NON-NLS-1$
@@ -1372,10 +1384,10 @@
InnerClass answer = new InnerClass(
new FullyQualifiedJavaType("UpdateByExampleParms")); //$NON-NLS-1$
- abatorContext.getCommentGenerator().addClassComment(answer, table);
answer.setVisibility(JavaVisibility.PRIVATE);
answer.setModifierStatic(true);
answer.setSuperClass(javaModelGenerator.getExampleType(table));
+ abatorContext.getCommentGenerator().addClassComment(answer, table);
Method method = new Method();
method.setConstructor(true);
@@ -1421,7 +1433,6 @@
compilationUnit.addImportedType(parameterType);
Method method = new Method();
- abatorContext.getCommentGenerator().addGeneralMethodComment(method, table);
method.setVisibility(JavaVisibility.PUBLIC);
method.setReturnType(FullyQualifiedJavaType.getIntInstance());
method.setName(methodNameCalculator.getUpdateByExampleWithBLOBsMethodName(introspectedTable));
@@ -1435,6 +1446,8 @@
compilationUnit.addImportedType(fqjt);
}
+ abatorContext.getCommentGenerator().addGeneralMethodComment(method, table);
+
if (!interfaceMethod) {
// generate the implementation method
method.addBodyLine("UpdateByExampleParms parms = new UpdateByExampleParms(record, example);"); //$NON-NLS-1$
@@ -1471,7 +1484,6 @@
compilationUnit.addImportedType(parameterType);
Method method = new Method();
- abatorContext.getCommentGenerator().addGeneralMethodComment(method, table);
method.setVisibility(JavaVisibility.PUBLIC);
method.setReturnType(FullyQualifiedJavaType.getIntInstance());
method.setName(methodNameCalculator.getUpdateByExampleWithoutBLOBsMethodName(introspectedTable));
@@ -1484,6 +1496,8 @@
method.addException(fqjt);
compilationUnit.addImportedType(fqjt);
}
+
+ abatorContext.getCommentGenerator().addGeneralMethodComment(method, table);
if (!interfaceMethod) {
// generate the implementation method
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/dao/BaseLegacyDAOGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/dao/BaseLegacyDAOGenerator.java?rev=631027&r1=631026&r2=631027&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/dao/BaseLegacyDAOGenerator.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/dao/BaseLegacyDAOGenerator.java Mon Feb 25 14:53:25 2008
@@ -67,7 +67,6 @@
compilationUnit.addImportedType(FullyQualifiedJavaType.getNewListInstance());
Method method1 = new Method();
- abatorContext.getCommentGenerator().addGeneralMethodComment(method1, table);
method1.setVisibility(exampleMethodVisibility);
method1.setReturnType(FullyQualifiedJavaType.getNewListInstance());
method1.setName(methodNameCalculator.getSelectByExampleWithoutBLOBsMethodName(introspectedTable));
@@ -76,7 +75,6 @@
"orderByClause")); //$NON-NLS-1$
Method method2 = new Method();
- abatorContext.getCommentGenerator().addGeneralMethodComment(method2, table);
method2.setVisibility(JavaVisibility.PUBLIC);
method2.setReturnType(FullyQualifiedJavaType.getNewListInstance());
method2.setName(methodNameCalculator.getSelectByExampleWithoutBLOBsMethodName(introspectedTable));
@@ -90,6 +88,9 @@
compilationUnit.addImportedType(fqjt);
}
+ abatorContext.getCommentGenerator().addGeneralMethodComment(method1, table);
+ abatorContext.getCommentGenerator().addGeneralMethodComment(method2, table);
+
if (!interfaceMethod) {
// generate the implementation method
compilationUnit.addImportedType(FullyQualifiedJavaType.getNewMapInstance());
@@ -141,7 +142,6 @@
compilationUnit.addImportedType(FullyQualifiedJavaType.getNewListInstance());
Method method1 = new Method();
- abatorContext.getCommentGenerator().addGeneralMethodComment(method1, table);
method1.setVisibility(exampleMethodVisibility);
method1.setReturnType(FullyQualifiedJavaType.getNewListInstance());
method1.setName(methodNameCalculator.getSelectByExampleWithBLOBsMethodName(introspectedTable));
@@ -150,7 +150,6 @@
"orderByClause")); //$NON-NLS-1$
Method method2 = new Method();
- abatorContext.getCommentGenerator().addGeneralMethodComment(method2, table);
method2.setVisibility(JavaVisibility.PUBLIC);
method2.setReturnType(FullyQualifiedJavaType.getNewListInstance());
method2.setName(methodNameCalculator.getSelectByExampleWithBLOBsMethodName(introspectedTable));
@@ -164,6 +163,9 @@
compilationUnit.addImportedType(fqjt);
}
+ abatorContext.getCommentGenerator().addGeneralMethodComment(method1, table);
+ abatorContext.getCommentGenerator().addGeneralMethodComment(method2, table);
+
if (!interfaceMethod) {
// generate the implementation method
compilationUnit.addImportedType(FullyQualifiedJavaType.getNewMapInstance());
@@ -213,7 +215,6 @@
compilationUnit.addImportedType(type);
Method method = new Method();
- abatorContext.getCommentGenerator().addGeneralMethodComment(method, table);
method.setVisibility(exampleMethodVisibility);
method.setReturnType(FullyQualifiedJavaType.getIntInstance());
method.setName(methodNameCalculator.getDeleteByExampleMethodName(introspectedTable));
@@ -226,6 +227,8 @@
compilationUnit.addImportedType(fqjt);
}
+ abatorContext.getCommentGenerator().addGeneralMethodComment(method, table);
+
if (!interfaceMethod) {
// generate the implementation method
StringBuffer sb = new StringBuffer();
@@ -259,7 +262,6 @@
compilationUnit.addImportedType(type);
Method method = new Method();
- abatorContext.getCommentGenerator().addGeneralMethodComment(method, table);
method.setVisibility(exampleMethodVisibility);
method.setReturnType(FullyQualifiedJavaType.getIntInstance());
method.setName(methodNameCalculator.getCountByExampleMethodName(introspectedTable));
@@ -272,6 +274,8 @@
compilationUnit.addImportedType(fqjt);
}
+ abatorContext.getCommentGenerator().addGeneralMethodComment(method, table);
+
if (!interfaceMethod) {
// generate the implementation method
StringBuffer sb = new StringBuffer();
@@ -307,7 +311,6 @@
generatedClass.addImportedType(type);
Method method = new Method();
- abatorContext.getCommentGenerator().addGeneralMethodComment(method, table);
method.setVisibility(JavaVisibility.PROTECTED);
if (abatorContext.getSuppressTypeWarnings()) {
method.addSuppressTypeWarningsAnnotation();
@@ -316,6 +319,8 @@
method.setName("getExampleParms"); //$NON-NLS-1$
method.addParameter(new Parameter(type, "example")); //$NON-NLS-1$
+ abatorContext.getCommentGenerator().addGeneralMethodComment(method, table);
+
method.addBodyLine("Map parms = new HashMap();"); //$NON-NLS-1$
Iterator iter = introspectedTable.getNonBLOBColumns();
@@ -369,7 +374,6 @@
StringBuffer sb = new StringBuffer();
Method method = new Method();
- abatorContext.getCommentGenerator().addGeneralMethodComment(method, table);
method.setVisibility(JavaVisibility.PROTECTED);
if (abatorContext.getSuppressTypeWarnings()) {
method.addSuppressTypeWarningsAnnotation();
@@ -382,6 +386,8 @@
method.addParameter(new Parameter(javaModelGenerator.getExampleType(table),
"example")); //$NON-NLS-1$
+ abatorContext.getCommentGenerator().addGeneralMethodComment(method, table);
+
method.addBodyLine("Map parms = new HashMap();"); //$NON-NLS-1$
sb.setLength(0);
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/model/JavaModelGeneratorJava2Impl.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/model/JavaModelGeneratorJava2Impl.java?rev=631027&r1=631026&r2=631027&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/model/JavaModelGeneratorJava2Impl.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/model/JavaModelGeneratorJava2Impl.java Mon Feb 25 14:53:25 2008
@@ -158,17 +158,17 @@
String property = cd.getJavaProperty();
field = new Field();
- commentGenerator.addFieldComment(field, table, cd.getActualColumnName());
field.setVisibility(JavaVisibility.PRIVATE);
field.setType(fqjt);
field.setName(property);
+ commentGenerator.addFieldComment(field, table, cd.getActualColumnName());
topLevelClass.addField(field);
method = new Method();
- commentGenerator.addGetterComment(method, table, cd);
method.setVisibility(JavaVisibility.PUBLIC);
method.setReturnType(fqjt);
method.setName(JavaBeansUtil.getGetterMethodName(field.getName(), field.getType()));
+ commentGenerator.addGetterComment(method, table, cd.getActualColumnName());
sb.setLength(0);
sb.append("return "); //$NON-NLS-1$
sb.append(property);
@@ -177,10 +177,10 @@
topLevelClass.addMethod(method);
method = new Method();
- commentGenerator.addSetterComment(method, table, cd);
method.setVisibility(JavaVisibility.PUBLIC);
method.setName(JavaBeansUtil.getSetterMethodName(property));
method.addParameter(new Parameter(fqjt, property));
+ commentGenerator.addSetterComment(method, table, cd.getActualColumnName());
if (trimStrings && cd.isStringColumn()) {
sb.setLength(0);
@@ -241,8 +241,8 @@
FullyQualifiedTable table = introspectedTable.getTable();
FullyQualifiedJavaType type = getPrimaryKeyType(table);
TopLevelClass answer = new TopLevelClass(type);
- abatorContext.getCommentGenerator().addJavaFileComment(answer);
answer.setVisibility(JavaVisibility.PUBLIC);
+ abatorContext.getCommentGenerator().addJavaFileComment(answer);
String rootClass = getRootClass(introspectedTable);
if (rootClass != null) {
@@ -264,8 +264,8 @@
FullyQualifiedTable table = introspectedTable.getTable();
FullyQualifiedJavaType type = getBaseRecordType(table);
TopLevelClass answer = new TopLevelClass(type);
- abatorContext.getCommentGenerator().addJavaFileComment(answer);
answer.setVisibility(JavaVisibility.PUBLIC);
+ abatorContext.getCommentGenerator().addJavaFileComment(answer);
if (introspectedTable.getRules().generatePrimaryKeyClass()) {
answer.setSuperClass(getPrimaryKeyType(table));
@@ -301,8 +301,8 @@
FullyQualifiedTable table = introspectedTable.getTable();
FullyQualifiedJavaType type = getRecordWithBLOBsType(table);
TopLevelClass answer = new TopLevelClass(type);
- abatorContext.getCommentGenerator().addJavaFileComment(answer);
answer.setVisibility(JavaVisibility.PUBLIC);
+ abatorContext.getCommentGenerator().addJavaFileComment(answer);
if (introspectedTable.getRules().generateBaseRecordClass()) {
answer.setSuperClass(getBaseRecordType(table));
@@ -718,16 +718,16 @@
FullyQualifiedTable table = introspectedTable.getTable();
FullyQualifiedJavaType type = getExampleType(table);
TopLevelClass topLevelClass = new TopLevelClass(type);
- commentGenerator.addJavaFileComment(topLevelClass);
topLevelClass.setVisibility(JavaVisibility.PUBLIC);
+ commentGenerator.addJavaFileComment(topLevelClass);
// add default constructor
Method method = new Method();
- commentGenerator.addGeneralMethodComment(method, table);
method.setVisibility(JavaVisibility.PUBLIC);
method.setConstructor(true);
method.setName(type.getShortName());
method.addBodyLine("oredCriteria = new ArrayList();"); //$NON-NLS-1$
+ commentGenerator.addGeneralMethodComment(method, table);
topLevelClass.addMethod(method);
// add shallow copy contructor if the update by
@@ -738,44 +738,43 @@
|| rules.generateUpdateByExampleWithBLOBs()
||rules.generateUpdateByExampleWithoutBLOBs()) {
method = new Method();
- commentGenerator.addGeneralMethodComment(method, table);
method.setVisibility(JavaVisibility.PROTECTED);
method.setConstructor(true);
method.setName(type.getShortName());
method.addParameter(new Parameter(type, "example")); //$NON-NLS-1$
method.addBodyLine("this.orderByClause = example.orderByClause;"); //$NON-NLS-1$
method.addBodyLine("this.oredCriteria = example.oredCriteria;"); //$NON-NLS-1$
+ commentGenerator.addGeneralMethodComment(method, table);
topLevelClass.addMethod(method);
}
// add field, getter, setter for orderby clause
Field field = new Field();
- commentGenerator.addFieldComment(field, table);
field.setVisibility(JavaVisibility.PROTECTED);
field.setType(FullyQualifiedJavaType.getStringInstance());
field.setName("orderByClause"); //$NON-NLS-1$
+ commentGenerator.addFieldComment(field, table);
topLevelClass.addField(field);
method = new Method();
- commentGenerator.addGeneralMethodComment(method, table);
method.setVisibility(JavaVisibility.PUBLIC);
method.setName("setOrderByClause"); //$NON-NLS-1$
method.addParameter(new Parameter(FullyQualifiedJavaType
.getStringInstance(), "orderByClause")); //$NON-NLS-1$
method.addBodyLine("this.orderByClause = orderByClause;"); //$NON-NLS-1$
+ commentGenerator.addGeneralMethodComment(method, table);
topLevelClass.addMethod(method);
method = new Method();
- commentGenerator.addGeneralMethodComment(method, table);
method.setVisibility(JavaVisibility.PUBLIC);
method.setReturnType(FullyQualifiedJavaType.getStringInstance());
method.setName("getOrderByClause"); //$NON-NLS-1$
method.addBodyLine("return orderByClause;"); //$NON-NLS-1$
+ commentGenerator.addGeneralMethodComment(method, table);
topLevelClass.addMethod(method);
// add field and methods for the list of ored criteria
field = new Field();
- commentGenerator.addFieldComment(field, table);
field.setVisibility(JavaVisibility.PROTECTED);
FullyQualifiedJavaType fqjt = FullyQualifiedJavaType
@@ -783,18 +782,18 @@
field.setType(fqjt);
field.setName("oredCriteria"); //$NON-NLS-1$
+ commentGenerator.addFieldComment(field, table);
topLevelClass.addField(field);
method = new Method();
- commentGenerator.addGeneralMethodComment(method, table);
method.setVisibility(JavaVisibility.PUBLIC);
method.setReturnType(fqjt);
method.setName("getOredCriteria"); //$NON-NLS-1$
method.addBodyLine("return oredCriteria;"); //$NON-NLS-1$
+ commentGenerator.addGeneralMethodComment(method, table);
topLevelClass.addMethod(method);
method = new Method();
- commentGenerator.addGeneralMethodComment(method, table);
method.setVisibility(JavaVisibility.PUBLIC);
if (abatorContext.getSuppressTypeWarnings()) {
method.addSuppressTypeWarningsAnnotation();
@@ -804,10 +803,10 @@
"criteria")); //$NON-NLS-1$
method.addBodyLine("oredCriteria.add(criteria);"); //$NON-NLS-1$
+ commentGenerator.addGeneralMethodComment(method, table);
topLevelClass.addMethod(method);
method = new Method();
- commentGenerator.addGeneralMethodComment(method, table);
method.setVisibility(JavaVisibility.PUBLIC);
if (abatorContext.getSuppressTypeWarnings()) {
method.addSuppressTypeWarningsAnnotation();
@@ -819,22 +818,23 @@
method.addBodyLine("oredCriteria.add(criteria);"); //$NON-NLS-1$
method.addBodyLine("}"); //$NON-NLS-1$
method.addBodyLine("return criteria;"); //$NON-NLS-1$
+ commentGenerator.addGeneralMethodComment(method, table);
topLevelClass.addMethod(method);
method = new Method();
- commentGenerator.addGeneralMethodComment(method, table);
method.setVisibility(JavaVisibility.PROTECTED);
method.setName("createCriteriaInternal"); //$NON-NLS-1$
method.setReturnType(FullyQualifiedJavaType.getCriteriaInstance());
method.addBodyLine("Criteria criteria = new Criteria();"); //$NON-NLS-1$
method.addBodyLine("return criteria;"); //$NON-NLS-1$
+ commentGenerator.addGeneralMethodComment(method, table);
topLevelClass.addMethod(method);
method = new Method();
- commentGenerator.addGeneralMethodComment(method, table);
method.setVisibility(JavaVisibility.PUBLIC);
method.setName("clear"); //$NON-NLS-1$
method.addBodyLine("oredCriteria.clear();"); //$NON-NLS-1$
+ commentGenerator.addGeneralMethodComment(method, table);
topLevelClass.addMethod(method);
// now generate the inner class that holds the AND conditions
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/model/JavaModelGeneratorJava5Impl.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/model/JavaModelGeneratorJava5Impl.java?rev=631027&r1=631026&r2=631027&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/model/JavaModelGeneratorJava5Impl.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/model/JavaModelGeneratorJava5Impl.java Mon Feb 25 14:53:25 2008
@@ -58,16 +58,16 @@
FullyQualifiedTable table = introspectedTable.getTable();
FullyQualifiedJavaType type = getExampleType(table);
TopLevelClass topLevelClass = new TopLevelClass(type);
- commentGenerator.addJavaFileComment(topLevelClass);
topLevelClass.setVisibility(JavaVisibility.PUBLIC);
+ commentGenerator.addJavaFileComment(topLevelClass);
// add default constructor
Method method = new Method();
- commentGenerator.addGeneralMethodComment(method, table);
method.setVisibility(JavaVisibility.PUBLIC);
method.setConstructor(true);
method.setName(type.getShortName());
method.addBodyLine("oredCriteria = new ArrayList<Criteria>();"); //$NON-NLS-1$
+ commentGenerator.addGeneralMethodComment(method, table);
topLevelClass.addMethod(method);
// add shallow copy contructor if the update by
@@ -78,44 +78,43 @@
|| rules.generateUpdateByExampleWithBLOBs()
||rules.generateUpdateByExampleWithoutBLOBs()) {
method = new Method();
- commentGenerator.addGeneralMethodComment(method, table);
method.setVisibility(JavaVisibility.PROTECTED);
method.setConstructor(true);
method.setName(type.getShortName());
method.addParameter(new Parameter(type, "example")); //$NON-NLS-1$
method.addBodyLine("this.orderByClause = example.orderByClause;"); //$NON-NLS-1$
method.addBodyLine("this.oredCriteria = example.oredCriteria;"); //$NON-NLS-1$
+ commentGenerator.addGeneralMethodComment(method, table);
topLevelClass.addMethod(method);
}
// add field, getter, setter for orderby clause
Field field = new Field();
- commentGenerator.addFieldComment(field, table);
field.setVisibility(JavaVisibility.PROTECTED);
field.setType(FullyQualifiedJavaType.getStringInstance());
field.setName("orderByClause"); //$NON-NLS-1$
+ commentGenerator.addFieldComment(field, table);
topLevelClass.addField(field);
method = new Method();
- commentGenerator.addGeneralMethodComment(method, table);
method.setVisibility(JavaVisibility.PUBLIC);
method.setName("setOrderByClause"); //$NON-NLS-1$
method.addParameter(new Parameter(FullyQualifiedJavaType
.getStringInstance(), "orderByClause")); //$NON-NLS-1$
method.addBodyLine("this.orderByClause = orderByClause;"); //$NON-NLS-1$
+ commentGenerator.addGeneralMethodComment(method, table);
topLevelClass.addMethod(method);
method = new Method();
- commentGenerator.addGeneralMethodComment(method, table);
method.setVisibility(JavaVisibility.PUBLIC);
method.setReturnType(FullyQualifiedJavaType.getStringInstance());
method.setName("getOrderByClause"); //$NON-NLS-1$
method.addBodyLine("return orderByClause;"); //$NON-NLS-1$
+ commentGenerator.addGeneralMethodComment(method, table);
topLevelClass.addMethod(method);
// add field and methods for the list of ored criteria
field = new Field();
- commentGenerator.addFieldComment(field, table);
field.setVisibility(JavaVisibility.PROTECTED);
FullyQualifiedJavaType fqjt = FullyQualifiedJavaType
@@ -124,28 +123,27 @@
field.setType(fqjt);
field.setName("oredCriteria"); //$NON-NLS-1$
+ commentGenerator.addFieldComment(field, table);
topLevelClass.addField(field);
method = new Method();
- commentGenerator.addGeneralMethodComment(method, table);
method.setVisibility(JavaVisibility.PUBLIC);
method.setReturnType(fqjt);
method.setName("getOredCriteria"); //$NON-NLS-1$
method.addBodyLine("return oredCriteria;"); //$NON-NLS-1$
+ commentGenerator.addGeneralMethodComment(method, table);
topLevelClass.addMethod(method);
method = new Method();
- commentGenerator.addGeneralMethodComment(method, table);
method.setVisibility(JavaVisibility.PUBLIC);
method.setName("or"); //$NON-NLS-1$
method.addParameter(new Parameter(FullyQualifiedJavaType.getCriteriaInstance(),
"criteria")); //$NON-NLS-1$
method.addBodyLine("oredCriteria.add(criteria);"); //$NON-NLS-1$
-
+ commentGenerator.addGeneralMethodComment(method, table);
topLevelClass.addMethod(method);
method = new Method();
- commentGenerator.addGeneralMethodComment(method, table);
method.setVisibility(JavaVisibility.PUBLIC);
method.setName("createCriteria"); //$NON-NLS-1$
method.setReturnType(FullyQualifiedJavaType.getCriteriaInstance());
@@ -154,22 +152,23 @@
method.addBodyLine("oredCriteria.add(criteria);"); //$NON-NLS-1$
method.addBodyLine("}"); //$NON-NLS-1$
method.addBodyLine("return criteria;"); //$NON-NLS-1$
+ commentGenerator.addGeneralMethodComment(method, table);
topLevelClass.addMethod(method);
method = new Method();
- commentGenerator.addGeneralMethodComment(method, table);
method.setVisibility(JavaVisibility.PROTECTED);
method.setName("createCriteriaInternal"); //$NON-NLS-1$
method.setReturnType(FullyQualifiedJavaType.getCriteriaInstance());
method.addBodyLine("Criteria criteria = new Criteria();"); //$NON-NLS-1$
method.addBodyLine("return criteria;"); //$NON-NLS-1$
+ commentGenerator.addGeneralMethodComment(method, table);
topLevelClass.addMethod(method);
method = new Method();
- commentGenerator.addGeneralMethodComment(method, table);
method.setVisibility(JavaVisibility.PUBLIC);
method.setName("clear"); //$NON-NLS-1$
method.addBodyLine("oredCriteria.clear();"); //$NON-NLS-1$
+ commentGenerator.addGeneralMethodComment(method, table);
topLevelClass.addMethod(method);
// now generate the inner class that holds the AND conditions
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/model/JavaModelGeneratorLegacyImpl.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/model/JavaModelGeneratorLegacyImpl.java?rev=631027&r1=631026&r2=631027&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/model/JavaModelGeneratorLegacyImpl.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/java/model/JavaModelGeneratorLegacyImpl.java Mon Feb 25 14:53:25 2008
@@ -71,20 +71,19 @@
StringBuffer sb = new StringBuffer();
Field field = new Field();
- commentGenerator.addFieldComment(field, table);
field.setVisibility(JavaVisibility.PUBLIC);
field.setModifierStatic(true);
field.setModifierFinal(true);
field.setType(FullyQualifiedJavaType.getIntInstance());
field.setName("EXAMPLE_IGNORE"); //$NON-NLS-1$
field.setInitializationString("0"); //$NON-NLS-1$
+ commentGenerator.addFieldComment(field, table);
topLevelClass.addField(field);
Iterator iter = ExampleClause.getAllExampleClauses();
while (iter.hasNext()) {
ExampleClause clause = (ExampleClause) iter.next();
field = new Field();
- commentGenerator.addFieldComment(field, table);
field.setVisibility(JavaVisibility.PUBLIC);
field.setModifierStatic(true);
field.setModifierFinal(true);
@@ -92,32 +91,33 @@
field.setName(clause.getExamplePropertyName());
field.setInitializationString(Integer.toString(clause
.getExamplePropertyValue()));
+ commentGenerator.addFieldComment(field, table);
topLevelClass.addField(field);
}
field = new Field();
- commentGenerator.addFieldComment(field, table);
field.setVisibility(JavaVisibility.PRIVATE);
field.setType(FullyQualifiedJavaType.getBooleanPrimitiveInstance());
field.setName("combineTypeOr"); //$NON-NLS-1$
+ commentGenerator.addFieldComment(field, table);
topLevelClass.addField(field);
Method method = new Method();
- commentGenerator.addGeneralMethodComment(method, table);
method.setVisibility(JavaVisibility.PUBLIC);
method.setName("setCombineTypeOr"); //$NON-NLS-1$
method.addParameter(new Parameter(FullyQualifiedJavaType
.getBooleanPrimitiveInstance(), "combineTypeOr")); //$NON-NLS-1$
method.addBodyLine("this.combineTypeOr = combineTypeOr;"); //$NON-NLS-1$
+ commentGenerator.addGeneralMethodComment(method, table);
topLevelClass.addMethod(method);
method = new Method();
- commentGenerator.addGeneralMethodComment(method, table);
method.setVisibility(JavaVisibility.PUBLIC);
method.setReturnType(FullyQualifiedJavaType
.getBooleanPrimitiveInstance());
method.setName("isCombineTypeOr"); //$NON-NLS-1$
method.addBodyLine("return combineTypeOr;"); //$NON-NLS-1$
+ commentGenerator.addGeneralMethodComment(method, table);
topLevelClass.addMethod(method);
iter = introspectedTable.getNonBLOBColumns();
@@ -127,14 +127,13 @@
String fieldName = cd.getJavaProperty() + "_Indicator"; //$NON-NLS-1$
field = new Field();
- commentGenerator.addFieldComment(field, table);
field.setVisibility(JavaVisibility.PRIVATE);
field.setType(FullyQualifiedJavaType.getIntInstance());
field.setName(fieldName);
+ commentGenerator.addFieldComment(field, table);
topLevelClass.addField(field);
method = new Method();
- commentGenerator.addGeneralMethodComment(method, table);
method.setVisibility(JavaVisibility.PUBLIC);
method.setReturnType(FullyQualifiedJavaType.getIntInstance());
method.setName(JavaBeansUtil.getGetterMethodName(field.getName(), field.getType()));
@@ -143,10 +142,10 @@
sb.append(fieldName);
sb.append(';');
method.addBodyLine(sb.toString());
+ commentGenerator.addGeneralMethodComment(method, table);
topLevelClass.addMethod(method);
method = new Method();
- commentGenerator.addGeneralMethodComment(method, table);
method.setVisibility(JavaVisibility.PUBLIC);
method.setName(JavaBeansUtil.getSetterMethodName(fieldName));
method.addParameter(new Parameter(FullyQualifiedJavaType
@@ -158,6 +157,7 @@
sb.append(fieldName);
sb.append(';');
method.addBodyLine(sb.toString());
+ commentGenerator.addGeneralMethodComment(method, table);
topLevelClass.addMethod(method);
}
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/sqlmap/SqlMapGeneratorIterateImpl.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/sqlmap/SqlMapGeneratorIterateImpl.java?rev=631027&r1=631026&r2=631027&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/sqlmap/SqlMapGeneratorIterateImpl.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/sqlmap/SqlMapGeneratorIterateImpl.java Mon Feb 25 14:53:25 2008
@@ -147,7 +147,6 @@
Document document = new Document(XmlConstants.SQL_MAP_PUBLIC_ID,
XmlConstants.SQL_MAP_SYSTEM_ID);
- abatorContext.getCommentGenerator().addComment(document);
document.setRootElement(getSqlMapElement(introspectedTable));
afterGenerationHook(introspectedTable, document);
@@ -173,6 +172,8 @@
answer.addAttribute(new Attribute("namespace", //$NON-NLS-1$
getSqlMapNamespace(table)));
+ abatorContext.getCommentGenerator().addRootComment(answer);
+
AbatorRules rules = introspectedTable.getRules();
XmlElement element;
if (rules.generateBaseResultMap()) {
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava5/abatortest/abatorConfig.xml
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava5/abatortest/abatorConfig.xml?rev=631027&r1=631026&r2=631027&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava5/abatortest/abatorConfig.xml (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/testJava5/abatortest/abatorConfig.xml Mon Feb 25 14:53:25 2008
@@ -353,6 +353,10 @@
</abatorContext>
<abatorContext id="miscellaneousTests" generatorSet="Java5">
+ <commentGenerator>
+ <property name="suppressDate" value="true"/>
+ </commentGenerator>
+
<jdbcConnection driverClass="org.hsqldb.jdbcDriver"
connectionURL="jdbc:hsqldb:mem:aname"
userId="sa" />