1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.classic.spi;
15
16 import java.io.Serializable;
17 import java.util.Arrays;
18
19 public class ThrowableProxyVO implements IThrowableProxy, Serializable {
20
21 private static final long serialVersionUID = -773438177285807139L;
22
23 private String className;
24 private String overridingMessage;
25 private String message;
26 private int commonFramesCount;
27 private StackTraceElementProxy[] stackTraceElementProxyArray;
28 private IThrowableProxy cause;
29 private IThrowableProxy[] suppressed;
30 private boolean cyclic;
31
32 public String getMessage() {
33 return message;
34 }
35
36
37
38
39
40
41
42
43
44 @Override
45 public String getOverridingMessage() { return overridingMessage;}
46
47 public String getClassName() {
48 return className;
49 }
50
51 public int getCommonFrames() {
52 return commonFramesCount;
53 }
54
55 public IThrowableProxy getCause() {
56 return cause;
57 }
58
59 public StackTraceElementProxy[] getStackTraceElementProxyArray() {
60 return stackTraceElementProxyArray;
61 }
62
63 public IThrowableProxy[] getSuppressed() {
64 return suppressed;
65 }
66
67 public boolean isCyclic() {
68 return cyclic;
69 }
70
71
72
73
74
75
76
77
78
79
80
81 public static ThrowableProxyVOBuilder builder() {
82 return new ThrowableProxyVOBuilder();
83 }
84
85
86
87 void setClassName(String className) {
88 this.className = className;
89 }
90
91 void setMessage(String message) {
92 this.message = message;
93 }
94
95 void setOverridingMessage(String overridingMessage) {
96 this.overridingMessage = overridingMessage;
97 }
98
99 void setCommonFramesCount(int commonFramesCount) {
100 this.commonFramesCount = commonFramesCount;
101 }
102
103 void setStackTraceElementProxyArray(StackTraceElementProxy[] stackTraceElementProxyArray) {
104 this.stackTraceElementProxyArray = stackTraceElementProxyArray;
105 }
106
107 void setCause(IThrowableProxy cause) {
108 this.cause = cause;
109 }
110
111 void setSuppressed(IThrowableProxy[] suppressed) {
112 this.suppressed = suppressed;
113 }
114
115 void setCyclic(boolean cyclic) {
116 this.cyclic = cyclic;
117 }
118
119 @Override
120 public int hashCode() {
121 final int prime = 31;
122 int result = 1;
123 result = prime * result + ((className == null) ? 0 : className.hashCode());
124 return result;
125 }
126
127 @Override
128 public boolean equals(Object obj) {
129 if (this == obj)
130 return true;
131 if (obj == null)
132 return false;
133 if (getClass() != obj.getClass())
134 return false;
135 final ThrowableProxyVO other = (ThrowableProxyVO) obj;
136
137 if (className == null) {
138 if (other.className != null)
139 return false;
140 } else if (!className.equals(other.className))
141 return false;
142
143 if (!Arrays.equals(stackTraceElementProxyArray, other.stackTraceElementProxyArray))
144 return false;
145
146 if (!Arrays.equals(suppressed, other.suppressed))
147 return false;
148
149 if (cause == null) {
150 if (other.cause != null)
151 return false;
152 } else if (!cause.equals(other.cause))
153 return false;
154
155 return true;
156 }
157
158 public static ThrowableProxyVO build(IThrowableProxy throwableProxy) {
159 if (throwableProxy == null) {
160 return null;
161 }
162 ThrowableProxyVO tpvo = new ThrowableProxyVO();
163 tpvo.className = throwableProxy.getClassName();
164 tpvo.message = throwableProxy.getMessage();
165 tpvo.overridingMessage = throwableProxy.getOverridingMessage();
166 tpvo.commonFramesCount = throwableProxy.getCommonFrames();
167 tpvo.stackTraceElementProxyArray = throwableProxy.getStackTraceElementProxyArray();
168 tpvo.cyclic = throwableProxy.isCyclic();
169
170 IThrowableProxy cause = throwableProxy.getCause();
171 if (cause != null) {
172 tpvo.cause = ThrowableProxyVO.build(cause);
173 }
174 IThrowableProxy[] suppressed = throwableProxy.getSuppressed();
175 if (suppressed != null) {
176 tpvo.suppressed = new IThrowableProxy[suppressed.length];
177 for (int i = 0; i < suppressed.length; i++) {
178 tpvo.suppressed[i] = ThrowableProxyVO.build(suppressed[i]);
179 }
180 }
181
182 return tpvo;
183 }
184 }