Search in sources :

Example 1 with CommentGeneratorConfiguration

use of org.mybatis.generator.config.CommentGeneratorConfiguration in project generator by mybatis.

the class MyBatisGeneratorConfigurationParser method parseCommentGenerator.

protected void parseCommentGenerator(Context context, Node node) {
    CommentGeneratorConfiguration commentGeneratorConfiguration = new CommentGeneratorConfiguration();
    context.setCommentGeneratorConfiguration(commentGeneratorConfiguration);
    Properties attributes = parseAttributes(node);
    //$NON-NLS-1$
    String type = attributes.getProperty("type");
    if (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() != Node.ELEMENT_NODE) {
            continue;
        }
        if ("property".equals(childNode.getNodeName())) {
            //$NON-NLS-1$
            parseProperty(commentGeneratorConfiguration, childNode);
        }
    }
}
Also used : CommentGeneratorConfiguration(org.mybatis.generator.config.CommentGeneratorConfiguration) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Messages.getString(org.mybatis.generator.internal.util.messages.Messages.getString) Properties(java.util.Properties)

Example 2 with CommentGeneratorConfiguration

use of org.mybatis.generator.config.CommentGeneratorConfiguration in project generator by mybatis.

the class ObjectFactory method createCommentGenerator.

/**
     * Creates a new Object object.
     *
     * @param context
     *            the context
     * @return the comment generator
     */
public static CommentGenerator createCommentGenerator(Context 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) createInternalObject(type);
    if (config != null) {
        answer.addConfigurationProperties(config.getProperties());
    }
    return answer;
}
Also used : CommentGeneratorConfiguration(org.mybatis.generator.config.CommentGeneratorConfiguration) CommentGenerator(org.mybatis.generator.api.CommentGenerator) Messages.getString(org.mybatis.generator.internal.util.messages.Messages.getString)

Aggregations

CommentGeneratorConfiguration (org.mybatis.generator.config.CommentGeneratorConfiguration)2 Messages.getString (org.mybatis.generator.internal.util.messages.Messages.getString)2 Properties (java.util.Properties)1 CommentGenerator (org.mybatis.generator.api.CommentGenerator)1 Node (org.w3c.dom.Node)1 NodeList (org.w3c.dom.NodeList)1