org.mybatis.generator.internal
Class DefaultCommentGenerator

java.lang.Object
  extended by org.mybatis.generator.internal.DefaultCommentGenerator
All Implemented Interfaces:
CommentGenerator

public class DefaultCommentGenerator
extends Object
implements CommentGenerator

Author:
Jeff Butler

Constructor Summary
DefaultCommentGenerator()
           
 
Method Summary
 void addClassComment(InnerClass innerClass, IntrospectedTable introspectedTable)
           
 void addClassComment(InnerClass innerClass, IntrospectedTable introspectedTable, boolean markAsDoNotDelete)
           
 void addComment(XmlElement xmlElement)
          Adds a suitable comment to warn users that the element was generated, and when it was generated.
 void addConfigurationProperties(Properties properties)
          Adds properties for this instance from any properties configured in the CommentGenerator configuration.
 void addEnumComment(InnerEnum innerEnum, IntrospectedTable introspectedTable)
           
 void addFieldComment(Field field, IntrospectedTable introspectedTable)
           
 void addFieldComment(Field field, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn)
          This method should add a Javadoc comment to the specified field.
 void addGeneralMethodComment(Method method, IntrospectedTable introspectedTable)
           
 void addGetterComment(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn)
           
protected  void addJavadocTag(JavaElement javaElement, boolean markAsDoNotDelete)
          This method adds the custom javadoc tag for.
 void addJavaFileComment(CompilationUnit compilationUnit)
          This method is called to add a file level comment to a generated java file.
 void addRootComment(XmlElement rootElement)
          This method is called to add a comment as the first child of the root element.
 void addSetterComment(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn)
           
protected  String getDateString()
          This method returns a formated date string to include in the Javadoc tag and XML comments.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultCommentGenerator

public DefaultCommentGenerator()
Method Detail

addJavaFileComment

public void addJavaFileComment(CompilationUnit compilationUnit)
Description copied from interface: CommentGenerator
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 the generator repeatedly, you will only retain the comment from the initial run.

The default implementation does nothing.

Specified by:
addJavaFileComment in interface CommentGenerator

addComment

public void addComment(XmlElement xmlElement)
Adds a suitable comment to warn users that the element was generated, and when it was generated.

Specified by:
addComment in interface CommentGenerator

addRootComment

public void addRootComment(XmlElement rootElement)
Description copied from interface: CommentGenerator
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 the generator repeatedly, you will only retain the comment from the initial run.

The default implementation does nothing.

Specified by:
addRootComment in interface CommentGenerator

addConfigurationProperties

public void addConfigurationProperties(Properties properties)
Description copied from 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.

Specified by:
addConfigurationProperties in interface CommentGenerator
Parameters:
properties - All properties from the configuration

addJavadocTag

protected void addJavadocTag(JavaElement javaElement,
                             boolean markAsDoNotDelete)
This method adds the custom javadoc tag for. 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.

Parameters:
javaElement - the java element

getDateString

protected String getDateString()
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.

Returns:
a string representing the current timestamp, or null

addClassComment

public void addClassComment(InnerClass innerClass,
                            IntrospectedTable introspectedTable)
Specified by:
addClassComment in interface CommentGenerator

addEnumComment

public void addEnumComment(InnerEnum innerEnum,
                           IntrospectedTable introspectedTable)
Specified by:
addEnumComment in interface CommentGenerator

addFieldComment

public void addFieldComment(Field field,
                            IntrospectedTable introspectedTable,
                            IntrospectedColumn introspectedColumn)
Description copied from interface: CommentGenerator
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.

Important: This method should add a the nonstandard JavaDoc tag "@mbggenerated" to the comment. Without this tag, the Eclipse based Java merge feature will fail.

Specified by:
addFieldComment in interface CommentGenerator

addFieldComment

public void addFieldComment(Field field,
                            IntrospectedTable introspectedTable)
Specified by:
addFieldComment in interface CommentGenerator

addGeneralMethodComment

public void addGeneralMethodComment(Method method,
                                    IntrospectedTable introspectedTable)
Specified by:
addGeneralMethodComment in interface CommentGenerator

addGetterComment

public void addGetterComment(Method method,
                             IntrospectedTable introspectedTable,
                             IntrospectedColumn introspectedColumn)
Specified by:
addGetterComment in interface CommentGenerator

addSetterComment

public void addSetterComment(Method method,
                             IntrospectedTable introspectedTable,
                             IntrospectedColumn introspectedColumn)
Specified by:
addSetterComment in interface CommentGenerator

addClassComment

public void addClassComment(InnerClass innerClass,
                            IntrospectedTable introspectedTable,
                            boolean markAsDoNotDelete)
Specified by:
addClassComment in interface CommentGenerator


Copyright © 2010-2012 MyBatis.org. All Rights Reserved.