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/simplestore/src/java/org/apache/commons/simplestore/tools Enhancer.java
Date Tue, 19 Mar 2002 15:03:57 GMT
baliuka     02/03/19 07:03:57

  Modified:    simplestore/src/java/org/apache/commons/simplestore/persistence
                        StorageException.java
               simplestore/src/java/org/apache/commons/simplestore/persistence/impl
                        MetaClassImpl.java PersistentProxy.java
               simplestore/src/java/org/apache/commons/simplestore/tools
                        Enhancer.java
  Log:
  Added default value hanling for primityves
  
  Revision  Changes    Path
  1.2       +2 -2      jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/StorageException.java
  
  Index: StorageException.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/StorageException.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StorageException.java	11 Feb 2002 20:23:30 -0000	1.1
  +++ StorageException.java	19 Mar 2002 15:03:57 -0000	1.2
  @@ -57,9 +57,9 @@
   /**
    *@author     Juozas Baliuka <a href="mailto:baliuka@mwm.lt">
    *      baliuka@mwm.lt</a>
  - *@version    $Id: StorageException.java,v 1.1 2002/02/11 20:23:30 froehlich Exp $
  + *@version    $Id: StorageException.java,v 1.2 2002/03/19 15:03:57 baliuka Exp $
    */
  -public class StorageException extends Exception {
  +public class StorageException extends RuntimeException {
   
       public Throwable detail;
   
  
  
  
  1.14      +12 -19    jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/impl/MetaClassImpl.java
  
  Index: MetaClassImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/impl/MetaClassImpl.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- MetaClassImpl.java	17 Mar 2002 13:36:25 -0000	1.13
  +++ MetaClassImpl.java	19 Mar 2002 15:03:57 -0000	1.14
  @@ -65,7 +65,7 @@
    *
    *@author     Juozas Baliuka <a href="mailto:baliuka@mwm.lt">
    *     baliuka@mwm.lt</a>
  - *@version    $Id: MetaClassImpl.java,v 1.13 2002/03/17 13:36:25 baliuka Exp $
  + *@version    $Id: MetaClassImpl.java,v 1.14 2002/03/19 15:03:57 baliuka Exp $
    */
   public class MetaClassImpl implements MetaClass, org.apache.commons.simplestore.tools.Constants
 {
       
  @@ -317,33 +317,28 @@
       private void setDescriptors(){
           try{
               descriptors = java.beans.Introspector.getBeanInfo( clasz ).getPropertyDescriptors();
  -            /*
  +            
               java.util.List  abstractProps = new java.util.Vector();
                
               for( int i = 0; i < descriptors.length; i++ ){
                
  -                if( descriptors[i].getReadMethod() != null && descriptors[i].getWriteMethod()
!= null ) {
  -             
  -                    if( java.lang.reflect.Modifier.isAbstract( descriptors[i].getReadMethod().getModifiers()
) &&
  -                    java.lang.reflect.Modifier.isAbstract(  descriptors[i].getWriteMethod().getModifiers()
) ){
  -                         abstractProps.add(descriptors[i]);
  -                    }
  -                }else if ( descriptors[i].getReadMethod() != null &&
  -                java.lang.reflect.Modifier.isAbstract( descriptors[i].getReadMethod().getModifiers()
)){
  -             
  +                 if ( descriptors[i].getReadMethod() != null &&
  +                  java.lang.reflect.Modifier.isAbstract( descriptors[i].getReadMethod().getModifiers()
)){
                       abstractProps.add(descriptors[i]);
  +                    continue;
                
  -                }else if ( descriptors[i].getWriteMethod() != null &&
  +                }
  +                if ( descriptors[i].getWriteMethod() != null &&
                   java.lang.reflect.Modifier.isAbstract( descriptors[i].getWriteMethod().getModifiers()
)){
  -             
                       abstractProps.add(descriptors[i]);
  +                    continue;
                   }
                
               }
                
                
               descriptors =  (java.beans.PropertyDescriptor[])abstractProps.toArray(new java.beans.PropertyDescriptor[]{});
  -             */
  +            
           }catch( Exception e ){
               e.printStackTrace();
               throw new Error(e.getMessage());
  @@ -357,8 +352,6 @@
               
               for( int i = 0; i < descriptors.length; i++ ){
                   fieldArray[ i ] = getField(descriptors[i].getName());
  -                if(DEBUG)
  -                    System.out.println("Field " + i + " " + fieldArray[ i ]);
                   String name =  fieldArray[ i ].getName();
                   if( name == null && fieldArray[ i ].getReferenceClass() == null){
                       if( DEBUG ){
  @@ -568,9 +561,9 @@
                       currentClass.clasz = clasz;
                       persitentClasses.put(clasz.getName(),currentClass);
                       Class interfaces[] = clasz.getInterfaces();
  -                    for(int i = 0; i< interfaces.length; i++){
  -                     persitentClasses.put(interfaces[i].getName(),currentClass);
  -                    }
  +                 //   for(int i = 0; i< interfaces.length; i++){
  +                 //    persitentClasses.put(interfaces[i].getName(),currentClass);
  +                  //  }
                   }
                   currentClass.setDescriptors();
                   currentClass.sqlName = meta.getValue("name");
  
  
  
  1.20      +3 -4      jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/impl/PersistentProxy.java
  
  Index: PersistentProxy.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/impl/PersistentProxy.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- PersistentProxy.java	16 Mar 2002 20:56:25 -0000	1.19
  +++ PersistentProxy.java	19 Mar 2002 15:03:57 -0000	1.20
  @@ -61,7 +61,6 @@
   import org.apache.commons.simplestore.persistence.Validator;
   import org.apache.commons.simplestore.persistence.ValidationException;
   import org.apache.commons.simplestore.persistence.SimplestoreException;
  -import org.apache.commons.simplestore.persistence.TypeConverter;
   import org.apache.commons.simplestore.tools.*;
   
   
  @@ -78,7 +77,7 @@
    *      baliuka@mwm.lt</a>
    *@author     Gerhard Froehlich <a href="mailto:g-froehlich@gmx.de">
    *      g-froehlich@gmx.de</a>
  - *@version    $Id: PersistentProxy.java,v 1.19 2002/03/16 20:56:25 baliuka Exp $
  + *@version    $Id: PersistentProxy.java,v 1.20 2002/03/19 15:03:57 baliuka Exp $
    */
   public class PersistentProxy
   implements MetaObject,  org.apache.commons.simplestore.tools.Constants ,
  @@ -101,7 +100,7 @@
       private Object m_oid         = null;
       private int state = 0;
       
  -    private TypeConverter m_typeConverter = new DefaultTypeConverter();
  +   
       private Persistent m_object;
       private Class m_clazz;
       private MetaClass m_metaClass;
  @@ -352,7 +351,7 @@
               if( value == null ){
                   return null;
               }
  -            return m_typeConverter.convert( value , method.getReturnType() );
  +            return  value;
           }
           throw new java.lang.NoSuchMethodError("pure method invoked: " + method);
       }
  
  
  
  1.19      +39 -6     jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/tools/Enhancer.java
  
  Index: Enhancer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/tools/Enhancer.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- Enhancer.java	19 Mar 2002 13:50:17 -0000	1.18
  +++ Enhancer.java	19 Mar 2002 15:03:57 -0000	1.19
  @@ -57,6 +57,9 @@
   import org.apache.bcel.classfile.Method;
   import org.apache.bcel.generic.AASTORE;
   import org.apache.bcel.generic.ACONST_NULL;
  +import org.apache.bcel.generic.LCONST;
  +import org.apache.bcel.generic.FCONST;
  +import org.apache.bcel.generic.DCONST;
   import org.apache.bcel.generic.ALOAD;
   import org.apache.bcel.generic.ANEWARRAY;
   import org.apache.bcel.generic.ARETURN;
  @@ -95,12 +98,13 @@
   import org.apache.bcel.generic.PUTFIELD;
   import org.apache.bcel.generic.RETURN;
   import org.apache.bcel.generic.IFNULL;
  +import org.apache.bcel.generic.IFNONNULL;
   import org.apache.bcel.generic.Type;
   import org.apache.bcel.generic.ArrayType;
   /**
    *@author     Juozas Baliuka <a href="mailto:baliuka@mwm.lt">
    *      baliuka@mwm.lt</a>
  - *@version    $Id: Enhancer.java,v 1.18 2002/03/19 13:50:17 baliuka Exp $
  + *@version    $Id: Enhancer.java,v 1.19 2002/03/19 15:03:57 baliuka Exp $
    */
   public class Enhancer implements org.apache.bcel.Constants , Constants{
       
  @@ -506,6 +510,11 @@
           } 
           if (returnType instanceof BasicType) {
               if (returnType.equals(Type.BOOLEAN)) {
  +                IFNONNULL ifNNull = new IFNONNULL(null);
  +                il.append(ifNNull);
  +                il.append(new ICONST(0) );
  +                il.append(new IRETURN());  
  +                ifNNull.setTarget(il.append(new ALOAD(stack)));
                   il.append(new CHECKCAST(cp.addClass(BOOLEAN_OBJECT)));
                   il.append(
                       factory.createInvoke(
  @@ -516,6 +525,11 @@
                           INVOKEVIRTUAL));
                   return il.append(new IRETURN());
               } else if (returnType.equals(Type.CHAR)) {
  +               IFNONNULL ifNNull = new IFNONNULL(null);
  +                il.append(ifNNull);
  +                il.append(new ICONST(0) );
  +                il.append(new IRETURN());  
  +                ifNNull.setTarget(il.append(new ALOAD(stack)));
                   il.append(new CHECKCAST(cp.addClass(CHARACTER_OBJECT)));
                   il.append(
                       factory.createInvoke(
  @@ -526,6 +540,11 @@
                           INVOKEVIRTUAL));
                   return il.append(new IRETURN());
               } else if (returnType.equals(Type.LONG)) {
  +                IFNONNULL ifNNull = new IFNONNULL(null);
  +                il.append(ifNNull);
  +                il.append(new LCONST(0) );
  +                il.append(new LRETURN());  
  +                ifNNull.setTarget(il.append(new ALOAD(stack)));
                   il.append(new CHECKCAST(cp.addClass(NUMBER_OBJECT)));
                   il.append(
                       factory.createInvoke(
  @@ -536,6 +555,12 @@
                           INVOKEVIRTUAL));
                   return il.append(new LRETURN());
               } else if (returnType.equals(Type.DOUBLE)) {
  +                IFNONNULL ifNNull = new IFNONNULL(null);
  +                il.append(ifNNull);
  +                il.append(new DCONST(0) );
  +                il.append(new DRETURN());  
  +                ifNNull.setTarget(il.append(new ALOAD(stack)));
  +                         
                   il.append(new CHECKCAST(cp.addClass(NUMBER_OBJECT)));
                   il.append(
                       factory.createInvoke(
  @@ -546,6 +571,11 @@
                           INVOKEVIRTUAL));
                   return il.append(new DRETURN());
               } else if (returnType.equals(Type.FLOAT)) {
  +                IFNONNULL ifNNull = new IFNONNULL(null);
  +                il.append(ifNNull);
  +                il.append(new FCONST(0) );
  +                il.append(new FRETURN());  
  +                ifNNull.setTarget(il.append(new ALOAD(stack)));
                   il.append(new CHECKCAST(cp.addClass(NUMBER_OBJECT)));
                   il.append(
                       factory.createInvoke(
  @@ -556,6 +586,11 @@
                           INVOKEVIRTUAL));
                   return il.append(new FRETURN());
               } else {
  +                IFNONNULL ifNNull = new IFNONNULL(null);
  +                il.append(ifNNull);
  +                il.append(new ICONST(0) );
  +                il.append(new IRETURN());  
  +                ifNNull.setTarget(il.append(new ALOAD(stack)));
                   il.append(new CHECKCAST(cp.addClass(NUMBER_OBJECT)));
                   il.append(
                       factory.createInvoke(
  @@ -673,8 +708,7 @@
                   return Type.BOOLEAN;
               }
           } else if (cls.isArray()) {
  -            System.out.println(new ArrayType( toType(cls.getComponentType()),cls.getName().lastIndexOf('[')
+ 1));
  -            return new ArrayType( toType(cls.getComponentType()),cls.getName().lastIndexOf('[')
+ 1);
  +             return new ArrayType( toType(cls.getComponentType()),cls.getName().lastIndexOf('[')
+ 1);
           } else
               return new ObjectType(cls.getName());
           throw new java.lang.InternalError(cls.getName());
  @@ -847,7 +881,6 @@
           if (DEBUG) {
               System.err.println(mg.getMethod());
               System.err.println(mg.getMethod().getCode());
  -            System.err.flush();
           }
           return result;
       }
  @@ -887,14 +920,14 @@
                                 return false;
                       }
                   }
  -             /*  Some veryfier ? 
  +        
                 if(!m1.getReturnType().getName().
                      equals(m2.getReturnType().getName()) ){
                    throw new java.lang.IllegalStateException(
                     "Can't implement:\n" + m1.getDeclaringClass().getName() +
                      "\n      and\n" + m2.getDeclaringClass().getName() + "\n"+
                        m1.toString() + "\n" + m2.toString());
  -              }*/           
  +              }           
                   return true;
               }
           }
  
  
  

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


Mime
View raw message