stephenh    2002/09/12 22:06:39

  Modified:    src/java/org/apache/torque/adapter DBMM.java DBNone.java
                        DBPostgres.java
               src/java/org/apache/torque/dsfactory
                        AbstractDataSourceFactory.java
                        DataSourceFactory.java
                        Jdbc2PoolDataSourceFactory.java
                        JndiDataSourceFactory.java
                        TorqueDataSourceFactory.java
               src/java/org/apache/torque/engine/database/transform
                        DTDResolver.java
  Log:
  Checkstyle fixes.
  
  Revision  Changes    Path
  1.11      +5 -2      
jakarta-turbine-torque/src/java/org/apache/torque/adapter/DBMM.java
  
  Index: DBMM.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/adapter/DBMM.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DBMM.java 24 Jun 2002 18:12:19 -0000      1.10
  +++ DBMM.java 13 Sep 2002 05:06:38 -0000      1.11
  @@ -78,10 +78,12 @@
    */
   public class DBMM extends DB
   {
  +    
  +    /** A specialized date format for MySQL. */
       private static final String DATE_FORMAT = "yyyyMMddHHmmss";
   
       /**
  -     * Empty constructor.
  +     * Empty protected constructor.
        */
       protected DBMM()
       {
  @@ -198,6 +200,7 @@
        * using a <code>DateFormat</code>.  As of version 2.0.11, the MM
        * JDBC driver does not implement JDBC 3.0 escapes.
        *
  +     * @param date the date to format
        * @return The properly formatted date String.
        */
       public String getDateString(Date date)
  
  
  
  1.6       +8 -22     
jakarta-turbine-torque/src/java/org/apache/torque/adapter/DBNone.java
  
  Index: DBNone.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/adapter/DBNone.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DBNone.java       24 Jun 2002 18:12:19 -0000      1.5
  +++ DBNone.java       13 Sep 2002 05:06:38 -0000      1.6
  @@ -65,42 +65,28 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Brett McLaughlin</a>
    * @version $Id$
    */
  -public class DBNone
  -    extends DB
  +public class DBNone extends DB
   {
  +
       /**
  -     * Empty constructor.
  +     * Empty protected constructor.
        */
       protected DBNone()
       {
       }
   
       /**
  -     * Returns a JDBC <code>Connection</code> from the
  -     * <code>DriverManager</code>.
  -     *
  -     * @return null.
  -     * @exception SQLException
  +     * @return null
        */
  -    public Connection getConnection() throws SQLException
  +    public Connection getConnection()
       {
           return null;
       }
   
       /**
  -     * Performs basic initialization.  Calls Class.forName() to assure
  -     * that the JDBC driver for this adapter can be loaded.
  -     *
  -     * @param url The URL of the database to connect to.
  -     * @param username The name of the user to use when connecting.
  -     * @param password The user's password.
  -     * @exception Exception The JDBC driver could not be loaded or
  -     * instantiated.
  +     * @see org.apache.torque.adapters.DB#init
        */
  -    public void init(String url,
  -                     String username,
  -                     String password)
  -        throws Exception
  +    public void init(String url, String username, String password)
       {
       }
   
  
  
  
  1.11      +8 -2      
jakarta-turbine-torque/src/java/org/apache/torque/adapter/DBPostgres.java
  
  Index: DBPostgres.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/adapter/DBPostgres.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DBPostgres.java   31 Aug 2002 22:57:50 -0000      1.10
  +++ DBPostgres.java   13 Sep 2002 05:06:38 -0000      1.11
  @@ -122,7 +122,7 @@
        * which support this feature will return a result, others will
        * return null.
        *
  -     * @return The most recently inserted database key.
  +     * @see org.apache.torque.adapters.DB#getSequenceSql
        */
       public String getSequenceSql(Object obj)
       {
  @@ -185,8 +185,14 @@
           return DB.LIMIT_STYLE_POSTGRES;
       }
   
  +    /**
  +     * Override the default behavior to associate b with null?
  +     * 
  +     * @see org.apache.torque.adapters.DB#getBooleanString
  +     */
       public String getBooleanString(Boolean b)
       {
           return (b == null) ? "0" : "1";
       }
  +
   }
  
  
  
  1.4       +19 -7     
jakarta-turbine-torque/src/java/org/apache/torque/dsfactory/AbstractDataSourceFactory.java
  
  Index: AbstractDataSourceFactory.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/dsfactory/AbstractDataSourceFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractDataSourceFactory.java    9 Sep 2002 17:28:14 -0000       1.3
  +++ AbstractDataSourceFactory.java    13 Sep 2002 05:06:38 -0000      1.4
  @@ -73,9 +73,18 @@
       /**
        * The logging category.
        */
  -    protected static Category category =
  -        Category.getInstance("org.apache.torque");
  +    private static Category category =
  +        Category.getInstance(AbstractDataSourceFactory.class);
   
  +    /**
  +     * Encapsulates setting configuration properties on 
  +     * <code>DataSource</code> objects.
  +     * 
  +     * @param property the property to read from the configuration
  +     * @param c the configuration to read the property from
  +     * @param ds the <code>DataSource</code> instance to write the property to
  +     * @throws Exception if anything goes wrong
  +     */
       protected void setProperty(String property, Configuration c, Object ds)
           throws Exception
       {
  @@ -114,10 +123,13 @@
           }
           catch (Exception e)
           {
  -            category.error("Property: " + property + " value: "
  -                           + c.getString(key) +
  -                           " is not supported by DataSource: " +
  -                           ds.getClass().getName());
  +            category.error(
  +                "Property: "
  +                + property
  +                + " value: "
  +                + c.getString(key)
  +                + " is not supported by DataSource: "
  +                + ds.getClass().getName());
               throw e;
           }
       }
  
  
  
  1.2       +8 -6      
jakarta-turbine-torque/src/java/org/apache/torque/dsfactory/DataSourceFactory.java
  
  Index: DataSourceFactory.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/dsfactory/DataSourceFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DataSourceFactory.java    26 May 2002 04:30:10 -0000      1.1
  +++ DataSourceFactory.java    13 Sep 2002 05:06:38 -0000      1.2
  @@ -66,18 +66,20 @@
    */
   public interface DataSourceFactory
   {
  +    
       /**
  -     *
  +     * @return the <code>DataSource</code> configured by the factory.
  +     * @throws TorqueException if the source can't be returned
        */
  -    public DataSource getDataSource()
  -        throws TorqueException;
  +    DataSource getDataSource() throws TorqueException;
   
       /**
  -     * initialize
  +     * Initialize the factory.
        *
  +     * @param configuration where to load the factory settings from
        * @throws TorqueException Any exceptions caught during processing will be
        *         rethrown wrapped into a TorqueException.
        */
  -    public void initialize(Configuration configuration) 
  +    void initialize(Configuration configuration) 
           throws TorqueException;
   }
  
  
  
  1.3       +32 -22    
jakarta-turbine-torque/src/java/org/apache/torque/dsfactory/Jdbc2PoolDataSourceFactory.java
  
  Index: Jdbc2PoolDataSourceFactory.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/dsfactory/Jdbc2PoolDataSourceFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Jdbc2PoolDataSourceFactory.java   7 Aug 2002 08:07:02 -0000       1.2
  +++ Jdbc2PoolDataSourceFactory.java   13 Sep 2002 05:06:38 -0000      1.3
  @@ -54,14 +54,16 @@
    * <http://www.apache.org/>.
    */
   
  -import javax.sql.DataSource;
  +import java.util.Iterator;
  +
   import javax.sql.ConnectionPoolDataSource;
  +import javax.sql.DataSource;
   
  -import java.util.Iterator;
   import org.apache.commons.configuration.Configuration;
  -import org.apache.torque.TorqueException;
  -import org.apache.commons.dbcp.jdbc2pool.Jdbc2PoolDataSource;
   import org.apache.commons.dbcp.cpdsadapter.DriverAdapterCPDS;
  +import org.apache.commons.dbcp.jdbc2pool.Jdbc2PoolDataSource;
  +import org.apache.log4j.Category;
  +import org.apache.torque.TorqueException;
   
   /**
    * A factory that looks up the DataSource from JNDI.  It is also able
  @@ -75,10 +77,16 @@
       extends AbstractDataSourceFactory
       implements DataSourceFactory
   {
  +    
  +    /** The log. */
  +    private static Category category =
  +        Category.getInstance(Jdbc2PoolDataSourceFactory.class);
  +        
  +    /** The wrapped <code>DataSource</code>. */
       private DataSource ds;
   
       /**
  -     *
  +     * @see org.apache.torque.dsfactory.DataSourceFactory#getDataSource
        */
       public DataSource getDataSource()
       {
  @@ -86,26 +94,30 @@
       }
   
       /**
  -     * initialize
  -     *
  -     * @throws TorqueException Any exceptions caught during processing will be
  -     *         rethrown wrapped into a TorqueException.
  +     * @see org.apache.torque.dsfactory.DataSourceFactory#initialize
        */
  -    public void initialize(Configuration configuration) 
  -        throws TorqueException
  +    public void initialize(Configuration configuration) throws TorqueException
       {
           if (configuration == null)
           {
  -            throw new TorqueException("Torque cannot be initialized without " +
  -                "a valid configuration. Please check the log files " +
  -                    "for further details.");
  -        }        
  +            throw new TorqueException(
  +                "Torque cannot be initialized without a valid configuration. "
  +                + "Please check the log files for further details.");
  +        }
  +        
           ConnectionPoolDataSource cpds = initCPDS(configuration);
           Jdbc2PoolDataSource ds = initJdbc2Pool(configuration);
           ds.setConnectionPoolDataSource(cpds);
           this.ds = ds;
       }
   
  +    /**
  +     * Initializes the ConnectionPoolDataSource.
  +     * 
  +     * @param configuration where to read the settings from
  +     * @throws TorqueException if a property set fails
  +     * @return a configured <code>ConnectionPoolDataSource</code>
  +     */
       private ConnectionPoolDataSource initCPDS(Configuration configuration)
           throws TorqueException
       {
  @@ -117,9 +129,8 @@
               Iterator i = c.getKeys();
               while (i.hasNext())
               {
  -                String key = (String)i.next();
  -                category.debug("Setting datasource property: " 
  -                               + key);
  +                String key = (String) i.next();
  +                category.debug("Setting datasource property: " + key);
                   setProperty(key, c, cpds);
               }
           }            
  @@ -131,8 +142,7 @@
           return cpds;
       }
   
  -    private Jdbc2PoolDataSource 
  -        initJdbc2Pool(Configuration configuration)
  +    private Jdbc2PoolDataSource initJdbc2Pool(Configuration configuration)
           throws TorqueException
       {
           category.debug("Starting initTorqueClassic"); 
  @@ -143,7 +153,7 @@
               Iterator i = c.getKeys();
               while (i.hasNext())
               {
  -                String key = (String)i.next();
  +                String key = (String) i.next();
                   category.debug("Setting datasource property: " 
                                  + key);
                   setProperty(key, c, ds);
  
  
  
  1.3       +30 -26    
jakarta-turbine-torque/src/java/org/apache/torque/dsfactory/JndiDataSourceFactory.java
  
  Index: JndiDataSourceFactory.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/dsfactory/JndiDataSourceFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JndiDataSourceFactory.java        27 May 2002 12:17:43 -0000      1.2
  +++ JndiDataSourceFactory.java        13 Sep 2002 05:06:38 -0000      1.3
  @@ -54,16 +54,19 @@
    * <http://www.apache.org/>.
    */
   
  -import javax.sql.DataSource;
  +import java.util.Hashtable;
   import java.util.Iterator;
   import java.util.Map;
  -import java.util.Hashtable;
   import java.util.StringTokenizer;
  +
   import javax.naming.Context;
   import javax.naming.InitialContext;
   import javax.naming.NameAlreadyBoundException;
   import javax.naming.NamingException;
  +import javax.sql.DataSource;
  +
   import org.apache.commons.configuration.Configuration;
  +import org.apache.log4j.Category;
   import org.apache.torque.TorqueException;
   
   /**
  @@ -78,14 +81,20 @@
       extends AbstractDataSourceFactory
       implements DataSourceFactory
   {
  +
  +    /** The log. */
  +    private static Category category =
  +        Category.getInstance(JndiDataSourceFactory.class);
  +
  +    /** The path to get the resource from. */
       private String path;
  +    /** The context to get the resource from. */
       private Context ctx;
   
       /**
  -     *
  +     * @see org.apache.torque.dsfactory.DataSourceFactory#getDataSource
        */
  -    public DataSource getDataSource()
  -        throws TorqueException
  +    public DataSource getDataSource() throws TorqueException
       {
           DataSource ds = null;
           try
  @@ -100,35 +109,31 @@
       }
   
       /**
  -     * initialize
  -     *
  -     * @throws TorqueException Any exceptions caught during processing will be
  -     *         rethrown wrapped into a TorqueException.
  +     * @see org.apache.torque.dsfactory.DataSourceFactory#initialize
        */
  -    public void initialize(Configuration configuration)
  -        throws TorqueException
  +    public void initialize(Configuration configuration) throws TorqueException
       {
           if (configuration == null)
           {
  -            throw new TorqueException("Torque cannot be initialized without " +
  -                "a valid configuration. Please check the log files " +
  -                    "for further details.");
  +            throw new TorqueException(
  +                "Torque cannot be initialized without "
  +                    + "a valid configuration. Please check the log files "
  +                    + "for further details.");
           }
           initJNDI(configuration);
           initDataSource(configuration);
       }
   
  -
  -    private void initJNDI(Configuration configuration)
  -        throws TorqueException
  +    private void initJNDI(Configuration configuration) throws TorqueException
       {
           category.debug("Starting initJNDI");
           Hashtable env = null;
           Configuration c = configuration.subset("jndi");
           if (c == null)
           {
  -            throw new TorqueException("JndiDataSourceFactory requires a jndi "
  -                + "path property to lookup the DataSource in JNDI.");
  +            throw new TorqueException(
  +                "JndiDataSourceFactory requires a jndi "
  +                    + "path property to lookup the DataSource in JNDI.");
           }
           try
           {
  @@ -209,14 +214,13 @@
           }
       }
   
  -    private void debugCtx(Context ctx)
  -        throws NamingException
  +    private void debugCtx(Context ctx) throws NamingException
       {
           category.debug("InitialContext -------------------------------");
           Map env = ctx.getEnvironment();
           Iterator qw = env.keySet().iterator();
           category.debug("Environment properties:" + env.size());
  -        while ( qw.hasNext() )
  +        while (qw.hasNext())
           {
               Object prop = qw.next();
               category.debug("    " + prop + ": " + env.get(prop));
  @@ -231,15 +235,15 @@
   
           // add subcontexts, if not added already
           int start = path.indexOf(':') + 1;
  -        if ( start > 0 )
  +        if (start > 0)
           {
               path = path.substring(start);
           }
           StringTokenizer st = new StringTokenizer(path, "/");
  -        while ( st.hasMoreTokens() )
  +        while (st.hasMoreTokens())
           {
               String subctx = st.nextToken();
  -            if ( st.hasMoreTokens() )
  +            if (st.hasMoreTokens())
               {
                   try
                   {
  
  
  
  1.4       +31 -28    
jakarta-turbine-torque/src/java/org/apache/torque/dsfactory/TorqueDataSourceFactory.java
  
  Index: TorqueDataSourceFactory.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/dsfactory/TorqueDataSourceFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TorqueDataSourceFactory.java      9 Sep 2002 17:18:11 -0000       1.3
  +++ TorqueDataSourceFactory.java      13 Sep 2002 05:06:38 -0000      1.4
  @@ -54,14 +54,16 @@
    * <http://www.apache.org/>.
    */
   
  -import javax.sql.DataSource;
  +import java.util.Iterator;
  +
   import javax.sql.ConnectionPoolDataSource;
  +import javax.sql.DataSource;
   
  -import java.util.Iterator;
   import org.apache.commons.configuration.Configuration;
  +import org.apache.commons.dbcp.cpdsadapter.DriverAdapterCPDS;
  +import org.apache.log4j.Category;
   import org.apache.torque.TorqueException;
   import org.apache.torque.pool.TorqueClassicDataSource;
  -import org.apache.commons.dbcp.cpdsadapter.DriverAdapterCPDS;
   
   /**
    * A factory that looks up the DataSource from JNDI.  It is also able
  @@ -71,14 +73,20 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>John McNally</a>
    * @version $Id$
    */
  -public class TorqueDataSourceFactory 
  +public class TorqueDataSourceFactory
       extends AbstractDataSourceFactory
       implements DataSourceFactory
   {
  +
  +    /** The log. */
  +    private static Category category =
  +        Category.getInstance(TorqueDataSourceFactory.class);
  +
  +    /** The wrapped <code>DataSource</code>. */
       private DataSource ds;
   
       /**
  -     *
  +     * @see org.apache.torque.dsfactory.DataSourceFactory#getDataSource
        */
       public DataSource getDataSource()
       {
  @@ -86,20 +94,17 @@
       }
   
       /**
  -     * initialize
  -     *
  -     * @throws TorqueException Any exceptions caught during processing will be
  -     *         rethrown wrapped into a TorqueException.
  +     * @see org.apache.torque.dsfactory.DataSourceFactory#initialize
        */
  -    public void initialize(Configuration configuration) 
  -        throws TorqueException
  +    public void initialize(Configuration configuration) throws TorqueException
       {
           if (configuration == null)
           {
  -            throw new TorqueException("Torque cannot be initialized without " +
  -                "a valid configuration. Please check the log files " +
  -                    "for further details.");
  -        }        
  +            throw new TorqueException(
  +                "Torque cannot be initialized without "
  +                    + "a valid configuration. Please check the log files "
  +                    + "for further details.");
  +        }
           ConnectionPoolDataSource cpds = initCPDS(configuration);
           TorqueClassicDataSource tcds = initTorqueClassic(configuration);
           tcds.setConnectionPoolDataSource(cpds);
  @@ -109,7 +114,7 @@
       protected ConnectionPoolDataSource initCPDS(Configuration configuration)
           throws TorqueException
       {
  -        category.debug("Starting initCPDS"); 
  +        category.debug("Starting initCPDS");
           ConnectionPoolDataSource cpds = new DriverAdapterCPDS();
           Configuration c = configuration.subset("connection");
           try
  @@ -117,12 +122,11 @@
               Iterator i = c.getKeys();
               while (i.hasNext())
               {
  -                String key = (String)i.next();
  -                category.debug("Setting datasource property: " 
  -                               + key);
  +                String key = (String) i.next();
  +                category.debug("Setting datasource property: " + key);
                   setProperty(key, c, cpds);
               }
  -        }            
  +        }
           catch (Exception e)
           {
               category.error("", e);
  @@ -131,11 +135,11 @@
           return cpds;
       }
   
  -    protected TorqueClassicDataSource 
  -        initTorqueClassic(Configuration configuration)
  +    protected TorqueClassicDataSource initTorqueClassic(
  +        Configuration configuration)
           throws TorqueException
       {
  -        category.debug("Starting initTorqueClassic"); 
  +        category.debug("Starting initTorqueClassic");
           TorqueClassicDataSource ds = new TorqueClassicDataSource();
           Configuration c = configuration.subset("pool");
           try
  @@ -143,12 +147,11 @@
               Iterator i = c.getKeys();
               while (i.hasNext())
               {
  -                String key = (String)i.next();
  -                category.debug("Setting datasource property: " 
  -                               + key);
  +                String key = (String) i.next();
  +                category.debug("Setting datasource property: " + key);
                   setProperty(key, c, ds);
               }
  -        }            
  +        }
           catch (Exception e)
           {
               category.error("", e);
  
  
  
  1.8       +12 -7     
jakarta-turbine-torque/src/java/org/apache/torque/engine/database/transform/DTDResolver.java
  
  Index: DTDResolver.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/engine/database/transform/DTDResolver.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DTDResolver.java  24 Jul 2002 14:53:01 -0000      1.7
  +++ DTDResolver.java  13 Sep 2002 05:06:39 -0000      1.8
  @@ -72,6 +72,8 @@
    */
   public class DTDResolver implements EntityResolver
   {
  +
  +    /** Where the DTD is located on the web. */
       private static final String WEB_SITE_DTD =
           "http://jakarta.apache.org/turbine/dtd/database.dtd";;
   
  @@ -111,10 +113,12 @@
       {
           if (databaseDTD != null && WEB_SITE_DTD.equals(systemId))
           {
  -            String pkg = getClass().getName()
  -                .substring(0, getClass().getName().lastIndexOf("."));
  -            System.out.println("Resolver: used database.dtd from " +
  -                 pkg + " package ");
  +            String pkg =
  +                getClass().getName().substring(
  +                    0,
  +                    getClass().getName().lastIndexOf("."));
  +            System.out.println(
  +                "Resolver: used database.dtd from " + pkg + " package ");
               return databaseDTD;
           }
           else if (systemId == null)
  @@ -144,8 +148,9 @@
           }
           catch (IOException ex)
           {
  -            System.err.println("Couldn't read DTD specified in XML schema: " +
  -                               ex.getMessage());
  +            System.err.println(
  +                "Couldn't read DTD specified in XML schema: "
  +                    + ex.getMessage());
               //ex.printStackTrace();
               return new InputSource();
           }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to