1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.logging.log4j.core.impl;
18
19 import java.io.Serializable;
20
21
22
23
24
25
26
27
28
29
30
31
32 public final class ExtendedStackTraceElement implements Serializable {
33
34 private static final long serialVersionUID = -2171069569241280505L;
35
36 private final ExtendedClassInfo extraClassInfo;
37
38 private final StackTraceElement stackTraceElement;
39
40 public ExtendedStackTraceElement(final StackTraceElement stackTraceElement, final ExtendedClassInfo extraClassInfo) {
41 this.stackTraceElement = stackTraceElement;
42 this.extraClassInfo = extraClassInfo;
43 }
44
45
46
47
48 public ExtendedStackTraceElement(final String declaringClass, final String methodName, final String fileName,
49 final int lineNumber, final boolean exact, final String location, final String version) {
50 this(new StackTraceElement(declaringClass, methodName, fileName, lineNumber), new ExtendedClassInfo(exact,
51 location, version));
52 }
53
54 @Override
55 public boolean equals(final Object obj) {
56 if (this == obj) {
57 return true;
58 }
59 if (obj == null) {
60 return false;
61 }
62 if (!(obj instanceof ExtendedStackTraceElement)) {
63 return false;
64 }
65 final ExtendedStackTraceElement other = (ExtendedStackTraceElement) obj;
66 if (this.extraClassInfo == null) {
67 if (other.extraClassInfo != null) {
68 return false;
69 }
70 } else if (!this.extraClassInfo.equals(other.extraClassInfo)) {
71 return false;
72 }
73 if (this.stackTraceElement == null) {
74 if (other.stackTraceElement != null) {
75 return false;
76 }
77 } else if (!this.stackTraceElement.equals(other.stackTraceElement)) {
78 return false;
79 }
80 return true;
81 }
82
83 public String getClassName() {
84 return this.stackTraceElement.getClassName();
85 }
86
87 public boolean getExact() {
88 return this.extraClassInfo.getExact();
89 }
90
91 public ExtendedClassInfo getExtraClassInfo() {
92 return this.extraClassInfo;
93 }
94
95 public String getFileName() {
96 return this.stackTraceElement.getFileName();
97 }
98
99 public int getLineNumber() {
100 return this.stackTraceElement.getLineNumber();
101 }
102
103 public String getLocation() {
104 return this.extraClassInfo.getLocation();
105 }
106
107 public String getMethodName() {
108 return this.stackTraceElement.getMethodName();
109 }
110
111 public StackTraceElement getStackTraceElement() {
112 return this.stackTraceElement;
113 }
114
115 public String getVersion() {
116 return this.extraClassInfo.getVersion();
117 }
118
119 @Override
120 public int hashCode() {
121 final int prime = 31;
122 int result = 1;
123 result = prime * result + ((this.extraClassInfo == null) ? 0 : this.extraClassInfo.hashCode());
124 result = prime * result + ((this.stackTraceElement == null) ? 0 : this.stackTraceElement.hashCode());
125 return result;
126 }
127
128 public boolean isNativeMethod() {
129 return this.stackTraceElement.isNativeMethod();
130 }
131
132 @Override
133 public String toString() {
134 final StringBuilder sb = new StringBuilder();
135 sb.append(this.stackTraceElement);
136 sb.append(" ");
137 sb.append(this.extraClassInfo);
138 return sb.toString();
139 }
140 }