ReflectionToStringBuilder.java
6.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
package org.apache.commons.lang3.builder;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.apache.commons.lang3.ArrayUtils;
public class ReflectionToStringBuilder
extends ToStringBuilder
{
private boolean a = false;
private boolean b = false;
private Class<?> c = null;
protected String[] excludeFieldNames;
public ReflectionToStringBuilder(Object paramObject)
{
super(a(paramObject));
}
public ReflectionToStringBuilder(Object paramObject, ToStringStyle paramToStringStyle)
{
super(a(paramObject), paramToStringStyle);
}
public ReflectionToStringBuilder(Object paramObject, ToStringStyle paramToStringStyle, StringBuffer paramStringBuffer)
{
super(a(paramObject), paramToStringStyle, paramStringBuffer);
}
public <T> ReflectionToStringBuilder(T paramT, ToStringStyle paramToStringStyle, StringBuffer paramStringBuffer, Class<? super T> paramClass, boolean paramBoolean1, boolean paramBoolean2)
{
super(a(paramT), paramToStringStyle, paramStringBuffer);
setUpToClass(paramClass);
setAppendTransients(paramBoolean1);
setAppendStatics(paramBoolean2);
}
private static Object a(Object paramObject)
{
if (paramObject == null) {
throw new IllegalArgumentException("The Object passed in should not be null.");
}
return paramObject;
}
static String[] a(Collection<String> paramCollection)
{
if (paramCollection == null) {
return ArrayUtils.EMPTY_STRING_ARRAY;
}
return a(paramCollection.toArray());
}
private static String[] a(Object[] paramArrayOfObject)
{
ArrayList localArrayList = new ArrayList(paramArrayOfObject.length);
int j = paramArrayOfObject.length;
int i = 0;
while (i < j)
{
Object localObject = paramArrayOfObject[i];
if (localObject != null) {
localArrayList.add(localObject.toString());
}
i += 1;
}
return (String[])localArrayList.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
}
public static String toString(Object paramObject)
{
return toString(paramObject, null, false, false, null);
}
public static String toString(Object paramObject, ToStringStyle paramToStringStyle)
{
return toString(paramObject, paramToStringStyle, false, false, null);
}
public static String toString(Object paramObject, ToStringStyle paramToStringStyle, boolean paramBoolean)
{
return toString(paramObject, paramToStringStyle, paramBoolean, false, null);
}
public static String toString(Object paramObject, ToStringStyle paramToStringStyle, boolean paramBoolean1, boolean paramBoolean2)
{
return toString(paramObject, paramToStringStyle, paramBoolean1, paramBoolean2, null);
}
public static <T> String toString(T paramT, ToStringStyle paramToStringStyle, boolean paramBoolean1, boolean paramBoolean2, Class<? super T> paramClass)
{
return new ReflectionToStringBuilder(paramT, paramToStringStyle, null, paramClass, paramBoolean1, paramBoolean2).toString();
}
public static String toStringExclude(Object paramObject, Collection<String> paramCollection)
{
return toStringExclude(paramObject, a(paramCollection));
}
public static String toStringExclude(Object paramObject, String... paramVarArgs)
{
return new ReflectionToStringBuilder(paramObject).setExcludeFieldNames(paramVarArgs).toString();
}
protected boolean accept(Field paramField)
{
if (paramField.getName().indexOf('$') != -1) {}
while (((Modifier.isTransient(paramField.getModifiers())) && (!isAppendTransients())) || ((Modifier.isStatic(paramField.getModifiers())) && (!isAppendStatics())) || ((this.excludeFieldNames != null) && (Arrays.binarySearch(this.excludeFieldNames, paramField.getName()) >= 0)) || (paramField.isAnnotationPresent(ToStringExclude.class))) {
return false;
}
return true;
}
protected void appendFieldsIn(Class<?> paramClass)
{
if (paramClass.isArray())
{
reflectionAppendArray(getObject());
return;
}
paramClass = paramClass.getDeclaredFields();
AccessibleObject.setAccessible(paramClass, true);
int j = paramClass.length;
int i = 0;
while (i < j)
{
Field localField = paramClass[i];
String str = localField.getName();
if (accept(localField)) {}
try
{
append(str, getValue(localField));
i += 1;
}
catch (IllegalAccessException paramClass)
{
throw new InternalError("Unexpected IllegalAccessException: " + paramClass.getMessage());
}
}
}
public String[] getExcludeFieldNames()
{
return (String[])this.excludeFieldNames.clone();
}
public Class<?> getUpToClass()
{
return this.c;
}
protected Object getValue(Field paramField)
throws IllegalArgumentException, IllegalAccessException
{
return paramField.get(getObject());
}
public boolean isAppendStatics()
{
return this.a;
}
public boolean isAppendTransients()
{
return this.b;
}
public ReflectionToStringBuilder reflectionAppendArray(Object paramObject)
{
getStyle().reflectionAppendArrayDetail(getStringBuffer(), null, paramObject);
return this;
}
public void setAppendStatics(boolean paramBoolean)
{
this.a = paramBoolean;
}
public void setAppendTransients(boolean paramBoolean)
{
this.b = paramBoolean;
}
public ReflectionToStringBuilder setExcludeFieldNames(String... paramVarArgs)
{
if (paramVarArgs == null)
{
this.excludeFieldNames = null;
return this;
}
this.excludeFieldNames = a(paramVarArgs);
Arrays.sort(this.excludeFieldNames);
return this;
}
public void setUpToClass(Class<?> paramClass)
{
if (paramClass != null)
{
Object localObject = getObject();
if ((localObject != null) && (!paramClass.isInstance(localObject))) {
throw new IllegalArgumentException("Specified class is not a superclass of the object");
}
}
this.c = paramClass;
}
public String toString()
{
if (getObject() == null) {
return getStyle().getNullText();
}
Class localClass = getObject().getClass();
appendFieldsIn(localClass);
while ((localClass.getSuperclass() != null) && (localClass != getUpToClass()))
{
localClass = localClass.getSuperclass();
appendFieldsIn(localClass);
}
return super.toString();
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/org/apache/commons/lang3/builder/ReflectionToStringBuilder.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/