View Javadoc

1   package ch.qos.logback.classic.spi;
2   
3   public class STEUtil {
4   
5     
6     static int findNumberOfCommonFrames(StackTraceElement[] steArray,
7         StackTraceElement[] otherSTEArray) {
8       if (otherSTEArray == null) {
9         return 0;
10      }
11  
12      int steIndex = steArray.length - 1;
13      int parentIndex = otherSTEArray.length - 1;
14      int count = 0;
15      while (steIndex >= 0 && parentIndex >= 0) {
16        if (steArray[steIndex].equals(otherSTEArray[parentIndex])) {
17          count++;
18        } else {
19          break;
20        }
21        steIndex--;
22        parentIndex--;
23      }
24      return count;
25    }
26    
27    
28    static int findNumberOfCommonFrames(StackTraceElement[] steArray,
29        StackTraceElementProxy[] otherSTEPArray) {
30      if (otherSTEPArray == null) {
31        return 0;
32      }
33  
34      int steIndex = steArray.length - 1;
35      int parentIndex = otherSTEPArray.length - 1;
36      int count = 0;
37      while (steIndex >= 0 && parentIndex >= 0) {
38        if (steArray[steIndex].equals(otherSTEPArray[parentIndex].ste)) {
39          count++;
40        } else {
41          break;
42        }
43        steIndex--;
44        parentIndex--;
45      }
46      return count;
47    }
48  }