db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r476550 - in /db/torque/runtime/trunk/src/java/org/apache/torque: ./ adapter/ avalon/ dsfactory/ map/ oid/ om/ util/
Date Sat, 18 Nov 2006 16:08:38 GMT
Author: tfischer
Date: Sat Nov 18 08:08:37 2006
New Revision: 476550

URL: http://svn.apache.org/viewvc?view=rev&rev=476550
Log:
Fixed some checkstyle complaints in the runtime. This involved:
- renaming local variables which were hiding instance variables
- making instance variables private
- making helper classes with only static methods final and non-instanciable
- removing throws clauses of unchecked exceptions
- adding some javadoc

Modified:
    db/torque/runtime/trunk/src/java/org/apache/torque/Database.java
    db/torque/runtime/trunk/src/java/org/apache/torque/Torque.java
    db/torque/runtime/trunk/src/java/org/apache/torque/TorqueInstance.java
    db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DB.java
    db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBFactory.java
    db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBFirebird.java
    db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBHypersonicSQL.java
    db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBInterbase.java
    db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBOracle.java
    db/torque/runtime/trunk/src/java/org/apache/torque/avalon/Torque.java
    db/torque/runtime/trunk/src/java/org/apache/torque/avalon/TorqueComponent.java
    db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/JndiDataSourceFactory.java
    db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/PerUserPoolDataSourceFactory.java
    db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/SharedPoolDataSourceFactory.java
    db/torque/runtime/trunk/src/java/org/apache/torque/map/DatabaseMap.java
    db/torque/runtime/trunk/src/java/org/apache/torque/oid/IDBroker.java
    db/torque/runtime/trunk/src/java/org/apache/torque/oid/IDGeneratorFactory.java
    db/torque/runtime/trunk/src/java/org/apache/torque/om/BaseObject.java
    db/torque/runtime/trunk/src/java/org/apache/torque/om/DateKey.java
    db/torque/runtime/trunk/src/java/org/apache/torque/util/Criteria.java
    db/torque/runtime/trunk/src/java/org/apache/torque/util/JoinBuilder.java
    db/torque/runtime/trunk/src/java/org/apache/torque/util/LargeSelect.java
    db/torque/runtime/trunk/src/java/org/apache/torque/util/Query.java
    db/torque/runtime/trunk/src/java/org/apache/torque/util/SQLBuilder.java
    db/torque/runtime/trunk/src/java/org/apache/torque/util/SqlExpression.java
    db/torque/runtime/trunk/src/java/org/apache/torque/util/Transaction.java
    db/torque/runtime/trunk/src/java/org/apache/torque/util/VillageUtils.java

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/Database.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/Database.java?view=diff&rev=476550&r1=476549&r2=476550
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/Database.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/Database.java Sat Nov 18 08:08:37 2006
@@ -158,12 +158,12 @@
      */
     public synchronized boolean startIDBroker()
     {
-        DatabaseMap databaseMap = getDatabaseMap();
-        if (databaseMap.getIDBroker() != null)
+        DatabaseMap dbMap = getDatabaseMap();
+        if (dbMap.getIDBroker() != null)
         {
             return false;
         }
-        return databaseMap.startIdBroker();
+        return dbMap.startIdBroker();
     }
 
     /**

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/Torque.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/Torque.java?view=diff&rev=476550&r1=476549&r2=476550
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/Torque.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/Torque.java Sat Nov 18 08:08:37 2006
@@ -41,7 +41,7 @@
  * @author <a href="mailto:kschrader@karmalab.org">Kurt Schrader</a>
  * @version $Id$
  */
-public abstract class Torque
+public class Torque
 {
     /**
      * The prefix for all configuration keys used by Torque.
@@ -90,11 +90,12 @@
     private static TorqueInstance torqueSingleton = null;
 
     /**
-     * C'tor for usage with the Stratum Lifecycle.
+     * Private constructor to prevent instantiation.
      *
-     * TODO: Should be made private or protected once Stratum is removed.
+     * Class contains only static method ans should therefore not be
+     * instantiated.
      */
-    public Torque()
+    private Torque()
     {
     }
 

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/TorqueInstance.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/TorqueInstance.java?view=diff&rev=476550&r1=476549&r2=476550
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/TorqueInstance.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/TorqueInstance.java Sat Nov 18 08:08:37
2006
@@ -437,10 +437,11 @@
         log.debug("init(" + configFile + ")");
         try
         {
-            Configuration conf = new PropertiesConfiguration(configFile);
+            Configuration configuration
+                    = new PropertiesConfiguration(configFile);
 
-            log.debug("Config Object is " + conf);
-            init(conf);
+            log.debug("Config Object is " + configuration);
+            init(configuration);
         }
         catch (ConfigurationException e)
         {

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DB.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DB.java?view=diff&rev=476550&r1=476549&r2=476550
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DB.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DB.java Sat Nov 18 08:08:37
2006
@@ -41,9 +41,9 @@
  * transparent swapping of databases is theoretically supported with
  * <i>zero code changes</i> and minimal configuration file
  * modifications.
- * 
+ *
  * All database adapters need to be thread safe, as they are instantiated
- * only once fore a gviven configured database and may be accessed 
+ * only once fore a given configured database and may be accessed
  * simultaneously from several threads.
  *
  * <p>Torque uses the driver class name to find the right adapter.

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBFactory.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBFactory.java?view=diff&rev=476550&r1=476549&r2=476550
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBFactory.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBFactory.java Sat Nov 18 08:08:37
2006
@@ -100,6 +100,15 @@
     }
 
     /**
+     * Private constructor to prevent instantiation.
+     *
+     * Class contains only static methods, so no instances are needed.
+     */
+    private DBFactory()
+    {
+    }
+
+    /**
      * Creates a new instance of the Torque database adapter associated
      * with the specified JDBC driver or adapter key.
      *

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBFirebird.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBFirebird.java?view=diff&rev=476550&r1=476549&r2=476550
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBFirebird.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBFirebird.java Sat Nov 18
08:08:37 2006
@@ -34,10 +34,13 @@
 public class DBFirebird extends AbstractDBAdapter
 {
     /**
-     * Serial version
+     * Serial version.
      */
     private static final long serialVersionUID = -2782124791802056450L;
 
+    /**
+     * The format in which firebird expects dates (with time).
+     */
     private static final String DATE_FORMAT = "yyyy-MM-dd HH:MM:ss";
 
     /**
@@ -143,7 +146,7 @@
         char delim = getStringDelimiter();
         return (delim + new SimpleDateFormat(DATE_FORMAT).format(date) + delim);
     }
-    
+
     /**
      * This method is for the SqlExpression.quoteAndEscape rules.  The rule is,
      * any string in a SqlExpression with a BACKSLASH will either be changed to

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBHypersonicSQL.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBHypersonicSQL.java?view=diff&rev=476550&r1=476549&r2=476550
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBHypersonicSQL.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBHypersonicSQL.java Sat Nov
18 08:08:37 2006
@@ -119,7 +119,7 @@
     /**
      * This method is for the SqlExpression.quoteAndEscape rules.  The rule is,
      * any string in a SqlExpression with a BACKSLASH will either be changed to
-     * "\\" or left as "\". 
+     * "\\" or left as "\".
      *
      * @return false.
      */

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBInterbase.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBInterbase.java?view=diff&rev=476550&r1=476549&r2=476550
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBInterbase.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBInterbase.java Sat Nov 18
08:08:37 2006
@@ -38,6 +38,9 @@
      */
     private static final long serialVersionUID = -6709312389168248070L;
 
+    /**
+     * The format in which interbase expects dates (with time).
+     */
     private static final String DATE_FORMAT = "yyyy-MM-dd HH:MM:ss";
 
     /**

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBOracle.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBOracle.java?view=diff&rev=476550&r1=476549&r2=476550
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBOracle.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBOracle.java Sat Nov 18 08:08:37
2006
@@ -239,7 +239,7 @@
         // are not allowed anyway
         // So alias names will be retained
         for (ListIterator columnIt = selectColumns.listIterator();
-                columnIt.hasNext(); )
+                columnIt.hasNext();)
         {
             String selectColumn = (String) columnIt.next();
 
@@ -265,7 +265,7 @@
 
         // second pass. Regard ordinary columns only
         for (ListIterator columnIt = selectColumns.listIterator();
-                columnIt.hasNext(); )
+                columnIt.hasNext();)
         {
             String selectColumn = (String) columnIt.next();
 

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/avalon/Torque.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/avalon/Torque.java?view=diff&rev=476550&r1=476549&r2=476550
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/avalon/Torque.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/avalon/Torque.java Sat Nov 18 08:08:37
2006
@@ -39,6 +39,9 @@
 public interface Torque
         extends Component
 {
+    /**
+     * The avalon role.
+     */
     String ROLE = Torque.class.getName();
 
     /*

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/avalon/TorqueComponent.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/avalon/TorqueComponent.java?view=diff&rev=476550&r1=476549&r2=476550
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/avalon/TorqueComponent.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/avalon/TorqueComponent.java Sat Nov
18 08:08:37 2006
@@ -107,27 +107,29 @@
     {
         getLogger().debug("configure(" + configuration + ")");
 
-        String configFile = configuration.getChild("configfile").getValue();
+        String configurationFile
+                = configuration.getChild("configfile").getValue();
 
         if (StringUtils.isNotEmpty(appRoot))
         {
-            if (configFile.startsWith("/"))
+            if (configurationFile.startsWith("/"))
             {
-                configFile = configFile.substring(1);
-                getLogger().debug("Config File changes to " + configFile);
+                configurationFile = configurationFile.substring(1);
+                getLogger().debug("Config File changes to "
+                        + configurationFile);
             }
 
             StringBuffer sb = new StringBuffer();
             sb.append(appRoot);
             sb.append(File.separator);
-            sb.append(configFile);
+            sb.append(configurationFile);
 
-            configFile = sb.toString();
+            configurationFile = sb.toString();
         }
 
-        getLogger().debug("Config File is " + configFile);
+        getLogger().debug("Config File is " + configurationFile);
 
-        this.configFile = configFile;
+        this.configFile = configurationFile;
     }
 
     /**

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/JndiDataSourceFactory.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/JndiDataSourceFactory.java?view=diff&rev=476550&r1=476549&r2=476550
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/JndiDataSourceFactory.java
(original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/JndiDataSourceFactory.java
Sat Nov 18 08:08:37 2006
@@ -205,7 +205,7 @@
         log.debug("Starting initDataSource");
         try
         {
-            Object ds = null;
+            Object dataSource = null;
 
             Configuration c = configuration.subset(DATASOURCE_KEY);
             if (c != null)
@@ -222,17 +222,17 @@
                         }
 
                         Class dsClass = Class.forName(classname);
-                        ds = dsClass.newInstance();
+                        dataSource = dsClass.newInstance();
                     }
                     else
                     {
-                        if (ds != null)
+                        if (dataSource != null)
                         {
                             if (log.isDebugEnabled())
                             {
                                 log.debug("Setting datasource property: " + key);
                             }
-                            setProperty(key, c, ds);
+                            setProperty(key, c, dataSource);
                         }
                         else
                         {
@@ -243,9 +243,9 @@
                 }
             }
 
-            if (ds != null)
+            if (dataSource != null)
             {
-                bindDStoJndi(ctx, path, ds);
+                bindDStoJndi(ctx, path, dataSource);
             }
         }
         catch (Exception e)
@@ -277,7 +277,7 @@
         log.debug("Environment properties:" + env.size());
         while (qw.hasNext())
         {
-            Map.Entry entry = (Map.Entry)qw.next();
+            Map.Entry entry = (Map.Entry) qw.next();
             log.debug("    " + entry.getKey() + ": " + entry.getValue());
         }
         log.debug("----------------------------------------------");
@@ -315,9 +315,14 @@
                 catch (NameAlreadyBoundException nabe)
                 {
                     // ignore
+                    log.debug("Sub context " + subctx + " already exists");
                 }
                 catch (NamingException ne)
                 {
+                    log.debug("Naming exception caught "
+                                + "when creating subcontext"
+                                + subctx,
+                            ne);
                     // even though there is a specific exception
                     // for this condition, some implementations
                     // throw the more general one.

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/PerUserPoolDataSourceFactory.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/PerUserPoolDataSourceFactory.java?view=diff&rev=476550&r1=476549&r2=476550
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/PerUserPoolDataSourceFactory.java
(original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/PerUserPoolDataSourceFactory.java
Sat Nov 18 08:08:37 2006
@@ -66,9 +66,9 @@
         super.initialize(configuration);
 
         ConnectionPoolDataSource cpds = initCPDS(configuration);
-        PerUserPoolDataSource ds = initJdbc2Pool(configuration);
-        ds.setConnectionPoolDataSource(cpds);
-        this.ds = ds;
+        PerUserPoolDataSource dataSource = initJdbc2Pool(configuration);
+        dataSource.setConnectionPoolDataSource(cpds);
+        this.ds = dataSource;
     }
 
     /**
@@ -82,7 +82,7 @@
         throws TorqueException
     {
         log.debug("Starting initJdbc2Pool");
-        PerUserPoolDataSource ds = new PerUserPoolDataSource();
+        PerUserPoolDataSource dataSource = new PerUserPoolDataSource();
         Configuration c = Torque.getConfiguration();
 
         if (c == null || c.isEmpty())
@@ -93,12 +93,12 @@
         else
         {
             Configuration conf = c.subset(DEFAULT_POOL_KEY);
-            applyConfiguration(conf, ds);
+            applyConfiguration(conf, dataSource);
         }
 
         Configuration conf = configuration.subset(POOL_KEY);
-        applyConfiguration(conf, ds);
-        return ds;
+        applyConfiguration(conf, dataSource);
+        return dataSource;
     }
 
     /**

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/SharedPoolDataSourceFactory.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/SharedPoolDataSourceFactory.java?view=diff&rev=476550&r1=476549&r2=476550
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/SharedPoolDataSourceFactory.java
(original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/SharedPoolDataSourceFactory.java
Sat Nov 18 08:08:37 2006
@@ -66,9 +66,9 @@
         super.initialize(configuration);
 
         ConnectionPoolDataSource cpds = initCPDS(configuration);
-        SharedPoolDataSource ds = initJdbc2Pool(configuration);
-        ds.setConnectionPoolDataSource(cpds);
-        this.ds = ds;
+        SharedPoolDataSource dataSource = initJdbc2Pool(configuration);
+        dataSource.setConnectionPoolDataSource(cpds);
+        this.ds = dataSource;
     }
 
     /**
@@ -82,7 +82,7 @@
         throws TorqueException
     {
         log.debug("Starting initJdbc2Pool");
-        SharedPoolDataSource ds = new SharedPoolDataSource();
+        SharedPoolDataSource dataSource = new SharedPoolDataSource();
         Configuration c = Torque.getConfiguration();
 
         if (c == null || c.isEmpty())
@@ -93,12 +93,12 @@
         else
         {
             Configuration conf = c.subset(DEFAULT_POOL_KEY);
-            applyConfiguration(conf, ds);
+            applyConfiguration(conf, dataSource);
         }
 
         Configuration conf = configuration.subset(POOL_KEY);
-        applyConfiguration(conf, ds);
-        return ds;
+        applyConfiguration(conf, dataSource);
+        return dataSource;
     }
 
 

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/map/DatabaseMap.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/map/DatabaseMap.java?view=diff&rev=476550&r1=476549&r2=476550
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/map/DatabaseMap.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/map/DatabaseMap.java Sat Nov 18 08:08:37
2006
@@ -48,12 +48,12 @@
      * The character used by most implementations as the separator
      * between name elements.
      */
-    char STD_SEPARATOR_CHAR = '_';
+    public static final char STD_SEPARATOR_CHAR = '_';
 
     /**
-     * The character which separates the schema name from the table name
+     * The character which separates the schema name from the table name.
      */
-    char SCHEMA_SEPARATOR_CHAR = '.';
+    public static final char SCHEMA_SEPARATOR_CHAR = '.';
 
     /**
      * Format used to create create the class name for initializing a DB
@@ -62,7 +62,10 @@
     public static final String INIT_CLASS_NAME_FORMAT =
                                 "org.apache.torque.linkage.{0}MapInit";
 
-    public static String[] eMsgs = {
+    /**
+     * Error Messages for initialisation.
+     */
+    protected static final String[] ERROR_MESSAGES_INIT = {
         "Invalid Torque OM setup for Database \"{0}\".\n"
         + "Database Map initialization class, \"{1}\"," + " "
         + "could not be found in your classpath.",
@@ -79,6 +82,9 @@
     /** The serialVersionUID for this class. */
     private static final long serialVersionUID = 955251837095032274L;
 
+    /** The initial size of the Id-Generators map. */
+    private static final int ID_GENERATORS_INITIAL_SIZE = 6;
+
     /** Name of the database. */
     private String name;
 
@@ -98,7 +104,7 @@
     private HashMap idGenerators;
 
     /** Flag indicating that all tables have been loaded via initialize() */
-    boolean isInitialized = false;
+    private boolean isInitialized = false;
 
     /**
      * Constructs a new DatabaseMap.
@@ -106,7 +112,7 @@
     public DatabaseMap()
     {
         tables = Collections.synchronizedMap(new ListOrderedMap());
-        idGenerators = new HashMap(6);
+        idGenerators = new HashMap(ID_GENERATORS_INITIAL_SIZE);
     }
 
     /**
@@ -121,7 +127,7 @@
     {
         this.name = name;
         tables = Collections.synchronizedMap(new ListOrderedMap());
-        idGenerators = new HashMap(6);
+        idGenerators = new HashMap(ID_GENERATORS_INITIAL_SIZE);
     }
 
     /**
@@ -135,7 +141,7 @@
     {
         this.name = name;
         tables = Collections.synchronizedMap(new ListOrderedMap());
-        idGenerators = new HashMap(6);
+        idGenerators = new HashMap(ID_GENERATORS_INITIAL_SIZE);
     }
 
     /**
@@ -392,7 +398,9 @@
             return;
         }
         String initClassName = MessageFormat.format(INIT_CLASS_NAME_FORMAT,
-                new Object[] { javanameMethod(getName()) });
+                new Object[] {
+                    javanameMethod(getName())
+                });
 
         Class initClass = null;
         try
@@ -401,18 +409,31 @@
         }
         catch (ClassNotFoundException e)
         {
-            throw new TorqueException(MessageFormat.format(eMsgs[0],
-                    new Object[] { getName(), initClassName }), e);
+            throw new TorqueException(MessageFormat.format(
+                    ERROR_MESSAGES_INIT[0],
+                    new Object[] {
+                        getName(),
+                        initClassName
+                    }),
+                    e);
         }
         catch (LinkageError e)
         {
-            throw new TorqueException(MessageFormat.format(eMsgs[1],
-                    new Object[] { getName(), initClassName }), e);
+            throw new TorqueException(MessageFormat.format(
+                    ERROR_MESSAGES_INIT[1],
+                    new Object[] {
+                        getName(), initClassName
+                    }),
+                    e);
         }
         catch (Throwable e)
         {
-            throw new TorqueException(MessageFormat.format(eMsgs[2],
-                    new Object[] { getName(), initClassName }), e);
+            throw new TorqueException(MessageFormat.format(
+                    ERROR_MESSAGES_INIT[2],
+                    new Object[] {
+                        getName(), initClassName
+                    }),
+                    e);
         }
         try
         {
@@ -421,8 +442,12 @@
         }
         catch (Exception e)
         {
-            throw new TorqueException(MessageFormat.format(eMsgs[3],
-                    new Object[] { getName(), initClassName }), e);
+            throw new TorqueException(MessageFormat.format(
+                    ERROR_MESSAGES_INIT[3],
+                    new Object[] {
+                        getName(), initClassName
+                    }),
+                    e);
         }
         isInitialized = true;
     }
@@ -440,27 +465,27 @@
      */
     protected String javanameMethod(String schemaName)
     {
-        StringBuffer name = new StringBuffer();
+        StringBuffer result = new StringBuffer();
         StringTokenizer tok = new StringTokenizer
             (schemaName, String.valueOf(STD_SEPARATOR_CHAR));
         while (tok.hasMoreTokens())
         {
             String namePart = (String) tok.nextElement();
-            name.append(StringUtils.capitalize(namePart));
+            result.append(StringUtils.capitalize(namePart));
         }
 
         // remove the SCHEMA_SEPARATOR_CHARs and capitalize
         // the tokens
-        schemaName = name.toString();
-        name = new StringBuffer();
+        schemaName = result.toString();
+        result = new StringBuffer();
 
         tok = new StringTokenizer
             (schemaName, String.valueOf(SCHEMA_SEPARATOR_CHAR));
         while (tok.hasMoreTokens())
         {
             String namePart = (String) tok.nextElement();
-            name.append(StringUtils.capitalize(namePart));
+            result.append(StringUtils.capitalize(namePart));
         }
-        return name.toString();
+        return result.toString();
     }
 }

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/oid/IDBroker.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/oid/IDBroker.java?view=diff&rev=476550&r1=476549&r2=476550
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/oid/IDBroker.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/oid/IDBroker.java Sat Nov 18 08:08:37
2006
@@ -142,7 +142,7 @@
     /**
      * Amount of time for the thread to sleep
      */
-    private static final int SLEEP_PERIOD = 1 * 60000;
+    private static final int SLEEP_PERIOD = 60000;
 
     /**
      * The safety Margin
@@ -264,6 +264,9 @@
             }
             catch (Exception e)
             {
+                log.warn("Could not close the connection which was used "
+                        + "for testing whether transactions are supported",
+                        e);
             }
         }
         if (!transactionsSupported)
@@ -478,16 +481,14 @@
     }
 
     /**
-     * Describe <code>exists</code> method here.
-     *
      * @param tableName a <code>String</code> value that is used to identify
      * the row
      * @return a <code>boolean</code> value
-     * @exception TorqueException if an error occurs
-     * @exception Exception a generic exception.
+     * @exception TorqueException if a Torque error occurs.
+     * @exception Exception if another error occurs.
      */
     public boolean exists(String tableName)
-        throws TorqueException, Exception
+        throws Exception
     {
         String query = new StringBuffer(100)
             .append("select ")

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/oid/IDGeneratorFactory.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/oid/IDGeneratorFactory.java?view=diff&rev=476550&r1=476549&r2=476550
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/oid/IDGeneratorFactory.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/oid/IDGeneratorFactory.java Sat Nov
18 08:08:37 2006
@@ -32,6 +32,16 @@
 public class IDGeneratorFactory
 {
     /**
+     * Private constructor to prevent initialisation.
+     *
+     * This class contains only static methods and thus should not be
+     * instantiated.
+     */
+    private IDGeneratorFactory()
+    {
+    }
+
+    /**
      * The list of ID generation method types which have associated
      * {@link org.apache.torque.oid.IdGenerator} implementations.
      */

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/om/BaseObject.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/om/BaseObject.java?view=diff&rev=476550&r1=476549&r2=476550
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/om/BaseObject.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/om/BaseObject.java Sat Nov 18 08:08:37
2006
@@ -187,8 +187,8 @@
      *             field object type.
      * @throws TorqueException If a problem occures with the set[Field] method.
      */
-    public boolean setByName(String name, Object value) throws TorqueException,
-            IllegalArgumentException
+    public boolean setByName(String name, Object value)
+            throws TorqueException
     {
         throw new Error("BaseObject.setByName: " + NOT_IMPLEMENTED);
     }
@@ -217,7 +217,7 @@
      * @throws TorqueException If a problem occures with the set[Field] method.
      */
     public boolean setByPeerName(String name, Object value)
-            throws TorqueException, IllegalArgumentException
+            throws TorqueException
     {
         throw new Error("BaseObject.setByPeerName: " + NOT_IMPLEMENTED);
     }
@@ -247,7 +247,7 @@
      * @throws TorqueException If a problem occures with the set[Field] method.
      */
     public boolean setByPosition(int position, Object value)
-            throws TorqueException, IllegalArgumentException
+            throws TorqueException
     {
         throw new Error("BaseObject.setByPosition: " + NOT_IMPLEMENTED);
     }

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/om/DateKey.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/om/DateKey.java?view=diff&rev=476550&r1=476549&r2=476550
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/om/DateKey.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/om/DateKey.java Sat Nov 18 08:08:37
2006
@@ -50,7 +50,7 @@
      * @param key the key value
      * @throws NumberFormatException if key is not valid
      */
-    public DateKey(String key) throws NumberFormatException
+    public DateKey(String key)
     {
         this.key = new Date(Long.parseLong(key));
     }

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/util/Criteria.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/util/Criteria.java?view=diff&rev=476550&r1=476549&r2=476550
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/util/Criteria.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/util/Criteria.java Sat Nov 18 08:08:37
2006
@@ -1808,6 +1808,7 @@
         }
         catch (Exception exc)
         {
+            log.debug("Exception when evaluating a Criteria", exc);
         }
 
         return sb.toString();
@@ -3588,7 +3589,7 @@
             }
             catch (TorqueException e)
             {
-                return("Criterion cannot be evaluated");
+                return "Criterion cannot be evaluated";
             }
             return expr.toString();
         }

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/util/JoinBuilder.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/util/JoinBuilder.java?view=diff&rev=476550&r1=476549&r2=476550
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/util/JoinBuilder.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/util/JoinBuilder.java Sat Nov 18 08:08:37
2006
@@ -19,7 +19,6 @@
  * under the License.
  */
 
-import java.io.Serializable;
 import java.util.List;
 
 import org.apache.torque.TorqueException;
@@ -35,16 +34,25 @@
  * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
  * @version $Id$
  */
-public abstract class JoinBuilder
-        implements Serializable
+public final class JoinBuilder
 {
     /**
+     * Private constructor to prevent initialisation.
+     *
+     * Class contains only static methods and should therefore not be
+     * instantiated.
+     */
+    private JoinBuilder()
+    {
+    }
+
+    /**
      * adds the Joins from the criteria to the query
      * @param criteria the criteria from which the Joins are taken
      * @param query the query to which the Joins should be added
      * @throws TorqueException if the Joins can not be processed
      */
-    public static final void processJoins(
+    public static void processJoins(
             final DB db,
             final DatabaseMap dbMap,
             final Criteria criteria,
@@ -209,8 +217,7 @@
      * @param joinType the join type to be reversed
      * @return the reversed join type
      */
-    private static final SqlEnum reverseJoinType(
-            final SqlEnum joinType)
+    private static SqlEnum reverseJoinType(final SqlEnum joinType)
     {
         if (SqlEnum.LEFT_JOIN.equals(joinType))
         {

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/util/LargeSelect.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/util/LargeSelect.java?view=diff&rev=476550&r1=476549&r2=476550
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/util/LargeSelect.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/util/LargeSelect.java Sat Nov 18 08:08:37
2006
@@ -228,6 +228,17 @@
      */
     private static int memoryPageLimit = DEFAULT_MEMORY_LIMIT_PAGES;
 
+    /**
+     * The number of milliseconds to sleep when the result of a query
+     * is not yet available.
+     */
+    private static final int QUERY_NOT_COMPLETED_SLEEP_TIME = 500;
+
+    /**
+     * The number of milliseconds to sleep before retrying to stop a query.
+     */
+    private static final int QUERY_STOP_SLEEP_TIME = 100;
+
     /** A place to store search parameters that relate to this query. */
     private Hashtable params = null;
 
@@ -249,7 +260,6 @@
      * both of offset and limit, or if <code>pageSize</code> is less than 1;
      */
     public LargeSelect(Criteria criteria, int pageSize)
-            throws IllegalArgumentException
     {
         this(criteria, pageSize, LargeSelect.memoryPageLimit);
     }
@@ -272,7 +282,6 @@
      * <code>memoryLimitPages</code> are less than 1;
      */
     public LargeSelect(Criteria criteria, int pageSize, int memoryPageLimit)
-            throws IllegalArgumentException
     {
         init(criteria, pageSize, memoryPageLimit);
     }
@@ -305,7 +314,6 @@
             Criteria criteria,
             int pageSize,
             String returnBuilderClassName)
-            throws IllegalArgumentException
     {
         this(
             criteria,
@@ -346,7 +354,6 @@
             int pageSize,
             int memoryPageLimit,
             String returnBuilderClassName)
-            throws IllegalArgumentException
     {
         try
         {
@@ -375,9 +382,14 @@
 
     /**
      * Access the populateObjects method.
+     *
+     * @throws SecurityException if the security manager does not allow
+     *         access to the method.
+     * @throws NoSuchMethodException if the poulateObjects method does not
+     *         exist.
      */
     private Method getPopulateObjectsMethod()
-            throws SecurityException, NoSuchMethodException
+            throws NoSuchMethodException
     {
         if (null == populateObjectsMethod)
         {
@@ -403,7 +415,6 @@
      * <code>memoryLimitPages</code> are less than 1;
      */
     private void init(Criteria criteria, int pageSize, int memoryLimitPages)
-            throws IllegalArgumentException
     {
         if (criteria.getOffset() != 0 || criteria.getLimit() != -1)
         {
@@ -541,7 +552,7 @@
      * method runs into problems or a sleep is unexpectedly interrupted.
      */
     private synchronized List getResults(int start, int size)
-            throws IllegalArgumentException, TorqueException
+            throws TorqueException
     {
         if (log.isDebugEnabled())
         {
@@ -571,7 +582,7 @@
             {
                 try
                 {
-                    Thread.sleep(500);
+                    Thread.sleep(QUERY_NOT_COMPLETED_SLEEP_TIME);
                 }
                 catch (InterruptedException e)
                 {
@@ -913,7 +924,7 @@
             {
                 try
                 {
-                    Thread.sleep(100);
+                    Thread.sleep(QUERY_STOP_SLEEP_TIME);
                 }
                 catch (InterruptedException e)
                 {

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/util/Query.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/util/Query.java?view=diff&rev=476550&r1=476549&r2=476550
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/util/Query.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/util/Query.java Sat Nov 18 08:08:37
2006
@@ -381,13 +381,13 @@
     {
 
         /** the tablename, might contain an appended alias name */
-        String tableName = null;
+        private String tableName = null;
 
         /** the type of the join, e.g. SqlEnum.LEFT_JOIN */
-        SqlEnum joinType = null;
+        private SqlEnum joinType = null;
 
         /** the join condition, e.g. table_a.id = table_b.a_id */
-        String joinCondition = null;
+        private String joinCondition = null;
 
         /**
          * Constructor

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/util/SQLBuilder.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/util/SQLBuilder.java?view=diff&rev=476550&r1=476549&r2=476550
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/util/SQLBuilder.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/util/SQLBuilder.java Sat Nov 18 08:08:37
2006
@@ -19,7 +19,6 @@
  * under the License.
  */
 
-import java.io.Serializable;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
@@ -45,8 +44,7 @@
  * @author <a href="mailto:fischer@seitenbau.de">Thomas Fischer</a>
  * @version $Id$
  */
-public abstract class SQLBuilder
-        implements Serializable
+public final class SQLBuilder
 {
     /** Logging */
     protected static final Log log = LogFactory.getLog(SQLBuilder.class);
@@ -56,6 +54,16 @@
     public static final String[] DELIMITERS = {" ", ",", "(", ")", "<", ">"};
 
     /**
+     * Private constructor to prevent instantiation.
+     *
+     * Class contains only static method ans should therefore not be
+     * instantiated.
+     */
+    private SQLBuilder()
+    {
+    }
+
+    /**
      * Fully qualify a table name with an optional schema reference
      *
      * @param table The table name to use. If null is passed in, null is returned.
@@ -66,8 +74,10 @@
      *         into this method, null is returned.
      * @exception TorqueException if an error occurs
      */
-    public static final String getFullTableName(final String table, final String dbName)
-            throws TorqueException
+    public static String getFullTableName(
+            final String table,
+            final String dbName)
+        throws TorqueException
     {
         if (table != null)
         {
@@ -105,7 +115,7 @@
      * @return The table name with a possible schema name
      *         stripped off
      */
-    public static final String getUnqualifiedTableName(final String table)
+    public static String getUnqualifiedTableName(final String table)
     {
         if (table != null)
         {
@@ -220,7 +230,7 @@
      * @param tableCallback A Callback Object
      * @return A Set of tables.
      */
-    public static final Set getTableSet(
+    public static Set getTableSet(
             final Criteria crit,
             final TableCallback tableCallback)
     {
@@ -271,7 +281,7 @@
      * @return a <code>Query</code> value
      * @exception TorqueException if an error occurs
      */
-    public static final Query buildQueryClause(final Criteria crit,
+    public static Query buildQueryClause(final Criteria crit,
             final List params,
             final QueryCallback qc)
             throws TorqueException
@@ -608,7 +618,7 @@
      * @throws TorqueException Any exceptions caught during processing will be
      *         rethrown wrapped into a TorqueException.
      */
-    public static final void throwMalformedColumnNameException(
+    public static void throwMalformedColumnNameException(
         final String criteriaPhrase,
         final String columnName)
         throws TorqueException
@@ -636,7 +646,7 @@
      *         or a String of the form "tableName tableOrAliasName"
      *         if tableOrAliasName is an alias for a table name
      */
-    public static final String getTableNameForFromClause(
+    public static String getTableNameForFromClause(
             final String tableName,
             final Criteria criteria)
     {
@@ -681,7 +691,7 @@
      * @return if the Tablename tableName is already contained in a from clause.
      *         If tableName is null, true is returned.
      */
-    public static final boolean fromClauseContainsTableName(
+    public static boolean fromClauseContainsTableName(
             final UniqueList fromClause,
             final String tableName)
     {

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/util/SqlExpression.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/util/SqlExpression.java?view=diff&rev=476550&r1=476549&r2=476550
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/util/SqlExpression.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/util/SqlExpression.java Sat Nov 18
08:08:37 2006
@@ -28,7 +28,6 @@
 import org.apache.commons.lang.StringUtils;
 import org.apache.torque.TorqueException;
 import org.apache.torque.adapter.DB;
-import org.apache.torque.adapter.DBPostgres;
 import org.apache.torque.om.DateKey;
 import org.apache.torque.om.ObjectKey;
 import org.apache.torque.om.StringKey;
@@ -50,12 +49,22 @@
  * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
  * @version $Id$
  */
-public class SqlExpression
+public final class SqlExpression
 {
     /** escaped single quote */
     private static final char SINGLE_QUOTE = '\'';
     /** escaped backslash */
     private static final char BACKSLASH = '\\';
+
+    /**
+     * Private constructor to prevent instantiation.
+     *
+     * Class contains only static method ans should therefore not be
+     * instantiated.
+     */
+    private SqlExpression()
+    {
+    }
 
     /**
      * Used to specify a join on two columns.

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/util/Transaction.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/util/Transaction.java?view=diff&rev=476550&r1=476549&r2=476550
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/util/Transaction.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/util/Transaction.java Sat Nov 18 08:08:37
2006
@@ -44,11 +44,21 @@
  * @author <a href="mailto:stephenh@chase3000.com">Stephen Haberman</a>
  * @version $Id$
  */
-public class Transaction
+public final class Transaction
 {
 
     /** The log. */
     private static Log log = LogFactory.getLog(Transaction.class);
+
+    /**
+     * Private constructor to prevent instantiation.
+     *
+     * Class contains only static method ans should therefore not be
+     * instantiated.
+     */
+    private Transaction()
+    {
+    }
 
     /**
      * Begin a transaction for the default database.

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/util/VillageUtils.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/util/VillageUtils.java?view=diff&rev=476550&r1=476549&r2=476550
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/util/VillageUtils.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/util/VillageUtils.java Sat Nov 18 08:08:37
2006
@@ -29,6 +29,8 @@
 import java.util.Iterator;
 import java.util.Map;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.torque.om.SimpleKey;
 
 import com.workingdogs.village.QueryDataSet;
@@ -41,9 +43,21 @@
  * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
  * @version $Id$
  */
-public abstract class VillageUtils
-        implements Serializable
+public final class VillageUtils
 {
+    /** The log. */
+    private static Log log = LogFactory.getLog(VillageUtils.class);
+
+    /**
+     * Private constructor to prevent instantiation.
+     *
+     * Class contains only static method ans should therefore not be
+     * instantiated.
+     */
+    private VillageUtils()
+    {
+    }
+
     /**
      * Convenience Method to close a Table Data Set without
      * Exception check.
@@ -60,6 +74,8 @@
             }
             catch (Exception ignored)
             {
+                log.debug("Caught exception when closing a TableDataSet",
+                        ignored);
             }
         }
     }
@@ -80,6 +96,8 @@
             }
             catch (Exception ignored)
             {
+                log.debug("Caught exception when closing a QueryDataSet",
+                        ignored);
             }
         }
     }
@@ -101,6 +119,8 @@
         }
         catch (Exception ignored)
         {
+            log.debug("Caught exception when closing an OutputStream",
+                    ignored);
         }
     }
 
@@ -109,8 +129,7 @@
      *
      * @param hash The Hashtable to convert.
      * @return A byte[] with the converted Hashtable.
-     * @throws TorqueException Any exceptions caught during processing will be
-     *         rethrown wrapped into a TorqueException.
+     * @throws Exception If an error occurs.
      */
     public static final byte[] hashtableToByteArray(final Hashtable hash)
         throws Exception
@@ -121,7 +140,7 @@
         Iterator keys = hash.entrySet().iterator();
         while (keys.hasNext())
         {
-            Map.Entry entry = (Map.Entry)keys.next();
+            Map.Entry entry = (Map.Entry) keys.next();
             if (entry.getValue() instanceof Serializable)
             {
                 saveData.put(entry.getKey(), entry.getValue());
@@ -238,5 +257,3 @@
         }
     }
 }
-
-



---------------------------------------------------------------------
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