Process the end of this element. @param namespace the namespace URI of the matching element, or an empty string if the parser is not namespace aware or the element has no namespace @param name the local name if the parser is namespace aware, or just the element name otherw
(String namespace, String name)
| 243 | * @param name the local name if the parser is namespace aware, or just the element name otherwise |
| 244 | */ |
| 245 | @SuppressWarnings("null") // parameters can't trigger NPE |
| 246 | @Override |
| 247 | public void end(String namespace, String name) throws Exception { |
| 248 | |
| 249 | // Retrieve or construct the parameter values array |
| 250 | Object[] parameters = null; |
| 251 | if (paramCount > 0) { |
| 252 | |
| 253 | parameters = (Object[]) digester.popParams(); |
| 254 | |
| 255 | if (digester.log.isTraceEnabled()) { |
| 256 | for (int i = 0, size = parameters.length; i < size; i++) { |
| 257 | digester.log.trace("[CallMethodRule](" + i + ")" + parameters[i]); |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | // In the case where the parameter for the method |
| 262 | // is taken from an attribute, and that attribute |
| 263 | // isn't actually defined in the source XML file, |
| 264 | // skip the method call |
| 265 | if (paramCount == 1 && parameters[0] == null) { |
| 266 | return; |
| 267 | } |
| 268 | |
| 269 | } else if (paramTypes.length != 0) { |
| 270 | |
| 271 | // In the case where the parameter for the method |
| 272 | // is taken from the body text, but there is no |
| 273 | // body text included in the source XML file, |
| 274 | // skip the method call |
| 275 | if (bodyText == null) { |
| 276 | return; |
| 277 | } |
| 278 | |
| 279 | parameters = new Object[1]; |
| 280 | parameters[0] = bodyText; |
| 281 | } |
| 282 | |
| 283 | // Construct the parameter values array we will need |
| 284 | // We only do the conversion if the param value is a String and |
| 285 | // the specified paramType is not String. |
| 286 | Object[] paramValues = new Object[paramTypes.length]; |
| 287 | for (int i = 0; i < paramTypes.length; i++) { |
| 288 | // convert nulls and convert stringy parameters |
| 289 | // for non-stringy param types |
| 290 | Object param = parameters[i]; |
| 291 | // Tolerate null non-primitive values |
| 292 | if (null == param && !paramTypes[i].isPrimitive()) { |
| 293 | paramValues[i] = null; |
| 294 | } else if (param instanceof String && !String.class.isAssignableFrom(paramTypes[i])) { |
| 295 | |
| 296 | paramValues[i] = IntrospectionUtils.convert((String) parameters[i], paramTypes[i]); |
| 297 | } else { |
| 298 | paramValues[i] = parameters[i]; |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | // Determine the target object for the method call |
nothing calls this directly
no test coverage detected