db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1402640 - in /db/torque/torque4/trunk: torque-runtime/src/main/java/org/apache/torque/ torque-runtime/src/main/java/org/apache/torque/avalon/ torque-runtime/src/main/java/org/apache/torque/oid/ torque-templates/src/main/java/org/apache/tor...
Date Fri, 26 Oct 2012 19:58:19 GMT
Author: tfischer
Date: Fri Oct 26 19:58:19 2012
New Revision: 1402640

URL: http://svn.apache.org/viewvc?rev=1402640&view=rev
Log:
Simplify code (PMD issues)

Modified:
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/TorqueInstance.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/avalon/TorqueComponent.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/oid/IDBroker.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMTableAndViewTransformer.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/sql/SQLTransformer.java

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/TorqueInstance.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/TorqueInstance.java?rev=1402640&r1=1402639&r2=1402640&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/TorqueInstance.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/TorqueInstance.java
Fri Oct 26 19:58:19 2012
@@ -682,22 +682,19 @@ public class TorqueInstance
     {
         AbstractBaseManager<?> manager = managers.get(name);
 
-        if (manager == null)
+        if (manager == null && className != null && className.length() !=
0)
         {
-            if (className != null && className.length() != 0)
+            try
             {
-                try
-                {
-                    manager = (AbstractBaseManager<?>)
-                            Class.forName(className).newInstance();
-                    managers.put(name, manager);
-                }
-                catch (Exception e)
-                {
-                    throw new TorqueException("Could not instantiate "
-                            + "manager associated with class: "
-                            + name, e);
-                }
+                manager = (AbstractBaseManager<?>)
+                        Class.forName(className).newInstance();
+                managers.put(name, manager);
+            }
+            catch (Exception e)
+            {
+                throw new TorqueException("Could not instantiate "
+                        + "manager associated with class: "
+                        + name, e);
             }
         }
     }

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/avalon/TorqueComponent.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/avalon/TorqueComponent.java?rev=1402640&r1=1402639&r2=1402640&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/avalon/TorqueComponent.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/avalon/TorqueComponent.java
Fri Oct 26 19:58:19 2012
@@ -144,13 +144,10 @@ public class TorqueComponent
             appRoot = (String) context.get("componentAppRoot");
         }
 
-        if (StringUtils.isNotEmpty(appRoot))
+        if (StringUtils.isNotEmpty(appRoot) && appRoot.endsWith("/"))
         {
-            if (appRoot.endsWith("/"))
-            {
-                appRoot = appRoot.substring(0, appRoot.length() - 1);
-                getLogger().debug("Application Root changed to " + appRoot);
-            }
+            appRoot = appRoot.substring(0, appRoot.length() - 1);
+            getLogger().debug("Application Root changed to " + appRoot);
         }
     }
 

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/oid/IDBroker.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/oid/IDBroker.java?rev=1402640&r1=1402639&r2=1402640&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/oid/IDBroker.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/oid/IDBroker.java
Fri Oct 26 19:58:19 2012
@@ -167,11 +167,6 @@ public class IDBroker implements Runnabl
     /** Whether the idBroker thread is running or not. */
     private boolean threadRunning = false;
 
-    /**
-     * The value of ONE!
-     */
-    private static final BigDecimal ONE = new BigDecimal("1");
-
     /** the configuration */
     private Configuration configuration;
 
@@ -762,7 +757,7 @@ public class IDBroker implements Runnabl
         for (int i = 0; i < numId; i++)
         {
             availableIds.add(nextId);
-            nextId = nextId.add(ONE);
+            nextId = nextId.add(BigDecimal.ONE);
         }
         //        }
     }

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMTableAndViewTransformer.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMTableAndViewTransformer.java?rev=1402640&r1=1402639&r2=1402640&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMTableAndViewTransformer.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMTableAndViewTransformer.java
Fri Oct 26 19:58:19 2012
@@ -561,16 +561,14 @@ public class OMTableAndViewTransformer e
                                 GET_DEFAULT_TIME_METHOD_NAME);
                     }
                 }
-                else if (CURRENT_TIMESTAMP.equalsIgnoreCase(defaultValue))
-                {
-                    if (tableElement.getAttribute(
+                else if (CURRENT_TIMESTAMP.equalsIgnoreCase(defaultValue)
+                    && tableElement.getAttribute(
                         TableAttributeName.GET_CURRENT_TIMESTAMP_METHOD_NAME)
                         == null)
-                    {
-                        tableElement.setAttribute(
-                            TableAttributeName.GET_CURRENT_TIMESTAMP_METHOD_NAME,
-                            GET_DEFAULT_TIMESTAMP_METHOD_NAME);
-                    }
+                {
+                    tableElement.setAttribute(
+                        TableAttributeName.GET_CURRENT_TIMESTAMP_METHOD_NAME,
+                        GET_DEFAULT_TIMESTAMP_METHOD_NAME);
                 }
             }
         }

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/sql/SQLTransformer.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/sql/SQLTransformer.java?rev=1402640&r1=1402639&r2=1402640&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/sql/SQLTransformer.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/sql/SQLTransformer.java
Fri Oct 26 19:58:19 2012
@@ -49,6 +49,7 @@ import org.apache.torque.templates.typem
  */
 public class SQLTransformer implements SourceTransformer
 {
+    /** A CollectAttributeSetTrueTransformer instance. */
     private final CollectAttributeSetTrueTransformer collectAttributeSetTrueTransformer
             = new CollectAttributeSetTrueTransformer();
 
@@ -312,7 +313,8 @@ public class SQLTransformer implements S
                     Date defaultDate
                             = OMColumnTransformer.getDefaultValueAsDate(
                                     sqlType.getDefaultValue());
-                    if (SchemaType.DATE == schemaType) {
+                    if (SchemaType.DATE == schemaType)
+                    {
                         resultList.add(platform.getDateString(defaultDate));
                     }
                     else if (SchemaType.TIME == schemaType)
@@ -352,12 +354,10 @@ public class SQLTransformer implements S
         boolean isNotNull = primaryKey || required;
         String isNotNullString = platform.getNullString(isNotNull);
 
-        if (platform.createNotNullBeforeAutoincrement())
+        if (platform.createNotNullBeforeAutoincrement()
+            && StringUtils.isNotEmpty(isNotNullString))
         {
-            if (StringUtils.isNotEmpty(isNotNullString))
-            {
-                resultList.add(isNotNullString);
-            }
+            resultList.add(isNotNullString);
         }
         // if idMethod was not set explicitly by the user,
         // the transformTable() method sets the attribute from the
@@ -374,12 +374,10 @@ public class SQLTransformer implements S
                 resultList.add(autoIncrement);
             }
         }
-        if (!platform.createNotNullBeforeAutoincrement())
+        if (!platform.createNotNullBeforeAutoincrement()
+                && StringUtils.isNotEmpty(isNotNullString))
         {
-            if (StringUtils.isNotEmpty(isNotNullString))
-            {
-                resultList.add(isNotNullString);
-            }
+            resultList.add(isNotNullString);
         }
         return StringUtils.join(resultList.iterator(), ' ');
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message