MCPcopy Index your code
hub / github.com/apache/tomcat / coerceToCharacter

Method coerceToCharacter

java/org/apache/el/lang/ELSupport.java:276–305  ·  view source on GitHub ↗
(final ELContext ctx, final Object obj)

Source from the content-addressed store, hash-verified

274 }
275
276 private static Character coerceToCharacter(final ELContext ctx, final Object obj) throws ELException {
277
278 if (ctx != null) {
279 boolean originalIsPropertyResolved = ctx.isPropertyResolved();
280 try {
281 Character result = ctx.getELResolver().convertToType(ctx, obj, Character.class);
282 if (ctx.isPropertyResolved()) {
283 return result;
284 }
285 } finally {
286 ctx.setPropertyResolved(originalIsPropertyResolved);
287 }
288 }
289
290 if (obj == null || "".equals(obj)) {
291 return Character.valueOf((char) 0);
292 }
293 if (obj instanceof String) {
294 return Character.valueOf(((String) obj).charAt(0));
295 }
296 if (ELArithmetic.isNumber(obj)) {
297 return Character.valueOf((char) ((Number) obj).shortValue());
298 }
299 Class<?> objType = obj.getClass();
300 if (obj instanceof Character) {
301 return (Character) obj;
302 }
303
304 throw new ELException(MessageFactory.get("error.convert", obj, objType, Character.class));
305 }
306
307 /**
308 * Coerces a Number to the specified numeric type.

Callers 1

coerceToTypeMethod · 0.95

Calls 9

isNumberMethod · 0.95
getMethod · 0.95
charAtMethod · 0.80
equalsMethod · 0.65
isPropertyResolvedMethod · 0.45
convertToTypeMethod · 0.45
getELResolverMethod · 0.45
setPropertyResolvedMethod · 0.45
valueOfMethod · 0.45

Tested by

no test coverage detected