1 15 package org.apache.tapestry.enhance; 16 17 import java.lang.reflect.Constructor ; 18 import java.lang.reflect.Method ; 19 20 import org.apache.hivemind.impl.MessageFormatter; 21 import org.apache.hivemind.service.ClassFabUtils; 22 import org.apache.tapestry.IAsset; 23 import org.apache.tapestry.Tapestry; 24 25 31 class EnhanceMessages 32 { 33 protected static MessageFormatter _formatter = new MessageFormatter(EnhanceMessages.class, 34 "EnhanceStrings"); 35 36 static String noImplForAbstractMethod(Method method, Class declareClass, String className, 37 Class enhancedClass) 38 { 39 return _formatter.format("no-impl-for-abstract-method", new Object [] 40 { method, declareClass.getName(), className, enhancedClass.getName() }); 41 } 42 43 static String unabelToIntrospectClass(Class targetClass, Throwable cause) 44 { 45 return _formatter.format("unable-to-introspect-class", targetClass.getName(), cause); 46 } 47 48 static String propertyTypeMismatch(Class componentClass, String propertyName, 49 Class actualPropertyType, Class expectedPropertyType) 50 { 51 return _formatter.format("property-type-mismatch", new Object [] 52 { componentClass.getName(), propertyName, 53 ClassFabUtils.getJavaClassName(actualPropertyType), 54 ClassFabUtils.getJavaClassName(expectedPropertyType) }); 55 } 56 57 static String errorAddingProperty(String propertyName, Class componentClass, Throwable cause) 58 { 59 return _formatter.format( 60 "error-adding-property", 61 propertyName, 62 componentClass.getName(), 63 cause); 64 } 65 66 static String claimedProperty(String propertyName) 67 { 68 return _formatter.format("claimed-property", propertyName); 69 } 70 71 static String instantiationFailure(Constructor c, Object [] parameters, String classFab, 72 Throwable cause) 73 { 74 int count = Tapestry.size(parameters); 75 StringBuffer buffer = new StringBuffer ("["); 76 for (int i = 0; i < count; i++) 77 { 78 if (i > 0) 79 buffer.append(", "); 80 buffer.append(parameters[i]); 81 } 82 83 buffer.append("]"); 84 85 return _formatter.format("instantiation-failure", new Object [] 86 { c.getDeclaringClass().getName(), c, buffer.toString(), classFab, cause }); 87 } 88 89 static String locatedValueIsNull(String objectReference) 90 { 91 return _formatter.format("located-value-is-null", objectReference); 92 } 93 94 static String incompatibleInjectType(String locator, Object value, Class propertyType) 95 { 96 return _formatter.format("incompatible-inject-type", locator, value, ClassFabUtils 97 .getJavaClassName(propertyType)); 98 } 99 100 static String initialValueForProperty(String propertyName) 101 { 102 return _formatter.format("initial-value-for-property", propertyName); 103 } 104 105 static String unknownInjectType(String propertyName, String injectType) 106 { 107 return _formatter.format("unknown-inject-type", propertyName, injectType); 108 } 109 110 static String wrongTypeForProperty(String propertyName, Class propertyType, Class requiredType) 111 { 112 return _formatter.format("wrong-type-for-property", propertyName, ClassFabUtils 113 .getJavaClassName(propertyType), ClassFabUtils.getJavaClassName(requiredType)); 114 } 115 116 public static String wrongTypeForPageInjection(String propertyName, Class propertyType) 117 { 118 return _formatter.format("wrong-type-for-page-injection", propertyName, ClassFabUtils 119 .getJavaClassName(propertyType)); 120 } 121 122 public static String incompatiblePropertyType(String propertyName, Class propertyType, 123 Class expectedType) 124 { 125 return _formatter.format("incompatible-property-type", propertyName, ClassFabUtils 126 .getJavaClassName(propertyType), ClassFabUtils.getJavaClassName(expectedType)); 127 } 128 129 public static String classEnhancementFailure(Class baseClass, Throwable cause) 130 { 131 return _formatter.format("class-enhancement-failure", ClassFabUtils 132 .getJavaClassName(baseClass), cause); 133 } 134 135 } | Popular Tags |