class NestableDelegate {
/**
* Trims the stack frames. The first set is left untouched. The rest
* of the frames are truncated from the bottom by comparing with
* one just on top.
*
* @param stacks The list containing String[] elements
* @since 2.0
*/
protected void trimStackFrames(List stacks) {
for (int size=stacks.size(), i=size-1; i > 0; i--) {
String[] curr = (String[]) stacks.get(i);
String[] next = (String[]) stacks.get(i-1);
List currList = new ArrayList(Arrays.asList(curr));
List nextList = new ArrayList(Arrays.asList(next));
ExceptionUtils.removeCommonFrames(currList, nextList);
int trimmed = curr.length - currList.size();
if (trimmed > 0) {
currList.add("\t... "+trimmed+" more");
stacks.set(
i,
currList.toArray(new String[currList.size()])
);
}
}
}
}