You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by mi...@apache.org on 2003/12/19 09:55:41 UTC
cvs commit: jakarta-tapestry/framework/src/org/apache/tapestry/enhance ComponentClassFactory.java
mindbridge 2003/12/19 00:55:41
Modified: framework/src/org/apache/tapestry/enhance
ComponentClassFactory.java
Log:
Fix for the bug
PR: 25642 properties cannot be of complex array types
Revision Changes Path
1.18 +44 -9 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.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- ComponentClassFactory.java 17 Oct 2003 18:53:53 -0000 1.17
+++ ComponentClassFactory.java 19 Dec 2003 08:55:41 -0000 1.18
@@ -101,6 +101,24 @@
**/
private static int _uid = 0;
+ /**
+ * Mapping between a primitive type and its Java VM representation
+ * Used for the encoding of array types
+ **/
+ private static Map _primitiveTypes = new HashMap();
+
+ static {
+ _primitiveTypes.put("boolean", "Z");
+ _primitiveTypes.put("short", "S");
+ _primitiveTypes.put("int", "I");
+ _primitiveTypes.put("long", "J");
+ _primitiveTypes.put("float", "F");
+ _primitiveTypes.put("double", "D");
+ _primitiveTypes.put("char", "C");
+ _primitiveTypes.put("byte", "B");
+ }
+
+
private IResourceResolver _resolver;
private IEnhancedClassFactory _enhancedClassFactory;
@@ -217,14 +235,7 @@
{
try
{
- String typeName = type;
-
- // if it is an array name reformat it in the way Java expects it
- if (type.endsWith("[]")) {
- String className = type.substring(0, type.length() - 2);
- typeName = "[L" + className + ";";
- }
-
+ String typeName = translateClassName(type, true);
result = _resolver.findClass(typeName);
}
catch (Exception ex)
@@ -241,6 +252,29 @@
return result;
}
+ // this method and its static Map should go into a utility class somewhere
+ protected String translateClassName(String type, boolean toplevel)
+ {
+ // 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)
+ return type;
+
+ // test for a primitive type
+ String primitiveIdentifier = (String) _primitiveTypes.get(type);
+ if (primitiveIdentifier != null)
+ return primitiveIdentifier;
+
+ // a normal java class
+ return "L" + type + ";";
+ }
+
protected void checkPropertyType(PropertyDescriptor pd, Class propertyType, ILocation location)
{
if (!pd.getPropertyType().equals(propertyType))
@@ -499,5 +533,6 @@
}
return _enhancedClass;
}
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org