View Javadoc
1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2015, QOS.ch. All rights reserved.
4    *
5    * This program and the accompanying materials are dual-licensed under
6    * either the terms of the Eclipse Public License v1.0 as published by
7    * the Eclipse Foundation
8    *
9    *   or (per the licensee's choosing)
10   *
11   * under the terms of the GNU Lesser General Public License version 2.1
12   * as published by the Free Software Foundation.
13   */
14  package ch.qos.logback.classic.spi;
15  
16  public class STEUtil {
17  
18      static int UNUSED_findNumberOfCommonFrames(StackTraceElement[] steArray, StackTraceElement[] otherSTEArray) {
19          if (otherSTEArray == null) {
20              return 0;
21          }
22  
23          int steIndex = steArray.length - 1;
24          int parentIndex = otherSTEArray.length - 1;
25          int count = 0;
26          while (steIndex >= 0 && parentIndex >= 0) {
27              if (steArray[steIndex].equals(otherSTEArray[parentIndex])) {
28                  count++;
29              } else {
30                  break;
31              }
32              steIndex--;
33              parentIndex--;
34          }
35          return count;
36      }
37  
38      static int findNumberOfCommonFrames(StackTraceElement[] steArray, StackTraceElementProxy[] otherSTEPArray) {
39          if (otherSTEPArray == null) {
40              return 0;
41          }
42  
43          int steIndex = steArray.length - 1;
44          int parentIndex = otherSTEPArray.length - 1;
45          int count = 0;
46          while (steIndex >= 0 && parentIndex >= 0) {
47              if (steArray[steIndex].equals(otherSTEPArray[parentIndex].ste)) {
48                  count++;
49              } else {
50                  break;
51              }
52              steIndex--;
53              parentIndex--;
54          }
55          return count;
56      }
57  }