mpoeschl    2002/07/12 14:40:13

  Modified:    src/java/org/apache/torque/util BasePeer.java Criteria.java
               src/java/org/apache/torque/manager MethodResultCache.java
  Log:
  code formatting
  
  Revision  Changes    Path
  1.48      +178 -189  
jakarta-turbine-torque/src/java/org/apache/torque/util/BasePeer.java
  
  Index: BasePeer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/util/BasePeer.java,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- BasePeer.java     3 Jul 2002 20:34:34 -0000       1.47
  +++ BasePeer.java     12 Jul 2002 21:40:12 -0000      1.48
  @@ -78,11 +78,11 @@
   import java.util.ArrayList;
   import javax.naming.Context;
   import javax.naming.InitialContext;
  +import org.apache.torque.Torque;
   import org.apache.torque.om.NumberKey;
   import org.apache.torque.om.ObjectKey;
   import org.apache.torque.om.SimpleKey;
   import org.apache.torque.om.StringKey;
  -import org.apache.torque.Torque;
   import org.apache.torque.adapter.DB;
   import org.apache.torque.oid.IdGenerator;
   import org.apache.torque.map.ColumnMap;
  @@ -155,7 +155,7 @@
        * @return A byte[] with the converted Hashtable.
        * @exception TorqueException
        */
  -    public static byte[] hashtableToByteArray( Hashtable hash )
  +    public static byte[] hashtableToByteArray(Hashtable hash)
           throws TorqueException
       {
           Hashtable saveData = new Hashtable(hash.size());
  @@ -168,9 +168,9 @@
           {
               key = (String) keys.next();
               value = hash.get(key);
  -            if ( value instanceof Serializable )
  +            if (value instanceof Serializable)
               {
  -                saveData.put ( key, value );
  +                saveData.put(key, value);
               }
           }
   
  @@ -240,7 +240,7 @@
        */
       public static Schema initTableSchema(String tableName)
       {
  -        return initTableSchema(tableName, null);
  +        return initTableSchema(tableName, Torque.getDefaultDB());
       }
   
       /**
  @@ -265,9 +265,8 @@
           catch (Exception e)
           {
               category.error(e);
  -            throw new Error("Error in BasePeer.initTableSchema(" +
  -                            tableName + "): " +
  -                            e.getMessage());
  +            throw new Error("Error in BasePeer.initTableSchema(" + tableName
  +                    + "): " + e.getMessage());
           }
           finally
           {
  @@ -369,7 +368,7 @@
           Connection con = Torque.getConnection(dbName);
           try
           {
  -            if ( con.getMetaData().supportsTransactions() )
  +            if (con.getMetaData().supportsTransactions())
               {
                   con.setAutoCommit(false);
               }
  @@ -394,7 +393,7 @@
       {
           try
           {
  -            if ( con.getMetaData().supportsTransactions() )
  +            if (con.getMetaData().supportsTransactions())
               {
                   con.commit();
                   con.setAutoCommit(true);
  @@ -422,26 +421,26 @@
       public static void rollBackTransaction(Connection con)
           throws TorqueException
       {
  -        if (con == null) 
  +        if (con == null)
           {
               throw new NullPointerException("Connection object was null. " +
  -                "This could be due to a misconfiguration of the " + 
  +                "This could be due to a misconfiguration of the " +
                   "DataSourceFactory.  Check the logs and Torque.properties " +
                   "to better determine the cause.");
           }
  -        
  +
           try
           {
  -            if ( con.getMetaData().supportsTransactions() )
  +            if (con.getMetaData().supportsTransactions())
               {
                   con.rollback();
                   con.setAutoCommit(true);
               }
               else
               {
  -                category.error(
  -                        "An attempt was made to rollback a transaction but the"
  -                        + " database did not allow the operation to be rolled 
back.");
  +                category.error("An attempt was made to rollback a transaction "
  +                        + "but the database did not allow the operation to be "
  +                        + "rolled back.");
               }
           }
           catch (SQLException e)
  @@ -466,11 +465,9 @@
        * @param value The value of the column.
        * @exception TorqueException
        */
  -    public static void deleteAll( Connection con,
  -                                  String table,
  -                                  String column,
  -                                  int value )
  -        throws TorqueException
  +    public static void deleteAll(Connection con, String table, String column,
  +            int value)
  +            throws TorqueException
       {
           Statement statement = null;
           try
  @@ -478,14 +475,14 @@
               statement = con.createStatement();
   
               StringBuffer query = new StringBuffer();
  -            query.append( "DELETE FROM " )
  -                .append( table )
  -                .append( " WHERE " )
  -                .append( column )
  -                .append( " = " )
  -                .append( value );
  +            query.append("DELETE FROM ")
  +                .append(table)
  +                .append(" WHERE ")
  +                .append(column)
  +                .append(" = ")
  +                .append(value);
   
  -            statement.executeUpdate( query.toString() );
  +            statement.executeUpdate(query.toString());
           }
           catch (SQLException e)
           {
  @@ -525,7 +522,7 @@
           {
               // Get a connection to the db.
               con = Torque.getConnection("default");
  -            deleteAll( con, table, column, value );
  +            deleteAll(con, table, column, value);
           }
           finally
           {
  @@ -603,13 +600,13 @@
               for (int i = 0; i < tableNames.length; i++)
               {
                   String tableName2 = criteria.getTableForAlias(tableNames[i]);
  -                if ( tableName2 != null )
  +                if (tableName2 != null)
                   {
                       tables.add(
                           new StringBuffer(tableNames[i].length() +
                                            tableName2.length() + 1)
                           .append(tableName2).append(' ').append(tableNames[i])
  -                        .toString() );
  +                        .toString());
                   }
                   else
                   {
  @@ -629,9 +626,9 @@
                           // Only delete rows where the foreign key is
                           // also a primary key.  Other rows need
                           // updateing, but that is not implemented.
  -                        if ( columnMaps[j].isForeignKey()
  +                        if (columnMaps[j].isForeignKey()
                               && columnMaps[j].isPrimaryKey()
  -                            && key.equals(columnMaps[j].getRelatedName()) )
  +                            && key.equals(columnMaps[j].getRelatedName()))
                           {
                               tables.add(tableMaps[i].getName());
                               criteria.add(columnMaps[j].getFullyQualifiedName(),
  @@ -647,30 +644,30 @@
               KeyDef kd = new KeyDef();
               StringStack whereClause = new StringStack();
   
  -            ColumnMap[] columnMaps =
  -                dbMap.getTable( tables.get(i) ).getColumns();
  +            ColumnMap[] columnMaps = dbMap.getTable(tables.get(i)).getColumns();
               for (int j = 0; j < columnMaps.length; j++)
               {
                   ColumnMap colMap = columnMaps[j];
  -                if ( colMap.isPrimaryKey() )
  +                if (colMap.isPrimaryKey())
                   {
                       kd.addAttrib( colMap.getColumnName() );
                   }
                   String key = new StringBuffer(colMap.getTableName())
                       .append('.').append(colMap.getColumnName()).toString();
  -                if ( criteria.containsKey(key) )
  +                if (criteria.containsKey(key))
                   {
  -                    if ( criteria.getComparison(key).equals(Criteria.CUSTOM) )
  +                    if (criteria.getComparison(key).equals(Criteria.CUSTOM))
                       {
                           whereClause.add( criteria.getString(key) );
                       }
                       else
                       {
  -                        whereClause.add( SqlExpression.build( 
colMap.getColumnName(),
  -                            criteria.getValue(key),
  -                            criteria.getComparison(key),
  -                            criteria.isIgnoreCase(),
  -                            db));
  +                        whereClause.add(SqlExpression.build(
  +                                colMap.getColumnName(),
  +                                criteria.getValue(key),
  +                                criteria.getComparison(key),
  +                                criteria.isIgnoreCase(),
  +                                db));
                       }
                   }
               }
  @@ -686,7 +683,7 @@
   
                   tds.where(sqlSnippet);
                   tds.fetchRecords();
  -                if ( tds.size() > 1 && criteria.isSingleRecord() )
  +                if (tds.size() > 1 && criteria.isSingleRecord())
                   {
                       handleMultipleRecords(tds);
                   }
  @@ -848,22 +845,21 @@
               {
                   try
                   {
  -                    if ( pk.getType() instanceof Number )
  +                    if (pk.getType() instanceof Number)
                       {
                           id = new NumberKey(keyGen.getIdAsBigDecimal
                                              (con, keyInfo));
                       }
                       else
                       {
  -                        id = new StringKey(keyGen.getIdAsString
  -                                           (con, keyInfo));
  +                        id = new StringKey(keyGen.getIdAsString(con, keyInfo));
                       }
                   }
                   catch (Exception e)
                   {
                       throw new TorqueException(e);
                   }
  -                criteria.add( pk.getFullyQualifiedName(), id );
  +                criteria.add(pk.getFullyQualifiedName(), id);
               }
           }
   
  @@ -871,7 +867,7 @@
           TableDataSet tds = null;
           try
           {
  -            tds = new TableDataSet(con, tableName );
  +            tds = new TableDataSet(con, tableName);
               Record rec = tds.addRecord();
               BasePeer.insertOrUpdateRecord(rec, tableName, criteria);
           }
  @@ -900,15 +896,13 @@
           {
               try
               {
  -                if ( pk.getType() instanceof Number )
  +                if (pk.getType() instanceof Number)
                   {
  -                    id = new NumberKey(keyGen.getIdAsBigDecimal
  -                                       (con, keyInfo));
  +                    id = new NumberKey(keyGen.getIdAsBigDecimal(con, keyInfo));
                   }
                   else
                   {
  -                    id = new StringKey(keyGen.getIdAsString
  -                                       (con, keyInfo));
  +                    id = new StringKey(keyGen.getIdAsString(con, keyInfo));
                   }
               }
               catch (Exception e)
  @@ -934,7 +928,7 @@
                                                Criteria criteria)
           throws TorqueException
       {
  -        DatabaseMap dbMap = Torque.getDatabaseMap( criteria.getDbName() );
  +        DatabaseMap dbMap = Torque.getDatabaseMap(criteria.getDbName());
   
           ColumnMap[] columnMaps = dbMap.getTable( tableName ).getColumns();
           boolean shouldSave = false;
  @@ -943,12 +937,12 @@
               ColumnMap colMap = columnMaps[j];
               String key = new StringBuffer(colMap.getTableName())
                   .append('.').append(colMap.getColumnName()).toString();
  -            if ( criteria.containsKey(key) )
  +            if (criteria.containsKey(key))
               {
                   // A village Record.setValue( String, Object ) would
                   // be nice here.
                   Object obj = criteria.getValue(key);
  -                if ( obj instanceof SimpleKey )
  +                if (obj instanceof SimpleKey)
                   {
                       obj = ((SimpleKey) obj).getValue();
                   }
  @@ -958,65 +952,62 @@
                       {
                           rec.setValueNull(colMap.getColumnName());
                       }
  -                    else if ( obj instanceof String )
  +                    else if (obj instanceof String)
                       {
  -                        rec.setValue( colMap.getColumnName(),
  -                                      (String) obj);
  +                        rec.setValue(colMap.getColumnName(), (String) obj);
                       }
  -                    else if ( obj instanceof Integer)
  +                    else if (obj instanceof Integer)
                       {
  -                        rec.setValue( colMap.getColumnName(),
  -                                      criteria.getInt(key));
  +                        rec.setValue(colMap.getColumnName(),
  +                                criteria.getInt(key));
                       }
  -                    else if ( obj instanceof BigDecimal)
  +                    else if (obj instanceof BigDecimal)
                       {
  -                        rec.setValue( colMap.getColumnName(),
  -                                      (BigDecimal) obj );
  +                        rec.setValue(colMap.getColumnName(), (BigDecimal) obj);
                       }
                       else if ( obj instanceof Boolean)
                       {
  -                        rec.setValue( colMap.getColumnName(),
  -                                      criteria.getBoolean(key) ? 1 : 0);
  +                        rec.setValue(colMap.getColumnName(),
  +                                criteria.getBoolean(key) ? 1 : 0);
                       }
  -                    else if ( obj instanceof java.util.Date)
  +                    else if (obj instanceof java.util.Date)
                       {
  -                        rec.setValue( colMap.getColumnName(),
  -                                      (java.util.Date) obj );
  +                        rec.setValue(colMap.getColumnName(),
  +                                (java.util.Date) obj);
                       }
  -                    else if ( obj instanceof Float)
  +                    else if (obj instanceof Float)
                       {
  -                        rec.setValue( colMap.getColumnName(),
  -                                      criteria.getFloat(key) );
  +                        rec.setValue(colMap.getColumnName(),
  +                                criteria.getFloat(key));
                       }
  -                    else if ( obj instanceof Double)
  +                    else if (obj instanceof Double)
                       {
  -                        rec.setValue( colMap.getColumnName(),
  -                                      criteria.getDouble(key) );
  +                        rec.setValue(colMap.getColumnName(),
  +                                criteria.getDouble(key));
                       }
  -                    else if ( obj instanceof Byte)
  +                    else if (obj instanceof Byte)
                       {
  -                        rec.setValue( colMap.getColumnName(),
  -                                      ((Byte) obj).byteValue() );
  +                        rec.setValue(colMap.getColumnName(),
  +                                ((Byte) obj).byteValue());
                       }
  -                    else if ( obj instanceof Long)
  +                    else if (obj instanceof Long)
                       {
  -                        rec.setValue( colMap.getColumnName(),
  -                                      criteria.getLong(key) );
  +                        rec.setValue(colMap.getColumnName(),
  +                                criteria.getLong(key));
                       }
  -                    else if ( obj instanceof Short)
  +                    else if (obj instanceof Short)
                       {
  -                        rec.setValue( colMap.getColumnName(),
  -                                      ((Short) obj).shortValue() );
  +                        rec.setValue(colMap.getColumnName(),
  +                                ((Short) obj).shortValue());
                       }
  -                    else if ( obj instanceof Hashtable )
  +                    else if (obj instanceof Hashtable )
                       {
  -                        rec.setValue( colMap.getColumnName(),
  -                                      hashtableToByteArray( (Hashtable)obj ) );
  +                        rec.setValue(colMap.getColumnName(),
  +                                hashtableToByteArray((Hashtable) obj));
                       }
  -                    else if ( obj instanceof byte[])
  +                    else if (obj instanceof byte[])
                       {
  -                        rec.setValue( colMap.getColumnName(),
  -                                      (byte[]) obj);
  +                        rec.setValue(colMap.getColumnName(), (byte[]) obj);
                       }
                   }
                   catch (Exception e)
  @@ -1050,12 +1041,12 @@
        * @param criteria A Criteria.
        * @exception TorqueException Trouble creating the query string.
        */
  -    public static String createQueryString( Criteria criteria )
  +    public static String createQueryString(Criteria criteria)
               throws TorqueException
       {
           Query query = new Query();
  -        DB db = Torque.getDB( criteria.getDbName() );
  -        DatabaseMap dbMap = Torque.getDatabaseMap( criteria.getDbName() );
  +        DB db = Torque.getDB(criteria.getDbName());
  +        DatabaseMap dbMap = Torque.getDatabaseMap(criteria.getDbName());
   
           StringStack selectModifiers = query.getSelectModifiers();
           StringStack selectClause = query.getSelectClause();
  @@ -1073,7 +1064,7 @@
   
           for (int i = 0; i < modifiers.size(); i++)
           {
  -            selectModifiers.add( modifiers.get(i) );
  +            selectModifiers.add(modifiers.get(i));
           }
   
           for (int i = 0; i < select.size(); i++)
  @@ -1097,19 +1088,19 @@
                   // functions may contain qualifiers so only take the last
                   // word as the table name.
                   int lastSpace = tableName.lastIndexOf(' ');
  -                if ( lastSpace != -1 )
  +                if (lastSpace != -1 )
                   {
                       tableName = tableName.substring(lastSpace + 1);
                   }
               }
               String tableName2 = criteria.getTableForAlias(tableName);
  -            if ( tableName2 != null )
  +            if (tableName2 != null)
               {
                   fromClause.add(
                       new StringBuffer(tableName.length() +
                                        tableName2.length() + 1)
                       .append(tableName2).append(' ').append(tableName)
  -                    .toString() );
  +                    .toString());
               }
               else
               {
  @@ -1151,7 +1142,7 @@
                       table = tableName;
                   }
   
  -                boolean ignorCase = ( (criteria.isIgnoreCase() ||
  +                boolean ignorCase = ((criteria.isIgnoreCase() ||
                                          someCriteria[i].isIgnoreCase()) &&
                       (dbMap.getTable(table).getColumn(
                       someCriteria[i].getColumn()).getType() instanceof String));
  @@ -1160,14 +1151,14 @@
               }
   
               criterion.setDB(db);
  -            whereClause.add( criterion.toString() );
  +            whereClause.add(criterion.toString());
   
           }
   
           List join = criteria.getJoinL();
  -        if ( join != null)
  +        if (join != null)
           {
  -            for ( int i = 0; i < join.size(); i++ )
  +            for (int i = 0; i < join.size(); i++)
               {
                   String join1 = (String) join.get(i);
                   String join2 = (String) criteria.getJoinR().get(i);
  @@ -1182,13 +1173,13 @@
   
                   String tableName = join1.substring(0, join1.indexOf('.'));
                   String table = criteria.getTableForAlias(tableName);
  -                if ( table != null )
  +                if (table != null)
                   {
                       fromClause.add(
                           new StringBuffer(tableName.length() +
                                            table.length() + 1)
                           .append(table).append(' ').append(tableName)
  -                        .toString() );
  +                        .toString());
                   }
                   else
                   {
  @@ -1198,7 +1189,7 @@
                   int dot =  join2.indexOf('.');
                   tableName = join2.substring(0, dot);
                   table = criteria.getTableForAlias(tableName);
  -                if ( table != null )
  +                if (table != null)
                   {
                       fromClause.add(
                           new StringBuffer(tableName.length() +
  @@ -1214,24 +1205,23 @@
   
                   boolean ignorCase = (criteria.isIgnoreCase() &&
                       (dbMap.getTable(table).getColumn(
  -                        join2.substring(dot + 1, join2.length()) )
  +                        join2.substring(dot + 1, join2.length()))
                       .getType() instanceof String));
   
                   whereClause.add(
  -                    SqlExpression.buildInnerJoin(join1, join2,
  -                                                 ignorCase, db) );
  +                    SqlExpression.buildInnerJoin(join1, join2, ignorCase, db));
               }
           }
   
           // need to allow for multiple group bys
           if ( groupBy != null && groupBy.size() > 0)
           {
  -            for (int i=0; i<groupBy.size(); i++)
  +            for (int i = 0; i < groupBy.size(); i++)
               {
                   String groupByColumn = groupBy.get(i);
                   if (groupByColumn.indexOf('.') == -1)
                   {
  -                    throwMalformedColumnNameException("group by",groupByColumn);
  +                    throwMalformedColumnNameException("group by", groupByColumn);
                   }
   
                   groupByClause.add(groupByColumn);
  @@ -1255,9 +1245,10 @@
                   if (orderByColumn.indexOf('.') == -1)
                   {
                       throwMalformedColumnNameException("order by",
  -                                                      orderByColumn);
  +                            orderByColumn);
                   }
  -                String table = orderByColumn.substring(0,orderByColumn.indexOf('.') 
);
  +                String table = orderByColumn.substring(0,
  +                        orderByColumn.indexOf('.') );
                   // See if there's a space (between the column list and sort
                   // order in ORDER BY table.column DESC).
                   int spacePos = orderByColumn.indexOf(' ');
  @@ -1299,7 +1290,7 @@
           int limit = criteria.getLimit();
           int offset = criteria.getOffset();
           String limitString = null;
  -        if ( offset > 0 && db.supportsNativeOffset() )
  +        if (offset > 0 && db.supportsNativeOffset())
           {
               switch(db.getLimitStyle())
               {
  @@ -1323,7 +1314,7 @@
               criteria.setLimit(-1);
               criteria.setOffset(0);
           }
  -        else if (limit > 0 && db.supportsNativeLimit() )
  +        else if (limit > 0 && db.supportsNativeLimit())
           {
               limitString = String.valueOf(limit);
   
  @@ -1366,10 +1357,10 @@
               Connection con = beginTransaction(criteria.getDbName());
               try
               {
  -                results = executeQuery( createQueryString(criteria),
  -                                        criteria.getOffset(),
  -                                        criteria.getLimit(),
  -                                        criteria.isSingleRecord(), con );
  +                results = executeQuery(createQueryString(criteria),
  +                                       criteria.getOffset(),
  +                                       criteria.getLimit(),
  +                                       criteria.isSingleRecord(), con );
                   commitTransaction(con);
               }
               catch (Exception e)
  @@ -1381,11 +1372,11 @@
           }
           else
           {
  -            results = executeQuery( createQueryString(criteria),
  -                                    criteria.getOffset(),
  -                                    criteria.getLimit(),
  -                                    criteria.getDbName(),
  -                                    criteria.isSingleRecord() );
  +            results = executeQuery(createQueryString(criteria),
  +                                   criteria.getOffset(),
  +                                   criteria.getLimit(),
  +                                   criteria.getDbName(),
  +                                   criteria.isSingleRecord() );
           }
           return results;
       }
  @@ -1401,8 +1392,8 @@
       public static List doSelect(Criteria criteria, Connection con)
               throws TorqueException
       {
  -        return executeQuery( createQueryString(criteria),
  -                             criteria.isSingleRecord(), con );
  +        return executeQuery(createQueryString(criteria),
  +                            criteria.isSingleRecord(), con);
       }
   
       /**
  @@ -1430,8 +1421,7 @@
        * @return List of Record objects.
        * @exception TorqueException
        */
  -    public static List executeQuery(String queryString,
  -                                      String dbName)
  +    public static List executeQuery(String queryString, String dbName)
               throws TorqueException
       {
           return executeQuery(queryString, dbName, false);
  @@ -1448,8 +1438,8 @@
        * @exception TorqueException
        */
       public static List executeQuery(String queryString,
  -                                      String dbName,
  -                                      boolean singleRecord)
  +                                    String dbName,
  +                                    boolean singleRecord)
               throws TorqueException
       {
           return executeQuery(queryString, 0, -1, dbName, singleRecord);
  @@ -1466,8 +1456,8 @@
        * @exception TorqueException
        */
       public static List executeQuery(String queryString,
  -                                      boolean singleRecord,
  -                                      Connection con)
  +                                    boolean singleRecord,
  +                                    Connection con)
           throws TorqueException
       {
           return executeQuery(queryString, 0, -1, singleRecord, con);
  @@ -1487,10 +1477,10 @@
        * @exception TorqueException
        */
       public static List executeQuery(String queryString,
  -                                      int start,
  -                                      int numberOfResults,
  -                                      String dbName,
  -                                      boolean singleRecord)
  +                                    int start,
  +                                    int numberOfResults,
  +                                    String dbName,
  +                                    boolean singleRecord)
               throws TorqueException
       {
           Connection db = null;
  @@ -1522,10 +1512,10 @@
        * @exception TorqueException
        */
       public static List executeQuery(String queryString,
  -                                      int start,
  -                                      int numberOfResults,
  -                                      boolean singleRecord,
  -                                      Connection con)
  +                                    int start,
  +                                    int numberOfResults,
  +                                    boolean singleRecord,
  +                                    Connection con)
           throws TorqueException
       {
           QueryDataSet qds = null;
  @@ -1568,7 +1558,7 @@
        * @return List of Record objects.
        * @exception TorqueException
        */
  -    public static List getSelectResults( QueryDataSet qds )
  +    public static List getSelectResults(QueryDataSet qds)
               throws TorqueException
       {
           return getSelectResults( qds, 0, -1, false);
  @@ -1600,9 +1590,9 @@
        * single record.
        * @exception TorqueException
        */
  -    public static List getSelectResults( QueryDataSet qds,
  -                                           int numberOfResults,
  -                                           boolean singleRecord )
  +    public static List getSelectResults(QueryDataSet qds,
  +                                        int numberOfResults,
  +                                        boolean singleRecord)
               throws TorqueException
       {
           List results = null;
  @@ -1625,16 +1615,16 @@
        * single record.
        * @exception TorqueException
        */
  -    public static List getSelectResults( QueryDataSet qds,
  -                                           int start,
  -                                           int numberOfResults,
  -                                           boolean singleRecord )
  +    public static List getSelectResults(QueryDataSet qds,
  +                                        int start,
  +                                        int numberOfResults,
  +                                        boolean singleRecord)
               throws TorqueException
       {
           List results;
           try
           {
  -            if ( numberOfResults <= 0 )
  +            if (numberOfResults <= 0)
               {
                   results = new ArrayList();
                   qds.fetchRecords();
  @@ -1644,13 +1634,13 @@
                   results = new ArrayList(numberOfResults);
                   qds.fetchRecords(start, numberOfResults);
               }
  -            if ( qds.size() > 1 && singleRecord )
  +            if (qds.size() > 1 && singleRecord)
               {
                   handleMultipleRecords(qds);
               }
   
               // Return a List of Record objects.
  -            for ( int i = 0; i < qds.size(); i++ )
  +            for (int i = 0; i < qds.size(); i++)
               {
                   Record rec = qds.getRecord(i);
                   results.add(rec);
  @@ -1681,7 +1671,7 @@
           String table = criteria.getTableName(key);
           ColumnMap pk = null;
   
  -        if ( !table.equals("") )
  +        if (!table.equals(""))
           {
               DatabaseMap dbMap = Torque.getDatabaseMap(criteria.getDbName());
               if (dbMap == null)
  @@ -1697,7 +1687,7 @@
   
               for (int i = 0; i < columns.length; i++)
               {
  -                if ( columns[i].isPrimaryKey() )
  +                if (columns[i].isPrimaryKey())
                   {
                       pk = columns[i];
                       break;
  @@ -1780,19 +1770,18 @@
           ColumnMap pk = getPrimaryKey(updateValues);
           Criteria selectCriteria = null;
   
  -        if ( pk != null &&
  -             updateValues.containsKey(pk.getFullyQualifiedName()) )
  +        if (pk != null && updateValues.containsKey(pk.getFullyQualifiedName()))
           {
               selectCriteria = new Criteria(2);
               selectCriteria.put(pk.getFullyQualifiedName(),
  -                    updateValues.remove(pk.getFullyQualifiedName()) );
  +                    updateValues.remove(pk.getFullyQualifiedName()));
           }
           else
           {
               throw new TorqueException("No PK specified for database update");
           }
   
  -        doUpdate( selectCriteria, updateValues, con );
  +        doUpdate(selectCriteria, updateValues, con);
       }
   
       /**
  @@ -1872,7 +1861,7 @@
           Iterator it = selectCriteria.keySet().iterator();
           while (it.hasNext())
           {
  -            tables.add(selectCriteria.getTableName((String) it.next()) );
  +            tables.add(selectCriteria.getTableName((String) it.next()));
           }
   
           for (int i = 0; i < tables.size(); i++)
  @@ -1886,26 +1875,26 @@
               for (int j = 0; j < columnMaps.length; j++)
               {
                   ColumnMap colMap = columnMaps[j];
  -                if ( colMap.isPrimaryKey() )
  +                if (colMap.isPrimaryKey())
                   {
                       kd.addAttrib( colMap.getColumnName() );
                   }
                   String key = new StringBuffer(colMap.getTableName())
                           .append('.').append(colMap.getColumnName()).toString();
  -                if ( selectCriteria.containsKey(key) )
  +                if (selectCriteria.containsKey(key))
                   {
  -                    if ( selectCriteria.getComparison(key).equals(Criteria.CUSTOM) )
  +                    if (selectCriteria.getComparison(key).equals(Criteria.CUSTOM))
                       {
  -                        whereClause.add( selectCriteria.getString( key ));
  +                        whereClause.add(selectCriteria.getString(key));
                       }
                       else
                       {
  -                        whereClause.add( SqlExpression.build(
  +                        whereClause.add(SqlExpression.build(
                                   colMap.getColumnName(),
  -                                selectCriteria.getValue( key ),
  -                                selectCriteria.getComparison( key ),
  +                                selectCriteria.getValue(key),
  +                                selectCriteria.getComparison(key),
                                   selectCriteria.isIgnoreCase(),
  -                                db ));
  +                                db));
                       }
                   }
               }
  @@ -1919,7 +1908,7 @@
                   tds.where(sqlSnippet);
                   tds.fetchRecords();
   
  -                if ( tds.size() > 1 && selectCriteria.isSingleRecord() )
  +                if (tds.size() > 1 && selectCriteria.isSingleRecord())
                   {
                       handleMultipleRecords(tds);
                   }
  @@ -1984,7 +1973,7 @@
           try
           {
               db = Torque.getConnection(dbName);
  -            rowCount = executeStatement( stmt, db );
  +            rowCount = executeStatement(stmt, db);
           }
           finally
           {
  @@ -2011,7 +2000,7 @@
           try
           {
               statement = con.createStatement();
  -            rowCount = statement.executeUpdate( stmt );
  +            rowCount = statement.executeUpdate(stmt);
           }
           catch (SQLException e)
           {
  @@ -2116,7 +2105,7 @@
                     {
                        mb.doBuild();
                     }
  -                  catch ( Exception e )
  +                  catch (Exception e)
                     {
                         // need to think about whether we'd want to remove
                         //  the MapBuilder from the cache if it can't be
  @@ -2177,7 +2166,7 @@
                   }
                   else if (param instanceof NumberKey)
                   {
  -                    stmt.setBigDecimal(i+1, ((NumberKey)param).getBigDecimal());
  +                    stmt.setBigDecimal(i + 1, ((NumberKey) param).getBigDecimal());
                   }
                   else
                   {
  @@ -2188,7 +2177,7 @@
               QueryDataSet qds = null;
               try
               {
  -                qds = new QueryDataSet( stmt.executeQuery() );
  +                qds = new QueryDataSet(stmt.executeQuery());
                   v = getSelectResults(qds);
               }
               finally
  @@ -2231,7 +2220,7 @@
   
           try
           {
  -            v = doPSSelect (criteria,con);
  +            v = doPSSelect(criteria,con);
           }
           finally
           {
  @@ -2250,8 +2239,8 @@
                                                  List params)
           throws TorqueException
       {
  -        DB db = Torque.getDB( criteria.getDbName() );
  -        DatabaseMap dbMap = Torque.getDatabaseMap( criteria.getDbName() );
  +        DB db = Torque.getDB(criteria.getDbName());
  +        DatabaseMap dbMap = Torque.getDatabaseMap(criteria.getDbName());
   
           Query query = new Query();
   
  @@ -2293,13 +2282,13 @@
                   // functions may contain qualifiers so only take the last
                   // word as the table name.
                   int lastSpace = tableName.lastIndexOf(' ');
  -                if ( lastSpace != -1 )
  +                if (lastSpace != -1)
                   {
                       tableName = tableName.substring(lastSpace + 1);
                   }
               }
               String tableName2 = criteria.getTableForAlias(tableName);
  -            if ( tableName2 != null )
  +            if (tableName2 != null)
               {
                   fromClause.add(
                       new StringBuffer(tableName.length() +
  @@ -2334,12 +2323,12 @@
               {
                   String tableName = someCriteria[i].getTable();
                   table = criteria.getTableForAlias(tableName);
  -                if ( table != null )
  +                if (table != null)
                   {
                       fromClause.add(new StringBuffer(tableName.length()
                               + table.length() + 1)
                               .append(table).append(' ').append(tableName)
  -                            .toString() );
  +                            .toString());
                   }
                   else
                   {
  @@ -2359,14 +2348,14 @@
               criterion.setDB(db);
               StringBuffer sb = new StringBuffer();
               criterion.appendPsTo(sb,params);
  -            whereClause.add( sb.toString() );
  +            whereClause.add(sb.toString());
   
           }
   
           List join = criteria.getJoinL();
  -        if ( join != null)
  +        if (join != null)
           {
  -            for ( int i = 0; i < join.size(); i++ )
  +            for (int i = 0; i < join.size(); i++)
               {
                   String join1 = (String)join.get(i);
                   String join2 = (String)criteria.getJoinR().get(i);
  @@ -2396,7 +2385,7 @@
                   int dot = join2.indexOf('.');
                   tableName = join2.substring(0, dot);
                   table = criteria.getTableForAlias(tableName);
  -                if ( table != null )
  +                if (table != null)
                   {
                       fromClause.add(new StringBuffer(tableName.length()
                               + table.length() + 1)
  @@ -2411,7 +2400,7 @@
   
                   boolean ignorCase = (criteria.isIgnoreCase()
                           && (dbMap.getTable(table).getColumn(
  -                        join2.substring(dot + 1, join2.length()) )
  +                        join2.substring(dot + 1, join2.length()))
                           .getType() instanceof String));
   
                   whereClause.add(SqlExpression.buildInnerJoin(
  @@ -2459,7 +2448,7 @@
                       {
                           orderByClause.add(db.ignoreCaseInOrderBy(
                                   orderByColumn.substring(0, spacePos))
  -                                + orderByColumn.substring(spacePos) );
  +                                + orderByColumn.substring(spacePos));
                       }
                       selectClause.add( db.ignoreCaseInOrderBy(table + '.'
                               + columnName) );
  @@ -2475,7 +2464,7 @@
           int limit = criteria.getLimit();
           int offset = criteria.getOffset();
           String limitString = null;
  -        if ( offset > 0 && db.supportsNativeOffset() )
  +        if (offset > 0 && db.supportsNativeOffset())
           {
               switch(db.getLimitStyle())
               {
  @@ -2499,7 +2488,7 @@
               criteria.setLimit(-1);
               criteria.setOffset(0);
           }
  -        else if (limit > 0 && db.supportsNativeLimit() )
  +        else if (limit > 0 && db.supportsNativeLimit())
           {
               limitString = String.valueOf(limit);
   
  
  
  
  1.31      +10 -10    
jakarta-turbine-torque/src/java/org/apache/torque/util/Criteria.java
  
  Index: Criteria.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/util/Criteria.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- Criteria.java     23 Jun 2002 02:13:08 -0000      1.30
  +++ Criteria.java     12 Jul 2002 21:40:12 -0000      1.31
  @@ -238,7 +238,7 @@
        * can be reused as if it was new. Except if the criteria has grown in
        * capacity, it is left at the current capacity.
        */
  -    public void clear() 
  +    public void clear()
       {
           super.clear();
           ignoreCase = false;
  @@ -251,7 +251,7 @@
           having = null;
           asColumns.clear();
           joinL = null;
  -        joinR = null;       
  +        joinR = null;
           dbName = originalDbName;
           offset = 0;
           limit = -1;
  @@ -1763,12 +1763,12 @@
       /**
        * Add group by column name.
        *
  -     * @param name The name of the column to group by.
  +     * @param groupBy The name of the column to group by.
        * @return A modified Criteria object.
        */
  -    public Criteria addGroupByColumn( String groupBy )
  +    public Criteria addGroupByColumn(String groupBy)
       {
  -        groupByColumns.add( groupBy );
  +        groupByColumns.add(groupBy);
           return this;
       }
   
  @@ -1883,7 +1883,7 @@
           {
               isEquiv = true;
           }
  -        else if (this.size() == ((Criteria)crit).size())
  +        else if (this.size() == ((Criteria) crit).size())
           {
               Criteria criteria = (Criteria)crit;
               if (this.offset == criteria.getOffset()
  @@ -1898,9 +1898,9 @@
                  )
               {
                   isEquiv = true;
  -                for (Iterator it=criteria.keySet().iterator(); it.hasNext();)
  +                for (Iterator it = criteria.keySet().iterator(); it.hasNext(); )
                   {
  -                    String key = (String)it.next();
  +                    String key = (String) it.next();
                       if (this.containsKey(key))
                       {
                           Criterion a = this.getCriterion(key);
  @@ -1946,7 +1946,7 @@
        *
        * @return A modified Criteria object.
        */
  -    public Criteria addHaving( Criterion having )
  +    public Criteria addHaving(Criterion having)
       {
           this.having = having;
           return this;
  
  
  
  1.10      +45 -47    
jakarta-turbine-torque/src/java/org/apache/torque/manager/MethodResultCache.java
  
  Index: MethodResultCache.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/manager/MethodResultCache.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- MethodResultCache.java    4 Jun 2002 21:31:23 -0000       1.9
  +++ MethodResultCache.java    12 Jul 2002 21:40:13 -0000      1.10
  @@ -56,8 +56,6 @@
   
   import java.util.Map;
   import java.util.HashMap;
  -import java.util.WeakHashMap;
  -import java.util.Iterator;
   import java.io.Serializable;
   import org.apache.log4j.Category;
   import org.apache.jcs.access.GroupCacheAccess;
  @@ -73,9 +71,9 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>John McNally</a>
    * @version $Id$
    */
  -public class MethodResultCache 
  +public class MethodResultCache
   {
  -    private static final Category log = 
  +    private static final Category log =
           Category.getInstance("org.apache.torque");
   
       private static final String keyClassName =
  @@ -89,8 +87,8 @@
       public MethodResultCache(GroupCacheAccess cache)
           throws TorqueException
       {
  -        // keys = new WeakHashMap();            
  -        this.jcsCache = cache;            
  +        // keys = new WeakHashMap();
  +        this.jcsCache = cache;
           groups = new HashMap();
           pool = new StackObjectPool(new MethodCacheKey.Factory(), 10000);
       }
  @@ -132,11 +130,11 @@
               }
           }
   
  -        if (result != null) 
  +        if (result != null)
           {
               log.debug("MethodResultCache saved expensive operation: " + key);
           }
  -        
  +
           return result;
       }
   
  @@ -146,11 +144,11 @@
       {
           //register the group, if this is the first occurrence
           String group = key.getGroupKey();
  -        if (!groups.containsKey(group)) 
  +        if (!groups.containsKey(group))
           {
               synchronized (jcsCache)
               {
  -                if (!groups.containsKey(group)) 
  +                if (!groups.containsKey(group))
                   {
                       try
                       {
  @@ -161,7 +159,7 @@
                           throw new TorqueException(ce);
                       }
                       groups.put(group, null);
  -                }                
  +                }
               }
           }
   
  @@ -174,10 +172,10 @@
                   try
                   {
                       old = jcsCache.getFromGroup(key, group);
  -                    while (inGet > 0) 
  +                    while (inGet > 0)
                       {
                           Thread.yield();
  -                    }                    
  +                    }
                       jcsCache.putInGroup(key, group, value);
                   }
                   catch (CacheException ce)
  @@ -207,14 +205,14 @@
                   try
                   {
                       old = jcsCache.getFromGroup(key, key.getGroupKey());
  -                    while (inGet > 0) 
  +                    while (inGet > 0)
                       {
                           Thread.yield();
                       }
                       jcsCache.remove(key, key.getGroupKey());
                   }
                   // jcs does not throw an exception here, might remove this
  -                catch (Exception ce) 
  +                catch (Exception ce)
                   {
                       lockCache = false;
                       throw new TorqueException(
  @@ -233,11 +231,11 @@
       public Object get(Serializable instanceOrClass, String method)
       {
           Object result = null;
  -        if (jcsCache != null) 
  +        if (jcsCache != null)
           {
               try
               {
  -                MethodCacheKey key = 
  +                MethodCacheKey key =
                       (MethodCacheKey)pool.borrowObject();
                   key.init(instanceOrClass, method);
                   result = getImpl(key);
  @@ -254,7 +252,7 @@
               catch (Exception e)
               {
                   log.error("", e);
  -            }            
  +            }
           }
           return result;
       }
  @@ -263,11 +261,11 @@
                         Serializable arg1)
       {
           Object result = null;
  -        if (jcsCache != null) 
  +        if (jcsCache != null)
           {
               try
               {
  -                MethodCacheKey key = 
  +                MethodCacheKey key =
                       (MethodCacheKey)pool.borrowObject();
                   key.init(instanceOrClass, method, arg1);
                   result = getImpl(key);
  @@ -293,11 +291,11 @@
                         Serializable arg1, Serializable arg2)
       {
           Object result = null;
  -        if (jcsCache != null) 
  +        if (jcsCache != null)
           {
               try
               {
  -                MethodCacheKey key = 
  +                MethodCacheKey key =
                       (MethodCacheKey)pool.borrowObject();
                   key.init(instanceOrClass, method, arg1, arg2);
                   result = getImpl(key);
  @@ -324,11 +322,11 @@
                         Serializable arg3)
       {
           Object result = null;
  -        if (jcsCache != null) 
  +        if (jcsCache != null)
           {
               try
               {
  -                MethodCacheKey key = 
  +                MethodCacheKey key =
                       (MethodCacheKey)pool.borrowObject();
                   key.init(instanceOrClass, method, arg1, arg2, arg3);
                   result = getImpl(key);
  @@ -353,11 +351,11 @@
       public Object get(Serializable[] keys)
       {
           Object result = null;
  -        if (jcsCache != null) 
  +        if (jcsCache != null)
           {
               try
               {
  -                MethodCacheKey key = 
  +                MethodCacheKey key =
                       (MethodCacheKey)pool.borrowObject();
                   key.init(keys);
                   result = getImpl(key);
  @@ -383,7 +381,7 @@
       {
           try
           {
  -            MethodCacheKey key =  
  +            MethodCacheKey key =
                   (MethodCacheKey)pool.borrowObject();
               key.init(instanceOrClass, method);
               putImpl(key, value);
  @@ -394,12 +392,12 @@
           }
       }
   
  -    public void put(Object value, Serializable instanceOrClass, 
  +    public void put(Object value, Serializable instanceOrClass,
                       String method, Serializable arg1)
       {
           try
           {
  -            MethodCacheKey key =  
  +            MethodCacheKey key =
                   (MethodCacheKey)pool.borrowObject();
               key.init(instanceOrClass, method, arg1);
               putImpl(key, value);
  @@ -415,7 +413,7 @@
       {
           try
           {
  -            MethodCacheKey key =  
  +            MethodCacheKey key =
                   (MethodCacheKey)pool.borrowObject();
               key.init(instanceOrClass, method, arg1, arg2);
               putImpl(key, value);
  @@ -431,7 +429,7 @@
       {
           try
           {
  -            MethodCacheKey key =  
  +            MethodCacheKey key =
                   (MethodCacheKey)pool.borrowObject();
               key.init(instanceOrClass, method, arg1, arg2, arg3);
               putImpl(key, value);
  @@ -446,7 +444,7 @@
       {
           try
           {
  -            MethodCacheKey key =  
  +            MethodCacheKey key =
                   (MethodCacheKey)pool.borrowObject();
               key.init(keys);
               putImpl(key, value);
  @@ -460,11 +458,11 @@
   
       public void removeAll(Serializable instanceOrClass, String method)
       {
  -        if (jcsCache != null) 
  +        if (jcsCache != null)
           {
               try
               {
  -                MethodCacheKey key = 
  +                MethodCacheKey key =
                       (MethodCacheKey)pool.borrowObject();
                   key.init(instanceOrClass, method);
                   String groupName = key.getGroupKey();
  @@ -483,7 +481,7 @@
               catch (Exception e)
               {
                   log.error("", e);
  -            }            
  +            }
           }
       }
   
  @@ -491,11 +489,11 @@
       public Object remove(Serializable instanceOrClass, String method)
       {
           Object result = null;
  -        if (jcsCache != null) 
  +        if (jcsCache != null)
           {
               try
               {
  -                MethodCacheKey key = 
  +                MethodCacheKey key =
                       (MethodCacheKey)pool.borrowObject();
                   key.init(instanceOrClass, method);
                   result = removeImpl(key);
  @@ -512,7 +510,7 @@
               catch (Exception e)
               {
                   log.error("", e);
  -            }            
  +            }
           }
           return result;
       }
  @@ -521,11 +519,11 @@
                            Serializable arg1)
       {
           Object result = null;
  -        if (jcsCache != null) 
  +        if (jcsCache != null)
           {
               try
               {
  -                MethodCacheKey key = 
  +                MethodCacheKey key =
                       (MethodCacheKey)pool.borrowObject();
                   key.init(instanceOrClass, method, arg1);
                   result = removeImpl(key);
  @@ -551,11 +549,11 @@
                            Serializable arg1, Serializable arg2)
       {
           Object result = null;
  -        if (jcsCache != null) 
  +        if (jcsCache != null)
           {
               try
               {
  -                MethodCacheKey key = 
  +                MethodCacheKey key =
                       (MethodCacheKey)pool.borrowObject();
                   key.init(instanceOrClass, method, arg1, arg2);
                   result = removeImpl(key);
  @@ -582,11 +580,11 @@
                            Serializable arg3)
       {
           Object result = null;
  -        if (jcsCache != null) 
  +        if (jcsCache != null)
           {
               try
               {
  -                MethodCacheKey key = 
  +                MethodCacheKey key =
                       (MethodCacheKey)pool.borrowObject();
                   key.init(instanceOrClass, method, arg1, arg2, arg3);
                   result = removeImpl(key);
  @@ -611,11 +609,11 @@
       public Object remove(Serializable[] keys)
       {
           Object result = null;
  -        if (jcsCache != null) 
  +        if (jcsCache != null)
           {
               try
               {
  -                MethodCacheKey key = 
  +                MethodCacheKey key =
                       (MethodCacheKey)pool.borrowObject();
                   key.init(keys);
                   result = removeImpl(key);
  
  
  

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

Reply via email to