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

Method coerceToArray

java/org/apache/el/lang/ELSupport.java:641–659  ·  view source on GitHub ↗
(final ELContext ctx, final Object obj, final Class<?> type)

Source from the content-addressed store, hash-verified

639 }
640
641 private static Object coerceToArray(final ELContext ctx, final Object obj, final Class<?> type) {
642 // Note: Nested arrays will result in nested calls to this method.
643
644 // Note: Calling method has checked the obj is an array.
645
646 int size = Array.getLength(obj);
647 // Cast the input object to an array (calling method has checked it is
648 // an array)
649 // Get the target type for the array elements
650 Class<?> componentType = type.getComponentType();
651 // Create a new array of the correct type
652 Object result = Array.newInstance(componentType, size);
653 // Coerce each element in turn.
654 for (int i = 0; i < size; i++) {
655 Array.set(result, i, coerceToType(ctx, Array.get(obj, i), componentType));
656 }
657
658 return result;
659 }
660
661
662 private static <T> T coerceToFunctionalInterface(final ELContext ctx, final LambdaExpression lambdaExpression,

Callers 1

coerceToTypeMethod · 0.95

Calls 5

coerceToTypeMethod · 0.95
getLengthMethod · 0.65
newInstanceMethod · 0.65
setMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected