1
|
|
|
2
|
|
|
3
|
|
|
4
|
|
|
5
|
|
package xjavadoc;
|
6
|
|
|
7
|
|
import org.apache.commons.collections.Predicate;
|
8
|
|
import org.apache.commons.collections.CollectionUtils;
|
9
|
|
|
10
|
|
import java.util.*;
|
11
|
|
import java.io.IOException;
|
12
|
|
import java.io.File;
|
13
|
|
|
14
|
|
|
15
|
|
|
16
|
|
|
17
|
|
|
18
|
|
|
19
|
|
|
20
|
|
|
21
|
|
public abstract class AbstractClass extends AbstractProgramElement implements XClass
|
22
|
|
{
|
23
|
|
|
24
|
|
|
25
|
|
|
26
|
|
private List _declaredInterfaces;
|
27
|
|
|
28
|
|
|
29
|
|
|
30
|
|
private List _allInterfaces;
|
31
|
|
|
32
|
|
private List _importedClasses;
|
33
|
|
private List _importedClassNames;
|
34
|
|
private List _importedPackages;
|
35
|
|
private List _constructors;
|
36
|
|
private Map _namedConstructors;
|
37
|
|
private List _methods;
|
38
|
|
private HashMap _namedMethods;
|
39
|
|
private List _fields;
|
40
|
|
private List _innerClasses;
|
41
|
|
private XPackage _containingPackage;
|
42
|
|
private boolean _isInterface;
|
43
|
|
private boolean _isAnonymous = false;
|
44
|
|
private XClass _superclass;
|
45
|
|
private int _hash = Integer.MIN_VALUE;
|
46
|
|
private List _directSubclasses;
|
47
|
|
private List _allSubclasses;
|
48
|
|
private List _implementingClasses;
|
49
|
|
private List _extendingInterfaces;
|
50
|
|
private String _name;
|
51
|
|
private String _transformedName;
|
52
|
|
private String _qualifiedName;
|
53
|
|
private String _transformedQualifiedName;
|
54
|
|
|
55
|
252
|
protected AbstractClass( AbstractClass containingClass, XTagFactory tagFactory )
|
56
|
|
{
|
57
|
252
|
super( containingClass, tagFactory );
|
58
|
|
}
|
59
|
|
|
60
|
3308
|
protected AbstractClass( XJavaDoc xJavaDoc, XTagFactory tagFactory )
|
61
|
|
{
|
62
|
3308
|
super( xJavaDoc, tagFactory );
|
63
|
|
}
|
64
|
|
|
65
|
|
|
66
|
|
|
67
|
|
|
68
|
|
|
69
|
|
|
70
|
8760
|
public final boolean isInterface()
|
71
|
|
{
|
72
|
8760
|
return _isInterface;
|
73
|
|
}
|
74
|
|
|
75
|
18
|
public final boolean isA( String full_qualified_type_name )
|
76
|
|
{
|
77
|
18
|
return isA( full_qualified_type_name, true );
|
78
|
|
}
|
79
|
|
|
80
|
18
|
public final boolean isA( final String full_qualified_type_name, final boolean superclasses )
|
81
|
|
{
|
82
|
18
|
final boolean sameClass = getQualifiedName().equals( full_qualified_type_name );
|
83
|
18
|
final boolean subClass = isSubclassOf( full_qualified_type_name, superclasses );
|
84
|
18
|
final boolean implementz = isImplementingInterface( full_qualified_type_name, superclasses );
|
85
|
|
|
86
|
18
|
return sameClass || subClass || implementz;
|
87
|
|
}
|
88
|
|
|
89
|
2622
|
public final XMethod getMethod( String methodNameWithSignature )
|
90
|
|
{
|
91
|
2622
|
return getMethod( methodNameWithSignature, false );
|
92
|
|
}
|
93
|
|
|
94
|
2650
|
public final XMethod getMethod( String methodNameWithSignature, boolean superclasses )
|
95
|
|
{
|
96
|
2650
|
XMethod result = null;
|
97
|
|
|
98
|
2650
|
initializeNamedMethodsHashMap();
|
99
|
|
|
100
|
2650
|
if( _namedMethods != null )
|
101
|
|
{
|
102
|
1448
|
result = ( XMethod ) _namedMethods.get( methodNameWithSignature );
|
103
|
|
}
|
104
|
2650
|
if( result == null && superclasses )
|
105
|
|
{
|
106
|
16
|
XClass superclass = getSuperclass();
|
107
|
|
|
108
|
16
|
if( superclass != null )
|
109
|
|
{
|
110
|
10
|
result = superclass.getMethod( methodNameWithSignature, true );
|
111
|
|
}
|
112
|
|
}
|
113
|
2650
|
return result;
|
114
|
|
}
|
115
|
|
|
116
|
|
|
117
|
|
|
118
|
|
|
119
|
|
|
120
|
|
|
121
|
|
|
122
|
0
|
public final XConstructor getConstructor( String constructorNameWithSignature )
|
123
|
|
{
|
124
|
0
|
initializeNamedConstructorsHashMap();
|
125
|
|
|
126
|
0
|
if( _namedConstructors != null )
|
127
|
0
|
return ( XConstructor ) _namedConstructors.get( constructorNameWithSignature );
|
128
|
|
else
|
129
|
0
|
return null;
|
130
|
|
}
|
131
|
|
|
132
|
|
|
133
|
|
|
134
|
|
|
135
|
|
|
136
|
|
|
137
|
|
|
138
|
2
|
public final XField getField( String fieldName )
|
139
|
|
{
|
140
|
2
|
if( _fields == null )
|
141
|
|
{
|
142
|
0
|
return null;
|
143
|
|
}
|
144
|
2
|
for( int i = 0; i < _fields.size(); i++ )
|
145
|
|
{
|
146
|
2
|
XField field = ( XField ) _fields.get( i );
|
147
|
|
|
148
|
2
|
if( field.getName().equals( fieldName ) )
|
149
|
|
{
|
150
|
2
|
return field;
|
151
|
|
}
|
152
|
|
}
|
153
|
0
|
return null;
|
154
|
|
}
|
155
|
|
|
156
|
|
|
157
|
|
|
158
|
|
|
159
|
|
|
160
|
|
|
161
|
2148
|
public final List getImportedClasses()
|
162
|
|
{
|
163
|
2148
|
return _importedClasses == null ? EMPTY_LIST : Collections.unmodifiableList( _importedClasses );
|
164
|
|
}
|
165
|
|
|
166
|
|
|
167
|
|
|
168
|
|
|
169
|
|
|
170
|
|
|
171
|
122
|
public final List getImportedPackages()
|
172
|
|
{
|
173
|
122
|
return _importedPackages == null ? EMPTY_LIST : Collections.unmodifiableList( _importedPackages );
|
174
|
|
}
|
175
|
|
|
176
|
60
|
public final List getMethods()
|
177
|
|
{
|
178
|
60
|
return getMethods( false );
|
179
|
|
}
|
180
|
|
|
181
|
0
|
public final List getMethods( Predicate predicate, boolean superclasses )
|
182
|
|
{
|
183
|
0
|
return Collections.unmodifiableList( new ArrayList( CollectionUtils.select( getMethods( superclasses ), predicate ) ) );
|
184
|
|
}
|
185
|
|
|
186
|
0
|
public final List getFields( Predicate predicate, boolean superclasses )
|
187
|
|
{
|
188
|
0
|
return Collections.unmodifiableList( new ArrayList( CollectionUtils.select( getFields( superclasses ), predicate ) ) );
|
189
|
|
}
|
190
|
|
|
191
|
64
|
public final List getMethods( boolean superclasses )
|
192
|
|
{
|
193
|
64
|
return getMembers( superclasses, false );
|
194
|
|
}
|
195
|
|
|
196
|
2
|
public final List getFields( boolean superclasses )
|
197
|
|
{
|
198
|
2
|
return getMembers( superclasses, true );
|
199
|
|
}
|
200
|
|
|
201
|
|
|
202
|
|
|
203
|
|
|
204
|
|
|
205
|
|
|
206
|
56
|
public final List getFields()
|
207
|
|
{
|
208
|
56
|
return _fields == null ? EMPTY_LIST : Collections.unmodifiableList( _fields );
|
209
|
|
}
|
210
|
|
|
211
|
|
|
212
|
|
|
213
|
|
|
214
|
|
|
215
|
|
|
216
|
42
|
public final List getConstructors()
|
217
|
|
{
|
218
|
42
|
return _constructors == null ? EMPTY_LIST : Collections.unmodifiableList( _constructors );
|
219
|
|
}
|
220
|
|
|
221
|
0
|
public final boolean isSubclassOf( String full_qualified_type_name )
|
222
|
|
{
|
223
|
0
|
return isSubclassOf( full_qualified_type_name, true );
|
224
|
|
}
|
225
|
|
|
226
|
2
|
public final boolean isImplementingInterface( String full_qualified_type_name )
|
227
|
|
{
|
228
|
2
|
return isImplementingInterface( full_qualified_type_name, true );
|
229
|
|
}
|
230
|
|
|
231
|
0
|
public String getType()
|
232
|
|
{
|
233
|
0
|
return getQualifiedName() + ".class";
|
234
|
|
}
|
235
|
|
|
236
|
4940
|
public boolean isInner()
|
237
|
|
{
|
238
|
4940
|
boolean hasContainingClass = getContainingClass() != null;
|
239
|
4940
|
return hasContainingClass;
|
240
|
|
}
|
241
|
|
|
242
|
18
|
public boolean isSubclassOf( String full_qualified_type_name, boolean superclasses )
|
243
|
|
{
|
244
|
18
|
XClass superclass = this.getSuperclass();
|
245
|
|
|
246
|
18
|
if( superclass == null )
|
247
|
4
|
return false;
|
248
|
14
|
do
|
249
|
|
{
|
250
|
30
|
if( superclass.getQualifiedName().equals( full_qualified_type_name ) )
|
251
|
4
|
return true;
|
252
|
|
|
253
|
26
|
superclass = superclass.getSuperclass();
|
254
|
26
|
}while ( superclasses == true && superclass != null );
|
255
|
|
|
256
|
10
|
return false;
|
257
|
|
}
|
258
|
|
|
259
|
20
|
public boolean isImplementingInterface( String full_qualified_type_name, boolean superclasses )
|
260
|
|
{
|
261
|
20
|
XClass cur_class = this;
|
262
|
|
|
263
|
20
|
do
|
264
|
|
{
|
265
|
32
|
for( Iterator iterator = cur_class.getInterfaces().iterator(); iterator.hasNext(); )
|
266
|
|
{
|
267
|
112
|
XClass intf = ( XClass ) iterator.next();
|
268
|
|
|
269
|
|
|
270
|
112
|
if( intf.getQualifiedName().equals( full_qualified_type_name ) || intf.isImplementingInterface( full_qualified_type_name, superclasses ) )
|
271
|
16
|
return true;
|
272
|
|
}
|
273
|
|
|
274
|
16
|
cur_class = cur_class.getSuperclass();
|
275
|
16
|
}while ( superclasses == true && cur_class != null );
|
276
|
|
|
277
|
4
|
return false;
|
278
|
|
}
|
279
|
|
|
280
|
852
|
public String getName()
|
281
|
|
{
|
282
|
852
|
return _name;
|
283
|
|
}
|
284
|
|
|
285
|
|
|
286
|
|
|
287
|
|
|
288
|
|
|
289
|
|
|
290
|
13044
|
public String getQualifiedName()
|
291
|
|
{
|
292
|
13044
|
return _qualifiedName;
|
293
|
|
}
|
294
|
|
|
295
|
|
|
296
|
|
|
297
|
|
|
298
|
|
|
299
|
|
|
300
|
294
|
public String getTransformedName()
|
301
|
|
{
|
302
|
294
|
return _transformedName;
|
303
|
|
}
|
304
|
|
|
305
|
|
|
306
|
|
|
307
|
|
|
308
|
|
|
309
|
|
|
310
|
14
|
public String getTransformedQualifiedName()
|
311
|
|
{
|
312
|
14
|
return _transformedQualifiedName;
|
313
|
|
}
|
314
|
|
|
315
|
|
|
316
|
|
|
317
|
|
|
318
|
|
|
319
|
|
|
320
|
|
|
321
|
926
|
public List getInterfaces()
|
322
|
|
{
|
323
|
|
|
324
|
926
|
if( _allInterfaces == null )
|
325
|
|
{
|
326
|
|
|
327
|
248
|
Set allInterfaces = new HashSet();
|
328
|
|
|
329
|
248
|
if( _declaredInterfaces != null )
|
330
|
|
{
|
331
|
126
|
allInterfaces.addAll( _declaredInterfaces );
|
332
|
|
|
333
|
|
|
334
|
126
|
for( Iterator i = _declaredInterfaces.iterator(); i.hasNext(); )
|
335
|
|
{
|
336
|
188
|
XClass intf = ( XClass ) i.next();
|
337
|
|
|
338
|
188
|
allInterfaces.addAll( intf.getInterfaces() );
|
339
|
|
}
|
340
|
|
}
|
341
|
|
|
342
|
|
|
343
|
248
|
XClass superclass = getSuperclass();
|
344
|
|
|
345
|
248
|
while( superclass != null )
|
346
|
|
{
|
347
|
148
|
allInterfaces.addAll( superclass.getInterfaces() );
|
348
|
148
|
superclass = superclass.getSuperclass();
|
349
|
|
}
|
350
|
|
|
351
|
248
|
_allInterfaces = Arrays.asList( allInterfaces.toArray() );
|
352
|
|
}
|
353
|
926
|
return _allInterfaces;
|
354
|
|
}
|
355
|
|
|
356
|
|
|
357
|
|
|
358
|
|
|
359
|
|
|
360
|
|
|
361
|
|
|
362
|
|
|
363
|
|
|
364
|
12
|
public Collection getDeclaredInterfaces()
|
365
|
|
{
|
366
|
12
|
return _declaredInterfaces != null ? _declaredInterfaces : EMPTY_LIST;
|
367
|
|
}
|
368
|
|
|
369
|
|
|
370
|
|
|
371
|
|
|
372
|
|
|
373
|
|
|
374
|
1818
|
public XClass getSuperclass()
|
375
|
|
{
|
376
|
1818
|
return _superclass;
|
377
|
|
}
|
378
|
|
|
379
|
0
|
public List getDirectSubclasses()
|
380
|
|
{
|
381
|
0
|
if( isInterface() )
|
382
|
|
{
|
383
|
0
|
throw new UnsupportedOperationException( "Should never ask for directSubclasses of interfaces. Ask for implementingClasses or extendingInterfaces instead" );
|
384
|
|
}
|
385
|
0
|
if( _directSubclasses == null )
|
386
|
|
{
|
387
|
0
|
_directSubclasses = new LinkedList();
|
388
|
|
|
389
|
0
|
for( Iterator classes = getXJavaDoc().getSourceClasses().iterator(); classes.hasNext(); )
|
390
|
|
{
|
391
|
0
|
XClass clazz = (XClass) classes.next();
|
392
|
|
|
393
|
0
|
if( clazz.getSuperclass() == this )
|
394
|
|
{
|
395
|
0
|
_directSubclasses.add( clazz );
|
396
|
|
}
|
397
|
|
}
|
398
|
|
}
|
399
|
0
|
return Collections.unmodifiableList( _directSubclasses );
|
400
|
|
}
|
401
|
|
|
402
|
0
|
public List getAllSubclasses()
|
403
|
|
{
|
404
|
0
|
if( isInterface() )
|
405
|
|
{
|
406
|
0
|
throw new UnsupportedOperationException( "Should never ask for allSubclasses of interfaces. Ask for implementingClasses or extendingInterfaces instead" );
|
407
|
|
}
|
408
|
0
|
if( _allSubclasses == null )
|
409
|
|
{
|
410
|
0
|
_allSubclasses = new LinkedList();
|
411
|
|
|
412
|
0
|
for( Iterator classes = getXJavaDoc().getSourceClasses().iterator(); classes.hasNext(); )
|
413
|
|
{
|
414
|
0
|
XClass clazz = (XClass) classes.next();
|
415
|
|
|
416
|
0
|
while( clazz != null )
|
417
|
|
{
|
418
|
0
|
if( clazz.getSuperclass() == this )
|
419
|
|
{
|
420
|
0
|
_allSubclasses.add( clazz );
|
421
|
0
|
break;
|
422
|
|
}
|
423
|
0
|
clazz = clazz.getSuperclass();
|
424
|
|
}
|
425
|
|
}
|
426
|
|
}
|
427
|
0
|
return Collections.unmodifiableList( _allSubclasses );
|
428
|
|
}
|
429
|
|
|
430
|
0
|
public List getImplementingClasses()
|
431
|
|
{
|
432
|
0
|
if( !isInterface() )
|
433
|
|
{
|
434
|
0
|
throw new UnsupportedOperationException( "Should never ask for implementingClasses of classes. Ask for directSubclasses or allSubclasses instead" );
|
435
|
|
}
|
436
|
0
|
if( _implementingClasses == null )
|
437
|
|
{
|
438
|
0
|
_implementingClasses = new LinkedList();
|
439
|
|
|
440
|
0
|
for( Iterator classes = getXJavaDoc().getSourceClasses().iterator(); classes.hasNext(); )
|
441
|
|
{
|
442
|
0
|
XClass clazz = (XClass) classes.next();
|
443
|
|
|
444
|
0
|
if( !clazz.isInterface() )
|
445
|
|
{
|
446
|
0
|
Collection interfaces = clazz.getInterfaces();
|
447
|
|
|
448
|
0
|
if( interfaces.contains( this ) )
|
449
|
|
{
|
450
|
0
|
_implementingClasses.add( clazz );
|
451
|
|
}
|
452
|
|
}
|
453
|
|
}
|
454
|
|
}
|
455
|
0
|
return Collections.unmodifiableList( _implementingClasses );
|
456
|
|
}
|
457
|
|
|
458
|
0
|
public List getExtendingInterfaces()
|
459
|
|
{
|
460
|
0
|
if( !isInterface() )
|
461
|
|
{
|
462
|
0
|
throw new UnsupportedOperationException( "Should never ask for extendingInterfaces of classes. Ask for directSubclasses or allSubclasses instead" );
|
463
|
|
}
|
464
|
0
|
if( _extendingInterfaces == null )
|
465
|
|
{
|
466
|
0
|
_extendingInterfaces = new LinkedList();
|
467
|
|
|
468
|
0
|
for( Iterator classes = getXJavaDoc().getSourceClasses().iterator(); classes.hasNext(); )
|
469
|
|
{
|
470
|
0
|
XClass clazz = (XClass) classes.next();
|
471
|
|
|
472
|
0
|
if( clazz.isInterface() )
|
473
|
|
{
|
474
|
0
|
Collection interfaces = clazz.getInterfaces();
|
475
|
|
|
476
|
0
|
if( interfaces.contains( this ) )
|
477
|
|
{
|
478
|
0
|
_extendingInterfaces.add( clazz );
|
479
|
|
}
|
480
|
|
}
|
481
|
|
}
|
482
|
|
}
|
483
|
0
|
return Collections.unmodifiableList( _extendingInterfaces );
|
484
|
|
}
|
485
|
|
|
486
|
|
|
487
|
|
|
488
|
|
|
489
|
|
|
490
|
|
|
491
|
2872
|
public XPackage getContainingPackage()
|
492
|
|
{
|
493
|
2872
|
if( _containingPackage == null )
|
494
|
|
{
|
495
|
60
|
_containingPackage = getXJavaDoc().addPackageMaybe( "" );
|
496
|
|
}
|
497
|
2872
|
return _containingPackage;
|
498
|
|
}
|
499
|
|
|
500
|
|
|
501
|
|
|
502
|
|
|
503
|
|
|
504
|
|
|
505
|
5528
|
public List getInnerClasses()
|
506
|
|
{
|
507
|
5528
|
return _innerClasses == null ? EMPTY_LIST : Collections.unmodifiableList( _innerClasses );
|
508
|
|
}
|
509
|
|
|
510
|
|
|
511
|
|
|
512
|
|
|
513
|
|
|
514
|
0
|
public XProgramElement getSuperElement()
|
515
|
|
{
|
516
|
0
|
return getSuperclass();
|
517
|
|
}
|
518
|
|
|
519
|
0
|
public List getSuperInterfaceElements()
|
520
|
|
{
|
521
|
0
|
return getInterfaces();
|
522
|
|
}
|
523
|
|
|
524
|
8
|
public boolean isAnonymous()
|
525
|
|
{
|
526
|
8
|
return _isAnonymous;
|
527
|
|
}
|
528
|
|
|
529
|
0
|
public List getMethodTags( String tagName, boolean superclasses )
|
530
|
|
{
|
531
|
0
|
Set result = new HashSet();
|
532
|
|
|
533
|
0
|
for( Iterator methods = getMethods( superclasses ).iterator(); methods.hasNext(); )
|
534
|
|
{
|
535
|
0
|
XMethod method = (XMethod) methods.next();
|
536
|
|
|
537
|
0
|
result.addAll( method.getDoc().getTags( tagName, superclasses ) );
|
538
|
|
}
|
539
|
0
|
return new ArrayList( result );
|
540
|
|
}
|
541
|
|
|
542
|
0
|
public final int compareTo( Object o )
|
543
|
|
{
|
544
|
0
|
XClass other = ( XClass ) o;
|
545
|
|
|
546
|
0
|
return getQualifiedName().compareTo( other.getQualifiedName() );
|
547
|
|
}
|
548
|
|
|
549
|
0
|
public final String toString()
|
550
|
|
{
|
551
|
0
|
return getQualifiedName();
|
552
|
|
}
|
553
|
|
|
554
|
0
|
public String save( File rootDir ) throws IOException
|
555
|
|
{
|
556
|
0
|
throw new UnsupportedOperationException( getClass().getName() );
|
557
|
|
}
|
558
|
|
|
559
|
2592
|
public boolean equals( Object obj )
|
560
|
|
{
|
561
|
2592
|
if( !( obj instanceof XClass ) )
|
562
|
|
{
|
563
|
0
|
return false;
|
564
|
|
}
|
565
|
|
|
566
|
2592
|
XClass other_clazz = ( XClass ) obj;
|
567
|
|
|
568
|
2592
|
return getQualifiedName().equals( other_clazz.getQualifiedName() );
|
569
|
|
}
|
570
|
|
|
571
|
716
|
public int hashCode()
|
572
|
|
{
|
573
|
716
|
if( _hash == Integer.MIN_VALUE )
|
574
|
|
{
|
575
|
146
|
_hash += getQualifiedName().hashCode();
|
576
|
|
}
|
577
|
716
|
return _hash;
|
578
|
|
}
|
579
|
|
|
580
|
220
|
public XClass qualify( String unqualifiedClassName )
|
581
|
|
{
|
582
|
220
|
return getXJavaDoc().getXClass( unqualifiedClassName );
|
583
|
|
}
|
584
|
|
|
585
|
0
|
public long lastModified()
|
586
|
|
{
|
587
|
0
|
return Long.MIN_VALUE;
|
588
|
|
}
|
589
|
|
|
590
|
|
|
591
|
|
|
592
|
|
|
593
|
24
|
public void updateDoc()
|
594
|
|
{
|
595
|
24
|
super.updateDoc();
|
596
|
|
|
597
|
|
|
598
|
24
|
for( Iterator i = getFields().iterator(); i.hasNext(); )
|
599
|
|
{
|
600
|
32
|
( ( XField ) i.next() ).updateDoc();
|
601
|
|
}
|
602
|
24
|
for( Iterator i = getMethods().iterator(); i.hasNext(); )
|
603
|
|
{
|
604
|
72
|
( ( XMethod ) i.next() ).updateDoc();
|
605
|
|
}
|
606
|
24
|
for( Iterator i = getConstructors().iterator(); i.hasNext(); )
|
607
|
|
{
|
608
|
24
|
( ( XConstructor ) i.next() ).updateDoc();
|
609
|
|
}
|
610
|
|
|
611
|
24
|
for( Iterator i = getInnerClasses().iterator(); i.hasNext(); )
|
612
|
|
{
|
613
|
16
|
( ( XClass ) i.next() ).updateDoc();
|
614
|
|
}
|
615
|
|
}
|
616
|
|
|
617
|
2278
|
protected final boolean hasImportedClasses()
|
618
|
|
{
|
619
|
2278
|
return _importedClasses != null;
|
620
|
|
}
|
621
|
|
|
622
|
588
|
protected final boolean hasInnerClasses()
|
623
|
|
{
|
624
|
588
|
return _innerClasses != null;
|
625
|
|
}
|
626
|
|
|
627
|
122
|
protected final boolean hasImportedPackages()
|
628
|
|
{
|
629
|
122
|
return _importedPackages != null;
|
630
|
|
}
|
631
|
|
|
632
|
252
|
protected void addInnerClass( XClass clazz )
|
633
|
|
{
|
634
|
252
|
if( _innerClasses == null )
|
635
|
|
{
|
636
|
138
|
_innerClasses = new LinkedList();
|
637
|
|
}
|
638
|
252
|
_innerClasses.add( clazz );
|
639
|
|
}
|
640
|
|
|
641
|
|
|
642
|
|
|
643
|
|
|
644
|
|
|
645
|
|
|
646
|
|
|
647
|
3308
|
final void setQualifiedName( String qualifiedName )
|
648
|
|
{
|
649
|
3308
|
if( qualifiedName == null )
|
650
|
|
{
|
651
|
0
|
throw new IllegalArgumentException( "qualifiedName can't be null!" );
|
652
|
|
}
|
653
|
3308
|
if( qualifiedName.startsWith( "." ) )
|
654
|
|
{
|
655
|
0
|
throw new IllegalArgumentException( "qualifiedName can't start with a dot! " + qualifiedName );
|
656
|
|
}
|
657
|
3308
|
if( _qualifiedName != null )
|
658
|
|
{
|
659
|
0
|
throw new IllegalStateException( "Setting qualified name " + qualifiedName + " from " + _qualifiedName + " 2nd time!" );
|
660
|
|
}
|
661
|
3308
|
if( isInner() )
|
662
|
|
{
|
663
|
0
|
throw new IllegalStateException( "Don't call setQualifiedName for inner classes. Call setName instead. (" + qualifiedName + ")" );
|
664
|
|
}
|
665
|
3308
|
_qualifiedName = qualifiedName;
|
666
|
3308
|
_transformedQualifiedName = qualifiedName;
|
667
|
3308
|
_name = Util.classNameFromQualifiedClassName( _qualifiedName );
|
668
|
3308
|
_transformedName = _name;
|
669
|
|
}
|
670
|
|
|
671
|
|
|
672
|
|
|
673
|
|
|
674
|
|
|
675
|
|
|
676
|
|
|
677
|
|
|
678
|
2288
|
final void setContainingPackage( String containingPackage )
|
679
|
|
{
|
680
|
2288
|
_containingPackage = getXJavaDoc().addPackageMaybe( containingPackage );
|
681
|
|
}
|
682
|
|
|
683
|
|
|
684
|
|
|
685
|
|
|
686
|
|
|
687
|
|
|
688
|
944
|
final void setInterface( boolean flag )
|
689
|
|
{
|
690
|
944
|
_isInterface = flag;
|
691
|
944
|
_superclass = null;
|
692
|
|
}
|
693
|
|
|
694
|
|
|
695
|
|
|
696
|
|
|
697
|
|
|
698
|
|
|
699
|
636
|
final void setSuperclass( String superclass )
|
700
|
|
{
|
701
|
636
|
_superclass = qualify( superclass );
|
702
|
|
|
703
|
|
|
704
|
|
|
705
|
|
|
706
|
|
|
707
|
|
|
708
|
|
|
709
|
|
|
710
|
|
|
711
|
|
|
712
|
|
|
713
|
|
}
|
714
|
|
|
715
|
|
|
716
|
|
|
717
|
|
|
718
|
|
|
719
|
|
|
720
|
|
|
721
|
40
|
final void setRealised( String clazz )
|
722
|
|
{
|
723
|
40
|
_isAnonymous = true;
|
724
|
|
|
725
|
40
|
XClass realised = qualify( clazz );
|
726
|
|
|
727
|
40
|
if( realised.isInterface() )
|
728
|
|
{
|
729
|
|
|
730
|
20
|
addInterface( clazz );
|
731
|
20
|
setSuperclass( "java.lang.Object" );
|
732
|
|
}
|
733
|
|
else
|
734
|
|
{
|
735
|
|
|
736
|
20
|
setSuperclass( clazz );
|
737
|
|
}
|
738
|
|
}
|
739
|
|
|
740
|
|
|
741
|
|
|
742
|
|
|
743
|
|
|
744
|
|
|
745
|
|
|
746
|
280
|
void setName( String name )
|
747
|
|
{
|
748
|
280
|
if( !isInner() )
|
749
|
|
{
|
750
|
0
|
throw new IllegalStateException( "Don't call setName for outer classes. Call setQualifiedName instead. (" + name + ")" );
|
751
|
|
}
|
752
|
280
|
if( name == null )
|
753
|
|
{
|
754
|
0
|
throw new IllegalStateException( "name can't be null!" );
|
755
|
|
}
|
756
|
|
|
757
|
|
|
758
|
|
|
759
|
280
|
String realName = getContainingClass().getName() + '.' + name;
|
760
|
|
|
761
|
|
|
762
|
|
|
763
|
280
|
String transformedName = getContainingClass().getTransformedName() + '$' + name;
|
764
|
|
|
765
|
280
|
if( _name != null && !_name.equals( realName ) )
|
766
|
|
{
|
767
|
0
|
throw new IllegalStateException( "Setting name 2nd time with a different value! 1st time: '" + _name + "', 2nd time: '" + name + "'" );
|
768
|
|
}
|
769
|
280
|
_name = realName;
|
770
|
280
|
_transformedName = transformedName;
|
771
|
|
|
772
|
280
|
if( getContainingPackage().getName().equals( "" ) )
|
773
|
|
{
|
774
|
120
|
_qualifiedName = _name;
|
775
|
120
|
_transformedQualifiedName = _transformedName;
|
776
|
|
}
|
777
|
|
else
|
778
|
|
{
|
779
|
160
|
_qualifiedName = getContainingPackage().getName() + '.' + _name;
|
780
|
160
|
_transformedQualifiedName = getContainingPackage().getName() + '.' + _transformedName;
|
781
|
|
}
|
782
|
280
|
if( _qualifiedName.startsWith( "." ) )
|
783
|
|
{
|
784
|
0
|
throw new IllegalStateException( "qualifiedName can't start with a dot! " + _qualifiedName );
|
785
|
|
}
|
786
|
|
}
|
787
|
|
|
788
|
|
|
789
|
|
|
790
|
|
|
791
|
|
|
792
|
|
|
793
|
|
|
794
|
722
|
final void addInterface( String interfaceName )
|
795
|
|
{
|
796
|
722
|
if( _declaredInterfaces == null )
|
797
|
|
{
|
798
|
552
|
_declaredInterfaces = new LinkedList();
|
799
|
|
}
|
800
|
|
|
801
|
722
|
XClass qualifiedInterface = qualify( interfaceName );
|
802
|
|
|
803
|
722
|
_declaredInterfaces.add( qualifiedInterface );
|
804
|
|
}
|
805
|
|
|
806
|
732
|
void resolveImportedClasses()
|
807
|
|
{
|
808
|
732
|
if( _importedClassNames == null )
|
809
|
|
{
|
810
|
|
|
811
|
232
|
return;
|
812
|
|
}
|
813
|
|
|
814
|
|
|
815
|
500
|
if( _importedClasses == null )
|
816
|
|
{
|
817
|
500
|
_importedClasses = new ArrayList( _importedClassNames.size() );
|
818
|
500
|
for( Iterator i = _importedClassNames.iterator(); i.hasNext(); )
|
819
|
|
{
|
820
|
1558
|
String importedClassName = ( String ) i.next();
|
821
|
|
|
822
|
1558
|
_importedClasses.add( qualify( importedClassName ) );
|
823
|
|
}
|
824
|
|
}
|
825
|
|
}
|
826
|
|
|
827
|
|
|
828
|
|
|
829
|
|
|
830
|
|
|
831
|
1558
|
void addImportedClass( String importedClass )
|
832
|
|
{
|
833
|
1558
|
if( _importedClassNames == null )
|
834
|
|
{
|
835
|
500
|
_importedClassNames = new LinkedList();
|
836
|
|
}
|
837
|
1558
|
_importedClassNames.add( importedClass );
|
838
|
|
}
|
839
|
|
|
840
|
|
|
841
|
|
|
842
|
|
|
843
|
|
|
844
|
264
|
void addImportedPackage( String importedPackage )
|
845
|
|
{
|
846
|
264
|
if( _importedPackages == null )
|
847
|
|
{
|
848
|
194
|
_importedPackages = new LinkedList();
|
849
|
|
}
|
850
|
|
|
851
|
264
|
XPackage pakkage = getXJavaDoc().addPackageMaybe( importedPackage );
|
852
|
|
|
853
|
264
|
_importedPackages.add( pakkage );
|
854
|
|
}
|
855
|
|
|
856
|
|
|
857
|
|
|
858
|
|
|
859
|
|
|
860
|
|
|
861
|
546
|
void addConstructor( XConstructor constructor )
|
862
|
|
{
|
863
|
546
|
validate( constructor );
|
864
|
546
|
if( _constructors == null )
|
865
|
|
{
|
866
|
296
|
_constructors = new LinkedList();
|
867
|
|
}
|
868
|
546
|
_constructors.add( constructor );
|
869
|
|
}
|
870
|
|
|
871
|
|
|
872
|
|
|
873
|
|
|
874
|
|
|
875
|
|
|
876
|
2106
|
void addField( XField field )
|
877
|
|
{
|
878
|
2106
|
validate( field );
|
879
|
2106
|
if( _fields == null )
|
880
|
|
{
|
881
|
426
|
_fields = new LinkedList();
|
882
|
|
}
|
883
|
2106
|
_fields.add( field );
|
884
|
|
}
|
885
|
|
|
886
|
|
|
887
|
|
|
888
|
|
|
889
|
|
|
890
|
8712
|
void addMethod( XMethod method )
|
891
|
|
{
|
892
|
8712
|
validate( method );
|
893
|
8712
|
if( _methods == null )
|
894
|
|
{
|
895
|
790
|
_methods = new LinkedList();
|
896
|
|
}
|
897
|
|
|
898
|
8712
|
_methods.add( method );
|
899
|
|
}
|
900
|
|
|
901
|
0
|
void reset()
|
902
|
|
{
|
903
|
0
|
super.reset();
|
904
|
|
|
905
|
0
|
_declaredInterfaces = null;
|
906
|
0
|
_allInterfaces = null;
|
907
|
0
|
_importedClasses = null;
|
908
|
0
|
_importedClassNames = null;
|
909
|
0
|
_importedPackages = null;
|
910
|
0
|
_constructors = null;
|
911
|
0
|
_namedConstructors = null;
|
912
|
0
|
_methods = null;
|
913
|
0
|
_namedMethods = null;
|
914
|
0
|
_fields = null;
|
915
|
0
|
_innerClasses = null;
|
916
|
|
}
|
917
|
|
|
918
|
|
|
919
|
|
|
920
|
|
|
921
|
|
|
922
|
|
|
923
|
|
|
924
|
|
|
925
|
258
|
private final List getMembers( boolean superclasses, boolean forFields )
|
926
|
|
{
|
927
|
258
|
if( !superclasses )
|
928
|
|
{
|
929
|
228
|
if( forFields )
|
930
|
|
{
|
931
|
56
|
return _fields == null ? EMPTY_LIST : Collections.unmodifiableList( _fields );
|
932
|
|
}
|
933
|
|
else
|
934
|
|
{
|
935
|
172
|
return _methods == null ? EMPTY_LIST : Collections.unmodifiableList( _methods );
|
936
|
|
}
|
937
|
|
}
|
938
|
|
else
|
939
|
|
{
|
940
|
|
|
941
|
30
|
LinkedList members = new LinkedList();
|
942
|
|
|
943
|
|
|
944
|
30
|
if( forFields )
|
945
|
|
{
|
946
|
10
|
if( _fields != null )
|
947
|
|
{
|
948
|
4
|
members.addAll( _fields );
|
949
|
|
}
|
950
|
|
}
|
951
|
|
else
|
952
|
|
{
|
953
|
20
|
if( _methods != null )
|
954
|
|
{
|
955
|
8
|
members.addAll( _methods );
|
956
|
|
}
|
957
|
|
}
|
958
|
|
|
959
|
|
|
960
|
30
|
AbstractClass superclass = ( AbstractClass ) getSuperclass();
|
961
|
|
|
962
|
30
|
if( superclass != null )
|
963
|
|
{
|
964
|
24
|
Collection superMembers = superclass.getMembers( true, forFields );
|
965
|
|
|
966
|
|
|
967
|
|
|
968
|
24
|
for( Iterator m = superMembers.iterator(); m.hasNext(); )
|
969
|
|
{
|
970
|
34
|
XMember superMember = ( XMember ) m.next();
|
971
|
|
|
972
|
34
|
if( !superMember.isPrivate() && !members.contains( superMember ) )
|
973
|
|
{
|
974
|
24
|
members.add( superMember );
|
975
|
|
}
|
976
|
|
}
|
977
|
|
}
|
978
|
|
|
979
|
|
|
980
|
30
|
Collection interfaces = getInterfaces();
|
981
|
|
|
982
|
30
|
for( Iterator i = interfaces.iterator(); i.hasNext(); )
|
983
|
|
{
|
984
|
168
|
AbstractClass interfaze = ( AbstractClass ) i.next();
|
985
|
|
|
986
|
|
|
987
|
168
|
Collection interfaceMembers = interfaze.getMembers( false, forFields );
|
988
|
|
|
989
|
|
|
990
|
|
|
991
|
|
|
992
|
168
|
for( Iterator m = interfaceMembers.iterator(); m.hasNext(); )
|
993
|
|
{
|
994
|
0
|
XMember interfaceMember = ( XMember ) m.next();
|
995
|
|
|
996
|
0
|
if( !members.contains( interfaceMember ) )
|
997
|
|
{
|
998
|
0
|
members.add( interfaceMember );
|
999
|
|
}
|
1000
|
|
}
|
1001
|
|
}
|
1002
|
|
|
1003
|
30
|
return Collections.unmodifiableList( members );
|
1004
|
|
}
|
1005
|
|
}
|
1006
|
|
|
1007
|
11364
|
private final void validate( XMember member ) throws IllegalStateException
|
1008
|
|
{
|
1009
|
11364
|
if( member.getName() == null )
|
1010
|
|
{
|
1011
|
0
|
throw new IllegalStateException( "Trying to add a member with no name:" + member.getClass().getName() + ":" + hashCode() );
|
1012
|
|
}
|
1013
|
|
}
|
1014
|
|
|
1015
|
2650
|
private void initializeNamedMethodsHashMap()
|
1016
|
|
{
|
1017
|
2650
|
if( _namedMethods != null || _methods == null )
|
1018
|
2580
|
return;
|
1019
|
|
|
1020
|
70
|
_namedMethods = new HashMap();
|
1021
|
|
|
1022
|
70
|
for( int i = 0; i < _methods.size(); i++ )
|
1023
|
|
{
|
1024
|
842
|
XMethod method = ( XMethod ) _methods.get( i );
|
1025
|
|
|
1026
|
842
|
_namedMethods.put( method.getNameWithSignature( false ), method );
|
1027
|
|
}
|
1028
|
|
}
|
1029
|
|
|
1030
|
0
|
private void initializeNamedConstructorsHashMap()
|
1031
|
|
{
|
1032
|
0
|
if( _namedConstructors != null || _constructors == null )
|
1033
|
0
|
return;
|
1034
|
|
|
1035
|
0
|
_namedConstructors = new HashMap();
|
1036
|
|
|
1037
|
0
|
for( int i = 0; i < _constructors.size(); i++ )
|
1038
|
|
{
|
1039
|
0
|
XConstructor constructor = ( XConstructor ) _constructors.get( i );
|
1040
|
|
|
1041
|
0
|
_namedConstructors.put( constructor.getNameWithSignature( false ), constructor );
|
1042
|
|
}
|
1043
|
|
}
|
1044
|
|
}
|
1045
|
|
|
1046
|
|
|