|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
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.Location; |
|
21 |
| import org.apache.hivemind.impl.MessageFormatter; |
|
22 |
| import org.apache.hivemind.service.ClassFabUtils; |
|
23 |
| import org.apache.hivemind.service.MethodSignature; |
|
24 |
| import org.apache.tapestry.Tapestry; |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| class EnhanceMessages |
|
33 |
| { |
|
34 |
| private final static MessageFormatter _formatter = new MessageFormatter(EnhanceMessages.class); |
|
35 |
| |
|
36 |
3
| static String noImplForAbstractMethod(Method method, Class declareClass, Class baseClass,
|
|
37 |
| Class enhancedClass) |
|
38 |
| { |
|
39 |
3
| return _formatter.format("no-impl-for-abstract-method", new Object[]
|
|
40 |
| { method, declareClass.getName(), baseClass.getName(), enhancedClass.getName() }); |
|
41 |
| } |
|
42 |
| |
|
43 |
3
| static String unimplementedInterfaceMethod(Method method, Class baseClass, Class enhancedClass)
|
|
44 |
| { |
|
45 |
3
| return _formatter.format(
|
|
46 |
| "unimplemented-interface-method", |
|
47 |
| method, |
|
48 |
| baseClass.getName(), |
|
49 |
| enhancedClass.getName()); |
|
50 |
| } |
|
51 |
| |
|
52 |
0
| static String unabelToIntrospectClass(Class targetClass, Throwable cause)
|
|
53 |
| { |
|
54 |
0
| return _formatter.format("unable-to-introspect-class", targetClass.getName(), cause);
|
|
55 |
| } |
|
56 |
| |
|
57 |
6
| static String propertyTypeMismatch(Class componentClass, String propertyName,
|
|
58 |
| Class actualPropertyType, Class expectedPropertyType) |
|
59 |
| { |
|
60 |
6
| return _formatter.format("property-type-mismatch", new Object[]
|
|
61 |
| { componentClass.getName(), propertyName, |
|
62 |
| ClassFabUtils.getJavaClassName(actualPropertyType), |
|
63 |
| ClassFabUtils.getJavaClassName(expectedPropertyType) }); |
|
64 |
| } |
|
65 |
| |
|
66 |
45
| static String errorAddingProperty(String propertyName, Class componentClass, Throwable cause)
|
|
67 |
| { |
|
68 |
45
| return _formatter.format(
|
|
69 |
| "error-adding-property", |
|
70 |
| propertyName, |
|
71 |
| componentClass.getName(), |
|
72 |
| cause); |
|
73 |
| } |
|
74 |
| |
|
75 |
27
| static String claimedProperty(String propertyName)
|
|
76 |
| { |
|
77 |
27
| return _formatter.format("claimed-property", propertyName);
|
|
78 |
| } |
|
79 |
| |
|
80 |
3
| static String instantiationFailure(Constructor c, Object[] parameters, String classFab,
|
|
81 |
| Throwable cause) |
|
82 |
| { |
|
83 |
3
| int count = Tapestry.size(parameters);
|
|
84 |
3
| StringBuffer buffer = new StringBuffer("[");
|
|
85 |
3
| for (int i = 0; i < count; i++)
|
|
86 |
| { |
|
87 |
3
| if (i > 0)
|
|
88 |
0
| buffer.append(", ");
|
|
89 |
3
| buffer.append(parameters[i]);
|
|
90 |
| } |
|
91 |
| |
|
92 |
3
| buffer.append("]");
|
|
93 |
| |
|
94 |
3
| return _formatter.format("instantiation-failure", new Object[]
|
|
95 |
| { c.getDeclaringClass().getName(), c, buffer.toString(), classFab, cause }); |
|
96 |
| } |
|
97 |
| |
|
98 |
3
| static String locatedValueIsNull(String objectReference)
|
|
99 |
| { |
|
100 |
3
| return _formatter.format("located-value-is-null", objectReference);
|
|
101 |
| } |
|
102 |
| |
|
103 |
3
| static String incompatibleInjectType(String locator, Object value, Class propertyType)
|
|
104 |
| { |
|
105 |
3
| return _formatter.format("incompatible-inject-type", locator, value, ClassFabUtils
|
|
106 |
| .getJavaClassName(propertyType)); |
|
107 |
| } |
|
108 |
| |
|
109 |
21
| static String initialValueForProperty(String propertyName)
|
|
110 |
| { |
|
111 |
21
| return _formatter.format("initial-value-for-property", propertyName);
|
|
112 |
| } |
|
113 |
| |
|
114 |
6
| static String unknownInjectType(String propertyName, String injectType)
|
|
115 |
| { |
|
116 |
6
| return _formatter.format("unknown-inject-type", propertyName, injectType);
|
|
117 |
| } |
|
118 |
| |
|
119 |
3
| static String wrongTypeForProperty(String propertyName, Class propertyType, Class requiredType)
|
|
120 |
| { |
|
121 |
3
| return _formatter.format("wrong-type-for-property", propertyName, ClassFabUtils
|
|
122 |
| .getJavaClassName(propertyType), ClassFabUtils.getJavaClassName(requiredType)); |
|
123 |
| } |
|
124 |
| |
|
125 |
3
| static String wrongTypeForPageInjection(String propertyName, Class propertyType)
|
|
126 |
| { |
|
127 |
3
| return _formatter.format("wrong-type-for-page-injection", propertyName, ClassFabUtils
|
|
128 |
| .getJavaClassName(propertyType)); |
|
129 |
| } |
|
130 |
| |
|
131 |
3
| static String incompatiblePropertyType(String propertyName, Class propertyType,
|
|
132 |
| Class expectedType) |
|
133 |
| { |
|
134 |
3
| return _formatter.format("incompatible-property-type", propertyName, ClassFabUtils
|
|
135 |
| .getJavaClassName(propertyType), ClassFabUtils.getJavaClassName(expectedType)); |
|
136 |
| } |
|
137 |
| |
|
138 |
3
| static String classEnhancementFailure(Class baseClass, Throwable cause)
|
|
139 |
| { |
|
140 |
3
| return _formatter.format("class-enhancement-failure", ClassFabUtils
|
|
141 |
| .getJavaClassName(baseClass), cause); |
|
142 |
| } |
|
143 |
| |
|
144 |
3
| static String methodConflict(MethodSignature sig, Location existing)
|
|
145 |
| { |
|
146 |
3
| return _formatter.format("method-conflict", sig, existing);
|
|
147 |
| } |
|
148 |
| |
|
149 |
3
| static String readonlyProperty(String propertyName, Method writeMethod)
|
|
150 |
| { |
|
151 |
3
| return _formatter.format("readonly-property", propertyName, writeMethod);
|
|
152 |
| } |
|
153 |
| |
|
154 |
3
| static String mustBeBoolean(String propertyName)
|
|
155 |
| { |
|
156 |
3
| return _formatter.format("must-be-boolean", propertyName);
|
|
157 |
| } |
|
158 |
| } |