From a360148cd6c242bd4d6ef729ae2d170b3b56a7f8 Mon Sep 17 00:00:00 2001 From: rkv Date: Wed, 7 Nov 2012 07:58:45 +0000 Subject: [PATCH] Modifications done to respect PMD rules. --- .../src/org/siman/generator/DaoGenerator.java | 27 +++++++++---------- .../DaoGenerator/src/templates/DAO.java.vm | 2 ++ .../src/templates/DAOImpl.java.vm | 8 +++--- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/Workspace/DaoGenerator/src/org/siman/generator/DaoGenerator.java b/Workspace/DaoGenerator/src/org/siman/generator/DaoGenerator.java index ab60ec5..fa69069 100644 --- a/Workspace/DaoGenerator/src/org/siman/generator/DaoGenerator.java +++ b/Workspace/DaoGenerator/src/org/siman/generator/DaoGenerator.java @@ -9,16 +9,13 @@ package org.siman.generator; -import java.io.File; import java.io.FileWriter; import java.io.IOException; -import java.util.ResourceBundle; - -import java.io.StringWriter; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Properties; +import java.util.ResourceBundle; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -59,7 +56,7 @@ public class DaoGenerator { * @throws IOException * @throws SAXException */ - public static void main(String[] args) throws ParserConfigurationException, + public static void main(final String[] args) throws ParserConfigurationException, SAXException, IOException { ResourceBundle bundle = ResourceBundle.getBundle("config"); String srcCtx = bundle.getString(SRC_CTX); @@ -124,9 +121,9 @@ public class DaoGenerator { * @throws IOException * @throws SAXException */ - private static void processMappingResource(List daos, - DocumentBuilderFactory dfactory, String resourceName, - String srcPath, String outPath) + private static void processMappingResource(final List daos, + final DocumentBuilderFactory dfactory, final String resourceName, + final String srcPath, final String outPath) throws ParserConfigurationException, SAXException, IOException { // dfactory.setValidating(false); // dfactory.setFeature("http://xml.org/sax/features/namespaces", false); @@ -154,8 +151,8 @@ public class DaoGenerator { * @param string * @param outPath */ - private static void processClasses(List daos, Document resDoc, - String elementName, String outPath) { + private static void processClasses(final List daos, final Document resDoc, + final String elementName, final String outPath) { NodeList classes = resDoc.getElementsByTagName(elementName); Element classElem; for (int i = 0; i < classes.getLength(); i++) { @@ -199,8 +196,8 @@ public class DaoGenerator { * @param string * @param outPath */ - private static void generateClass(String entityName, String className, - String templatePath, String outPath) { + private static void generateClass(final String entityName, final String className, + final String templatePath, final String outPath) { String resultPath = outPath + className.replace(".", "/") + ".java"; System.out.println("Generating file: " + resultPath); VelocityContext context = new VelocityContext(); @@ -220,7 +217,7 @@ public class DaoGenerator { * @param string * @param outPath */ - private static void generateDaoContext(List daos, String outPath) { + private static void generateDaoContext(final List daos, final String outPath) { String resultPath = outPath + "spring/daoContext.xml"; String templatePath = "templates/daoContext.xml.vm"; System.out.println("Generating file: " + resultPath); @@ -236,8 +233,8 @@ public class DaoGenerator { * @param templatePath * @param resultPath */ - private static void generateFile(VelocityContext context, - String templatePath, String resultPath) { + private static void generateFile(final VelocityContext context, + final String templatePath, final String resultPath) { Template template = null; context.put("date", new Date()); diff --git a/Workspace/DaoGenerator/src/templates/DAO.java.vm b/Workspace/DaoGenerator/src/templates/DAO.java.vm index 80720c0..779a298 100644 --- a/Workspace/DaoGenerator/src/templates/DAO.java.vm +++ b/Workspace/DaoGenerator/src/templates/DAO.java.vm @@ -11,7 +11,9 @@ package ${DAOPackage}; import ${EntityPackage}.${EntityClass}; +#if(${DAOPackage} != "org.splat.dal.dao.kernel") import org.splat.dal.dao.kernel.GenericDAO; +#end /** * ${EntityClass} DAO class implementation. diff --git a/Workspace/DaoGenerator/src/templates/DAOImpl.java.vm b/Workspace/DaoGenerator/src/templates/DAOImpl.java.vm index 2071532..7977aa0 100644 --- a/Workspace/DaoGenerator/src/templates/DAOImpl.java.vm +++ b/Workspace/DaoGenerator/src/templates/DAOImpl.java.vm @@ -11,7 +11,9 @@ package ${DAOPackage}; import ${EntityPackage}.${EntityClass}; -import org.splat.dal.dao.kernel.GenericDAOImpl; +#if(${DAOPackage} != "org.splat.dal.dao.kernel") +import org.splat.dal.dao.kernel.AbstractGenericDAOImpl; +#end /** * ${EntityClass} DAO. @@ -19,11 +21,11 @@ import org.splat.dal.dao.kernel.GenericDAOImpl; * */ public class ${EntityClass}DAOImpl extends - GenericDAOImpl<${EntityClass}, Long> implements ${EntityClass}DAO { + AbstractGenericDAOImpl<${EntityClass}, Long> implements ${EntityClass}DAO { /** * {@inheritDoc} - * @see org.splat.dal.dao.kernel.GenericDAOImpl#getType() + * @see org.splat.dal.dao.kernel.AbstractGenericDAOImpl#getType() */ @Override protected Class<${EntityClass}> getType() { -- 2.39.2