commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bali...@apache.org
Subject cvs commit: jakarta-commons-sandbox/dbutils/src/test/org/apache/commons/dbutils Demo.java ProcedureUtilsTest.java
Date Wed, 19 Mar 2003 09:21:39 GMT
baliuka     2003/03/19 01:21:39

  Modified:    dbutils/src/java/org/apache/commons/dbutils DbUtils.java
                        ProcedureUtils.java
               dbutils/src/test/org/apache/commons/dbutils Demo.java
                        ProcedureUtilsTest.java
  Log:
  fixed index mapping for bean collection and dependancy on jdk 1.4 BitSet
  
  Revision  Changes    Path
  1.22      +4 -4      jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/DbUtils.java
  
  Index: DbUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/DbUtils.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- DbUtils.java	16 Mar 2003 16:23:47 -0000	1.21
  +++ DbUtils.java	19 Mar 2003 09:21:39 -0000	1.22
  @@ -381,9 +381,9 @@
                   
                   LOOP:
                       for( int i = 1; i <= cnt; i++ ){
  +                       String name = rsmd.getColumnName(i);
                           for( int j = 0; j < pd.length; j++ ){
  -                            String name = rsmd.getColumnName(i);
  -                            if(name.equals(pd[i].getName())){
  +                            if(name.equals(pd[j].getName())){
                                   nameToIndex[i] = j;
                                   continue LOOP;
                               }
  @@ -401,7 +401,7 @@
                               throw new DbException( "can not create " + cls.getName() ,
e);
                           }
                           
  -                        for(int i = 1; i < cnt; i++){
  +                        for(int i = 1; i <= cnt; i++){
                               Object value = rs.getObject(i);
                               int index = nameToIndex[i];
                               if( rs.wasNull() && pd[index].getPropertyType().isPrimitive()
){
  @@ -409,7 +409,7 @@
                               }
                               try{
                                   
  -                                pd[i].getWriteMethod().invoke(obj, new Object[]{ value
});
  +                                pd[index].getWriteMethod().invoke(obj, new Object[]{ value
});
                                   
                                   
                               }catch(Exception e){
  
  
  
  1.13      +13 -5     jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/ProcedureUtils.java
  
  Index: ProcedureUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/ProcedureUtils.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ProcedureUtils.java	16 Mar 2003 16:23:47 -0000	1.12
  +++ ProcedureUtils.java	19 Mar 2003 09:21:39 -0000	1.13
  @@ -123,7 +123,8 @@
               if(sql[i] == '$'){
                   if( state.get(ESCAPE) ){
                       sb.append('$');
  -                    state.clear();
  +                    state.clear(ESCAPE);
  +                    state.clear(ARG);
                       continue;
                   }
                   if(state.get(ARG)){
  @@ -131,7 +132,7 @@
                       sb.append('?');
                       digit.delete(0, digit.length() );
                   }
  -                state.clear();
  +                state.clear(ARG);
                   state.set(ESCAPE);
                   continue ;
               }
  @@ -139,7 +140,7 @@
               if ( Character.isDigit(sql[i]) &&
               (state.get(ESCAPE) || state.get(ARG))   ){
                   digit.append(sql[i]);
  -                state.clear();
  +                state.clear(ESCAPE);
                   state.set(ARG);
                   if( i != sql.length - 1 ){
                       continue;
  @@ -156,7 +157,9 @@
               if( i < sql.length ){
                   sb.append(sql[i]);
               }
  -            state.clear();
  +            state.clear(ESCAPE);
  +            state.clear(ARG);
  +                    
           }
           
           return indexes;
  @@ -512,6 +515,7 @@
               this.method = method;
               this.args   = args;
               hash = method.hashCode();
  +            if(args != null)
               for(int i=0; i< args.length; i++){
                   hash += 3*(args[i] == null ? 0 : args[i].hashCode());
               }
  @@ -526,6 +530,10 @@
                   
                   CacheKey key = (CacheKey)obj;
                   if(key.method == method || key.method.equals(method)){
  +                    
  +                    if(args == null ){
  +                      return key.args == null || key.args.length == 0;
  +                    }
                       
                       for( int i = 0; i < args.length; i++ ){
                           if( args[i] == key.args[i] ){
  
  
  
  1.11      +5 -9      jakarta-commons-sandbox/dbutils/src/test/org/apache/commons/dbutils/Demo.java
  
  Index: Demo.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/dbutils/src/test/org/apache/commons/dbutils/Demo.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- Demo.java	16 Mar 2003 16:23:48 -0000	1.10
  +++ Demo.java	19 Mar 2003 09:21:39 -0000	1.11
  @@ -42,18 +42,14 @@
        */
       public Integer maxId(String table);
       
  -    /**
  -     *@query SELECT now() 
  -     */
  -    public java.util.Date now();
       
       /**
  -     *@query SELECT * FROM TBL  WHERE ID=$0 
  +     *@query SELECT id, name FROM TBL  WHERE ID=$0 
        */
       public Object[] getRow( int id );
       
        /**
  -     *@query SELECT * FROM TBL WHERE ID=$0 
  +     *@query SELECT id, name FROM TBL WHERE ID=$0 
        */
        public Map getRowAsMap( int id );
      
  @@ -76,7 +72,7 @@
        public java.util.Collection getBeans();
      
       /**
  -     *@query SELECT * FROM {0}  
  +     *@query SELECT id, name FROM {0}  
        */
        public java.util.Collection getAll( String tbl );
       
  @@ -88,13 +84,13 @@
       
       
       /**
  -     *@query SELECT * FROM TBL 
  +     *@query SELECT id, name FROM TBL 
        *@handler DemoHandler
        */
       public int print(java.io.PrintStream out) throws java.io.IOException;
       
       /**
  -     *@query SELECT * FROM {1} WHERE {2} > $3
  +     *@query SELECT id, name FROM {1} WHERE {2} > $3
        *@handler DemoHandler
        */
       public int dynamicPrint(java.io.PrintStream out,
  
  
  
  1.10      +2 -1      jakarta-commons-sandbox/dbutils/src/test/org/apache/commons/dbutils/ProcedureUtilsTest.java
  
  Index: ProcedureUtilsTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/dbutils/src/test/org/apache/commons/dbutils/ProcedureUtilsTest.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ProcedureUtilsTest.java	16 Mar 2003 16:23:48 -0000	1.9
  +++ ProcedureUtilsTest.java	19 Mar 2003 09:21:39 -0000	1.10
  @@ -9,6 +9,7 @@
   import com.thoughtworks.qdox.model.*;
   import junit.framework.*;
   
  +
   /**
    *
    * @author baliuka
  @@ -123,7 +124,7 @@
          
          assertTrue( max != null  );
          assertTrue("cached query", max == demo.maxId("TBL")  );
  -       assertTrue( demo.now()  != null  );
  +       
          assertEquals(demo.concat("A","B"), "AB" );
          assertTrue(demo.getRow(max.intValue()).length == 2 );
          assertTrue(demo.getRowAsMap(max.intValue()).size() == 2 );
  
  
  

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


Mime
View raw message