View Javadoc

1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2011, 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    
19    static int UNUSED_findNumberOfCommonFrames(StackTraceElement[] steArray,
20        StackTraceElement[] otherSTEArray) {
21      if (otherSTEArray == null) {
22        return 0;
23      }
24  
25      int steIndex = steArray.length - 1;
26      int parentIndex = otherSTEArray.length - 1;
27      int count = 0;
28      while (steIndex >= 0 && parentIndex >= 0) {
29        if (steArray[steIndex].equals(otherSTEArray[parentIndex])) {
30          count++;
31        } else {
32          break;
33        }
34        steIndex--;
35        parentIndex--;
36      }
37      return count;
38    }
39    
40    
41    static int findNumberOfCommonFrames(StackTraceElement[] steArray,
42        StackTraceElementProxy[] otherSTEPArray) {
43      if (otherSTEPArray == null) {
44        return 0;
45      }
46  
47      int steIndex = steArray.length - 1;
48      int parentIndex = otherSTEPArray.length - 1;
49      int count = 0;
50      while (steIndex >= 0 && parentIndex >= 0) {
51        if (steArray[steIndex].equals(otherSTEPArray[parentIndex].ste)) {
52          count++;
53        } else {
54          break;
55        }
56        steIndex--;
57        parentIndex--;
58      }
59      return count;
60    }
61  }