tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mindbri...@apache.org
Subject cvs commit: jakarta-tapestry/framework/src/org/apache/tapestry/enhance ComponentClassFactory.java
Date Fri, 19 Dec 2003 17:55:43 GMT
mindbridge    2003/12/19 09:55:43

  Modified:    framework/src/org/apache/tapestry/enhance
                        ComponentClassFactory.java
  Log:
  changing implementation from recursive to iterative
  
  Revision  Changes    Path
  1.19      +24 -19    jakarta-tapestry/framework/src/org/apache/tapestry/enhance/ComponentClassFactory.java
  
  Index: ComponentClassFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/enhance/ComponentClassFactory.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- ComponentClassFactory.java	19 Dec 2003 08:55:41 -0000	1.18
  +++ ComponentClassFactory.java	19 Dec 2003 17:55:43 -0000	1.19
  @@ -235,7 +235,7 @@
           {
               try
               {
  -                String typeName = translateClassName(type, true);
  +                String typeName = translateClassName(type);
                   result = _resolver.findClass(typeName);
               }
               catch (Exception ex)
  @@ -252,27 +252,33 @@
           return result;
       }
   
  -    // this method and its static Map should go into a utility class somewhere  
  -    protected String translateClassName(String type, boolean toplevel)
  +    /**
  +     *  Translates types from standard Java format to Java VM format.
  +     *  For example, java.util.Locale remains java.util.Locale, but
  +     *  int[][] is translated to [[I and java.lang.Object[] to 
  +     *  [Ljava.lang.Object;   
  +     *  This method and its static Map should go into a utility class
  +     */   
  +    protected String translateClassName(String type)
       {
  -        // if it is an array name reformat it in the way Java expects it
  -        if (type.endsWith("[]")) {
  -            String subtype = type.substring(0, type.length() - 2);
  -            return "[" + translateClassName(subtype, false); 
  -        }
  -        
  -        // if not an array and at the top level of the recursion, 
  -        // return the type as it is  
  -        if (toplevel) 
  +        // if it is not an array, just return the type itself
  +        if (!type.endsWith("[]"))
               return type;
   
  -        // test for a primitive type
  +        // if it is an array, convert it to JavaVM-style format
  +        StringBuffer javaType = new StringBuffer(); 
  +        while (type.endsWith("[]")) {
  +            javaType.append("[");
  +            type = type.substring(0, type.length() - 2);
  +        }
  +        
           String primitiveIdentifier = (String) _primitiveTypes.get(type); 
           if (primitiveIdentifier != null)
  -            return primitiveIdentifier;
  -        
  -        // a normal java class 
  -        return "L" + type + ";";
  +            javaType.append(primitiveIdentifier);
  +        else
  +            javaType.append("L" + type + ";");
  +
  +        return javaType.toString();
       }
   
       protected void checkPropertyType(PropertyDescriptor pd, Class propertyType, ILocation
location)
  @@ -533,6 +539,5 @@
           }
           return _enhancedClass;
       }
  -
   
   }
  
  
  

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


Mime
View raw message