| 1 |
// |
|---|
| 2 |
// =========================================================================== |
|---|
| 3 |
// |
|---|
| 4 |
// Title: ClassDoc.java |
|---|
| 5 |
// Description: Somehwat similar to javadoc |
|---|
| 6 |
// Author: Raphal Szwarc <zoe (underscore) info (at) mac (dot) com> |
|---|
| 7 |
// Creation Date: Thu Dec 09 2004 |
|---|
| 8 |
// Legal: Copyright (C) 2004 Raphal Szwarc |
|---|
| 9 |
// |
|---|
| 10 |
// This software is provided 'as-is', without any express or implied warranty. |
|---|
| 11 |
// In no event will the author be held liable for any damages arising from |
|---|
| 12 |
// the use of this software. |
|---|
| 13 |
// |
|---|
| 14 |
// Permission is granted to anyone to use this software for any purpose, |
|---|
| 15 |
// including commercial applications, and to alter it and |
|---|
| 16 |
// redistribute it freely, subject to the following restrictions: |
|---|
| 17 |
// |
|---|
| 18 |
// 1. The origin of this software must not be misrepresented; |
|---|
| 19 |
// you must not claim that you wrote the original software. |
|---|
| 20 |
// If you use this software in a product, an acknowledgment |
|---|
| 21 |
// in the product documentation would be appreciated but is not required. |
|---|
| 22 |
// |
|---|
| 23 |
// 2. Altered source versions must be plainly marked as such, |
|---|
| 24 |
// and must not be misrepresented as being the original software. |
|---|
| 25 |
// |
|---|
| 26 |
// 3. This notice may not be removed or altered from any source distribution. |
|---|
| 27 |
// |
|---|
| 28 |
// --------------------------------------------------------------------------- |
|---|
| 29 |
// |
|---|
| 30 |
|
|---|
| 31 |
package alt.dev.dydoc; |
|---|
| 32 |
|
|---|
| 33 |
import java.io.File; |
|---|
| 34 |
|
|---|
| 35 |
import java.lang.reflect.Constructor; |
|---|
| 36 |
import java.lang.reflect.Field; |
|---|
| 37 |
import java.lang.reflect.Method; |
|---|
| 38 |
import java.lang.reflect.Modifier; |
|---|
| 39 |
|
|---|
| 40 |
import java.text.NumberFormat; |
|---|
| 41 |
|
|---|
| 42 |
import java.util.Arrays; |
|---|
| 43 |
import java.util.Collections; |
|---|
| 44 |
import java.util.Collection; |
|---|
| 45 |
import java.util.List; |
|---|
| 46 |
import java.util.Map; |
|---|
| 47 |
import java.util.HashMap; |
|---|
| 48 |
import java.util.Iterator; |
|---|
| 49 |
import java.util.Locale; |
|---|
| 50 |
|
|---|
| 51 |
import alt.dev.pl.PLReader; |
|---|
| 52 |
|
|---|
| 53 |
import alt.dev.szapp.SZComponent; |
|---|
| 54 |
import alt.dev.szapp.SZContext; |
|---|
| 55 |
import alt.dev.szapp.SZTemplate; |
|---|
| 56 |
import alt.dev.szapp.SZSpanString; |
|---|
| 57 |
import alt.dev.szapp.SZLink; |
|---|
| 58 |
import alt.dev.szapp.SZHTMLString; |
|---|
| 59 |
import alt.dev.szapp.SZURIEncoder; |
|---|
| 60 |
|
|---|
| 61 |
import alt.dev.szfoundation.SZString; |
|---|
| 62 |
import alt.dev.szfoundation.SZLog; |
|---|
| 63 |
|
|---|
| 64 |
public class ClassDoc extends Doc |
|---|
| 65 |
{ |
|---|
| 66 |
|
|---|
| 67 |
// =========================================================================== |
|---|
| 68 |
// Constant(s) |
|---|
| 69 |
// --------------------------------------------------------------------------- |
|---|
| 70 |
|
|---|
| 71 |
// =========================================================================== |
|---|
| 72 |
// Class variable(s) |
|---|
| 73 |
// --------------------------------------------------------------------------- |
|---|
| 74 |
|
|---|
| 75 |
// =========================================================================== |
|---|
| 76 |
// Instance variable(s) |
|---|
| 77 |
// --------------------------------------------------------------------------- |
|---|
| 78 |
|
|---|
| 79 |
private Class _value = null; |
|---|
| 80 |
private Collection _values = null; |
|---|
| 81 |
private Map _valueProperties = null; |
|---|
| 82 |
private Collection _interfaces = null; |
|---|
| 83 |
private Collection _classVariables = null; |
|---|
| 84 |
private Collection _instanceVariables = null; |
|---|
| 85 |
private Collection _constructors = null; |
|---|
| 86 |
private Collection _classMethods = null; |
|---|
| 87 |
private Collection _instanceMethods = null; |
|---|
| 88 |
private Collection _knownClasses = null; |
|---|
| 89 |
|
|---|
| 90 |
// =========================================================================== |
|---|
| 91 |
// Constructor method(s) |
|---|
| 92 |
// --------------------------------------------------------------------------- |
|---|
| 93 |
|
|---|
| 94 |
protected ClassDoc(final SZContext aContext, final SZComponent aParent, final Map someBindings) |
|---|
| 95 |
{ |
|---|
| 96 |
super( aContext, aParent, someBindings ); |
|---|
| 97 |
} |
|---|
| 98 |
|
|---|
| 99 |
// =========================================================================== |
|---|
| 100 |
// Class method(s) |
|---|
| 101 |
// --------------------------------------------------------------------------- |
|---|
| 102 |
|
|---|
| 103 |
public static SZComponent linkForClassInComponent(final Class aClass, final SZComponent aComponent) |
|---|
| 104 |
{ |
|---|
| 105 |
if ( aClass != null ) |
|---|
| 106 |
{ |
|---|
| 107 |
if ( aComponent != null ) |
|---|
| 108 |
{ |
|---|
| 109 |
Map someBindings = new HashMap(); |
|---|
| 110 |
someBindings.put( "value", ClassInfo.nameForClass( aClass ) ); |
|---|
| 111 |
someBindings.put( "description", ClassInfo.nameForClass( aClass ) ); |
|---|
| 112 |
someBindings.put( "altDescription", ClassInfo.altNameForClass( aClass ) ); |
|---|
| 113 |
someBindings.put( "length", new Integer( 0 ) ); |
|---|
| 114 |
Class aLocalClass = aClass; |
|---|
| 115 |
SZComponent aLink = null; |
|---|
| 116 |
|
|---|
| 117 |
while ( aLocalClass.isArray() == true ) |
|---|
| 118 |
{ |
|---|
| 119 |
aLocalClass = aLocalClass.getComponentType(); |
|---|
| 120 |
} |
|---|
| 121 |
|
|---|
| 122 |
someBindings.put( "path", ClassInfo.nameForClass( aLocalClass ) + ".cls.html" ); |
|---|
| 123 |
|
|---|
| 124 |
if ( aLocalClass.isPrimitive() == true ) |
|---|
| 125 |
{ |
|---|
| 126 |
aLink = new SZHTMLString( aComponent.context(), aComponent, someBindings ); |
|---|
| 127 |
} |
|---|
| 128 |
else |
|---|
| 129 |
{ |
|---|
| 130 |
if ( ( aLocalClass.isInterface() == false ) && |
|---|
| 131 |
( Modifier.isAbstract( aLocalClass.getModifiers() ) == true ) ) |
|---|
| 132 |
{ |
|---|
| 133 |
someBindings.put( "isItalic", Boolean.TRUE ); |
|---|
| 134 |
} |
|---|
| 135 |
|
|---|
| 136 |
aLink = new SZLink( aComponent.context(), aComponent, someBindings ); |
|---|
| 137 |
} |
|---|
| 138 |
|
|---|
| 139 |
return aLink; |
|---|
| 140 |
} |
|---|
| 141 |
|
|---|
| 142 |
throw new IllegalArgumentException( "ClassDoc.linkForClassInComponent: null component" ); |
|---|
| 143 |
} |
|---|
| 144 |
|
|---|
| 145 |
throw new IllegalArgumentException( "ClassDoc.linkForClassInComponent: null class" ); |
|---|
| 146 |
} |
|---|
| 147 |
|
|---|
| 148 |
public static SZComponent altLinkForClassInComponent(final Class aClass, final SZComponent aComponent) |
|---|
| 149 |
{ |
|---|
| 150 |
if ( aClass != null ) |
|---|
| 151 |
{ |
|---|
| 152 |
if ( aComponent != null ) |
|---|
| 153 |
{ |
|---|
| 154 |
Map someBindings = new HashMap(); |
|---|
| 155 |
someBindings.put( "value", ClassInfo.altNameForClass( aClass ) ); |
|---|
| 156 |
someBindings.put( "description", ClassInfo.altNameForClass( aClass ) ); |
|---|
| 157 |
someBindings.put( "altDescription", ClassInfo.nameForClass( aClass ) ); |
|---|
| 158 |
someBindings.put( "length", new Integer( 0 ) ); |
|---|
| 159 |
Class aLocalClass = aClass; |
|---|
| 160 |
SZComponent aLink = null; |
|---|
| 161 |
|
|---|
| 162 |
while ( aLocalClass.isArray() == true ) |
|---|
| 163 |
{ |
|---|
| 164 |
aLocalClass = aLocalClass.getComponentType(); |
|---|
| 165 |
} |
|---|
| 166 |
|
|---|
| 167 |
someBindings.put( "path", ClassInfo.nameForClass( aLocalClass ) + ".cls.html" ); |
|---|
| 168 |
|
|---|
| 169 |
if ( aLocalClass.isPrimitive() == true ) |
|---|
| 170 |
{ |
|---|
| 171 |
aLink = new SZHTMLString( aComponent.context(), aComponent, someBindings ); |
|---|
| 172 |
} |
|---|
| 173 |
else |
|---|
| 174 |
{ |
|---|
| 175 |
if ( ( aLocalClass.isInterface() == false ) && |
|---|
| 176 |
( Modifier.isAbstract( aLocalClass.getModifiers() ) == true ) ) |
|---|
| 177 |
{ |
|---|
| 178 |
someBindings.put( "isItalic", Boolean.TRUE ); |
|---|
| 179 |
} |
|---|
| 180 |
|
|---|
| 181 |
aLink = new SZLink( aComponent.context(), aComponent, someBindings ); |
|---|
| 182 |
} |
|---|
| 183 |
|
|---|
| 184 |
return aLink; |
|---|
| 185 |
} |
|---|
| 186 |
|
|---|
| 187 |
throw new IllegalArgumentException( "ClassDoc.linkForClassInComponent: null component" ); |
|---|
| 188 |
} |
|---|
| 189 |
|
|---|
| 190 |
throw new IllegalArgumentException( "ClassDoc.linkForClassInComponent: null class" ); |
|---|
| 191 |
} |
|---|
| 192 |
|
|---|
| 193 |
// =========================================================================== |
|---|
| 194 |
// Instance method(s) |
|---|
| 195 |
// --------------------------------------------------------------------------- |
|---|
| 196 |
|
|---|
| 197 |
protected Class value() |
|---|
| 198 |
{ |
|---|
| 199 |
if ( _value == null ) |
|---|
| 200 |
{ |
|---|
| 201 |
_value = (Class) this.valueForBinding( "value" ); |
|---|
| 202 |
} |
|---|
| 203 |
|
|---|
| 204 |
return _value; |
|---|
| 205 |
} |
|---|
| 206 |
|
|---|
| 207 |
protected Collection values() |
|---|
| 208 |
{ |
|---|
| 209 |
if ( _values == null ) |
|---|
| 210 |
{ |
|---|
| 211 |
_values = (Collection) this.valueForBinding( "values" ); |
|---|
| 212 |
} |
|---|
| 213 |
|
|---|
| 214 |
return _values; |
|---|
| 215 |
} |
|---|
| 216 |
|
|---|
| 217 |
protected Map valueProperties() |
|---|
| 218 |
{ |
|---|
| 219 |
if ( _valueProperties == null ) |
|---|
| 220 |
{ |
|---|
| 221 |
File aFile = new File( this.stubDirectory(), ClassInfo.nameForClass( this.value() ) + ".cls.plist" ); |
|---|
| 222 |
|
|---|
| 223 |
_valueProperties = (Map) PLReader.valueOf( aFile.toURI() ); |
|---|
| 224 |
|
|---|
| 225 |
if ( _valueProperties == null ) |
|---|
| 226 |
{ |
|---|
| 227 |
_valueProperties = Collections.EMPTY_MAP; |
|---|
| 228 |
} |
|---|
| 229 |
} |
|---|
| 230 |
|
|---|
| 231 |
return _valueProperties; |
|---|
| 232 |
} |
|---|
| 233 |
|
|---|
| 234 |
protected Collection interfaces() |
|---|
| 235 |
{ |
|---|
| 236 |
if ( _interfaces == null ) |
|---|
| 237 |
{ |
|---|
| 238 |
_interfaces = Arrays.asList( this.value().getInterfaces() ); |
|---|
| 239 |
|
|---|
| 240 |
if ( _interfaces.isEmpty() == false ) |
|---|
| 241 |
{ |
|---|
| 242 |
Collections.sort( (List) _interfaces, ClassInfo.AltClassComparator.comparator() ); |
|---|
| 243 |
} |
|---|
| 244 |
} |
|---|
| 245 |
|
|---|
| 246 |
return _interfaces; |
|---|
| 247 |
} |
|---|
| 248 |
|
|---|
| 249 |
protected Collection classVariables() |
|---|
| 250 |
{ |
|---|
| 251 |
if ( _classVariables == null ) |
|---|
| 252 |
{ |
|---|
| 253 |
_classVariables = ClassInfo.classVariables( this.value() ); |
|---|
| 254 |
|
|---|
| 255 |
if ( _classVariables == null ) |
|---|
| 256 |
{ |
|---|
| 257 |
_classVariables = Collections.EMPTY_LIST; |
|---|
| 258 |
} |
|---|
| 259 |
} |
|---|
| 260 |
|
|---|
| 261 |
return _classVariables; |
|---|
| 262 |
} |
|---|
| 263 |
|
|---|
| 264 |
protected Collection instanceVariables() |
|---|
| 265 |
{ |
|---|
| 266 |
if ( _instanceVariables == null ) |
|---|
| 267 |
{ |
|---|
| 268 |
_instanceVariables = ClassInfo.instanceVariables( this.value() ); |
|---|
| 269 |
|
|---|
| 270 |
if ( _instanceVariables == null ) |
|---|
| 271 |
{ |
|---|
| 272 |
_instanceVariables = Collections.EMPTY_LIST; |
|---|
| 273 |
} |
|---|
| 274 |
} |
|---|
| 275 |
|
|---|
| 276 |
return _instanceVariables; |
|---|
| 277 |
} |
|---|
| 278 |
|
|---|
| 279 |
protected Collection constructors() |
|---|
| 280 |
{ |
|---|
| 281 |
if ( _constructors == null ) |
|---|
| 282 |
{ |
|---|
| 283 |
_constructors = ClassInfo.constructors( this.value() ); |
|---|
| 284 |
|
|---|
| 285 |
if ( _constructors == null ) |
|---|
| 286 |
{ |
|---|
| 287 |
_constructors = Collections.EMPTY_LIST; |
|---|
| 288 |
} |
|---|
| 289 |
} |
|---|
| 290 |
|
|---|
| 291 |
return _constructors; |
|---|
| 292 |
} |
|---|
| 293 |
|
|---|
| 294 |
protected Collection classMethods() |
|---|
| 295 |
{ |
|---|
| 296 |
if ( _classMethods == null ) |
|---|
| 297 |
{ |
|---|
| 298 |
_classMethods = ClassInfo.classMethods( this.value() ); |
|---|
| 299 |
|
|---|
| 300 |
if ( _classMethods == null ) |
|---|
| 301 |
{ |
|---|
| 302 |
_classMethods = Collections.EMPTY_LIST; |
|---|
| 303 |
} |
|---|
| 304 |
} |
|---|
| 305 |
|
|---|
| 306 |
return _classMethods; |
|---|
| 307 |
} |
|---|
| 308 |
|
|---|
| 309 |
protected Collection instanceMethods() |
|---|
| 310 |
{ |
|---|
| 311 |
if ( _instanceMethods == null ) |
|---|
| 312 |
{ |
|---|
| 313 |
_instanceMethods = ClassInfo.instanceMethods( this.value() ); |
|---|
| 314 |
|
|---|
| 315 |
if ( _instanceMethods == null ) |
|---|
| 316 |
{ |
|---|
| 317 |
_instanceMethods = Collections.EMPTY_LIST; |
|---|
| 318 |
} |
|---|
| 319 |
} |
|---|
| 320 |
|
|---|
| 321 |
return _instanceMethods; |
|---|
| 322 |
} |
|---|
| 323 |
|
|---|
| 324 |
protected Collection knownClasses() |
|---|
| 325 |
{ |
|---|
| 326 |
if ( _knownClasses == null ) |
|---|
| 327 |
{ |
|---|
| 328 |
if ( this.value().isInterface() == true ) |
|---|
| 329 |
{ |
|---|
| 330 |
_knownClasses = ClassInfo.implementations( this.values(), this.value() ); |
|---|
| 331 |
} |
|---|
| 332 |
else |
|---|
| 333 |
{ |
|---|
| 334 |
_knownClasses = ClassInfo.subclasses( this.values(), this.value() ); |
|---|
| 335 |
} |
|---|
| 336 |
|
|---|
| 337 |
if ( _knownClasses == null ) |
|---|
| 338 |
{ |
|---|
| 339 |
_knownClasses = Collections.EMPTY_LIST; |
|---|
| 340 |
} |
|---|
| 341 |
} |
|---|
| 342 |
|
|---|
| 343 |
return _knownClasses; |
|---|
| 344 |
} |
|---|
| 345 |
|
|---|
| 346 |
// =========================================================================== |
|---|
| 347 |
// Doc method(s) |
|---|
| 348 |
// --------------------------------------------------------------------------- |
|---|
| 349 |
|
|---|
| 350 |
public String title() |
|---|
| 351 |
{ |
|---|
| 352 |
return ClassInfo.nameForClass( this.value() ); |
|---|
| 353 |
} |
|---|
| 354 |
|
|---|
| 355 |
protected void initPathComponents() |
|---|
| 356 |
{ |
|---|
| 357 |
String aPackageName = ClassInfo.packageNameForClass( this.value() ); |
|---|
| 358 |
String aClassName = ClassInfo.altNameForClass( this.value() ); |
|---|
| 359 |
|
|---|
| 360 |
this.addObjectToPathComponents( "Documentation", "index.html", "Documentation" ); |
|---|
| 361 |
this.addObjectToPathComponents( aPackageName, aPackageName + ".pkg.html", aPackageName ); |
|---|
| 362 |
this.addObjectToPathComponents( aClassName, aClassName + ".cls.html", aClassName ); |
|---|
| 363 |
} |
|---|
| 364 |
|
|---|
| 365 |
protected File file() |
|---|
| 366 |
{ |
|---|
| 367 |
String aName = ClassInfo.nameForClass( this.value() ) + ".cls.html"; |
|---|
| 368 |
File aFile = new File( this.directory(), aName ); |
|---|
| 369 |
|
|---|
| 370 |
return aFile; |
|---|
| 371 |
} |
|---|
| 372 |
|
|---|
| 373 |
protected String type() |
|---|
| 374 |
{ |
|---|
| 375 |
String aType = null; |
|---|
| 376 |
|
|---|
| 377 |
if ( this.value().isInterface() == true ) |
|---|
| 378 |
{ |
|---|
| 379 |
aType = this.property( "interface" ); |
|---|
| 380 |
} |
|---|
| 381 |
else |
|---|
| 382 |
if ( Throwable.class.isAssignableFrom( this.value() ) == true ) |
|---|
| 383 |
{ |
|---|
| 384 |
aType = this.property( "exception" ); |
|---|
| 385 |
} |
|---|
| 386 |
else |
|---|
| 387 |
{ |
|---|
| 388 |
aType = this.property( "class" ); |
|---|
| 389 |
} |
|---|
| 390 |
|
|---|
| 391 |
return aType; |
|---|
| 392 |
} |
|---|
| 393 |
|
|---|
| 394 |
// =========================================================================== |
|---|
| 395 |
// Display method(s) |
|---|
| 396 |
// --------------------------------------------------------------------------- |
|---|
| 397 |
|
|---|
| 398 |
protected SZComponent navigation() |
|---|
| 399 |
{ |
|---|
| 400 |
Map someBindings = new HashMap(); |
|---|
| 401 |
someBindings.put( "value", this.value() ); |
|---|
| 402 |
someBindings.put( "valueProperties", this.valueProperties() ); |
|---|
| 403 |
SZComponent aComponent = new ClassMethodNavigation( this.context(), this, someBindings ); |
|---|
| 404 |
|
|---|
| 405 |
return aComponent; |
|---|
| 406 |
} |
|---|
| 407 |
|
|---|
| 408 |
protected String titleAnchor() |
|---|
| 409 |
{ |
|---|
| 410 |
StringBuffer aBuffer = new StringBuffer(); |
|---|
| 411 |
String aName = ClassInfo.altNameForClass( this.value() ); |
|---|
| 412 |
|
|---|
| 413 |
aName = aName.replace( ':', '.' ); |
|---|
| 414 |
aName = SZURIEncoder.encode( aName ); |
|---|
| 415 |
|
|---|
| 416 |
aBuffer.append( "<a name = \"" ); |
|---|
| 417 |
aBuffer.append( "class" ); |
|---|
| 418 |
aBuffer.append( "\"></a>" ); |
|---|
| 419 |
|
|---|
| 420 |
return aBuffer.toString(); |
|---|
| 421 |
} |
|---|
| 422 |
|
|---|
| 423 |
protected SZComponent titleComponent() |
|---|
| 424 |
{ |
|---|
| 425 |
Map someBindings = new HashMap(); |
|---|
| 426 |
someBindings.put( "value", ClassInfo.altNameForClass( this.value() ) ); |
|---|
| 427 |
someBindings.put( "isBig", Boolean.TRUE ); |
|---|
| 428 |
someBindings.put( "isBold", Boolean.TRUE ); |
|---|
| 429 |
someBindings.put( "class", "Title" ); |
|---|
| 430 |
SZComponent aComponent = new SZSpanString( this.context(), this, someBindings ); |
|---|
| 431 |
|
|---|
| 432 |
if ( ( this.value().isInterface() == false ) && |
|---|
| 433 |
( Modifier.isAbstract( this.value().getModifiers() ) == true ) ) |
|---|
| 434 |
{ |
|---|
| 435 |
someBindings.put( "isItalic", Boolean.TRUE ); |
|---|
| 436 |
} |
|---|
| 437 |
|
|---|
| 438 |
return aComponent; |
|---|
| 439 |
} |
|---|
| 440 |
|
|---|
| 441 |
protected SZComponent subTitleComponent() |
|---|
| 442 |
{ |
|---|
| 443 |
String aValue = Modifier.toString( this.value().getModifiers() ); |
|---|
| 444 |
Map someBindings = new HashMap(); |
|---|
| 445 |
someBindings.put( "value", aValue ); |
|---|
| 446 |
someBindings.put( "isTypeWriter", Boolean.TRUE ); |
|---|
| 447 |
SZComponent aComponent = new SZSpanString( this.context(), this, someBindings ); |
|---|
| 448 |
|
|---|
| 449 |
return aComponent; |
|---|
| 450 |
} |
|---|
| 451 |
|
|---|
| 452 |
protected SZComponent inheritsFromTitle() |
|---|
| 453 |
{ |
|---|
| 454 |
Map someBindings = new HashMap(); |
|---|
| 455 |
someBindings.put( "value", this.property( "Inherits From" ) + ": " ); |
|---|
| 456 |
someBindings.put( "isBold", Boolean.TRUE ); |
|---|
| 457 |
someBindings.put( "class", "Title" ); |
|---|
| 458 |
SZComponent aComponent = new SZSpanString( this.context(), this, someBindings ); |
|---|
| 459 |
|
|---|
| 460 |
return aComponent; |
|---|
| 461 |
} |
|---|
| 462 |
|
|---|
| 463 |
protected SZComponent conformsToTitle() |
|---|
| 464 |
{ |
|---|
| 465 |
Map someBindings = new HashMap(); |
|---|
| 466 |
someBindings.put( "value", this.property( "Conforms To" ) + ": " ); |
|---|
| 467 |
someBindings.put( "isBold", Boolean.TRUE ); |
|---|
| 468 |
someBindings.put( "class", "Title" ); |
|---|
| 469 |
SZComponent aComponent = new SZSpanString( this.context(), this, someBindings ); |
|---|
| 470 |
|
|---|
| 471 |
return aComponent; |
|---|
| 472 |
} |
|---|
| 473 |
|
|---|
| 474 |
protected SZComponent declaredInTitle() |
|---|
| 475 |
{ |
|---|
| 476 |
Map someBindings = new HashMap(); |
|---|
| 477 |
someBindings.put( "value", this.property( "Declared In" ) + ": " ); |
|---|
| 478 |
someBindings.put( "isBold", Boolean.TRUE ); |
|---|
| 479 |
someBindings.put( "class", "Title" ); |
|---|
| 480 |
SZComponent aComponent = new SZSpanString( this.context(), this, someBindings ); |
|---|
| 481 |
|
|---|
| 482 |
return aComponent; |
|---|
| 483 |
} |
|---|
| 484 |
|
|---|
| 485 |
protected SZComponent descriptionTitle() |
|---|
| 486 |
{ |
|---|
| 487 |
Map someBindings = new HashMap(); |
|---|
| 488 |
someBindings.put( "isBig", Boolean.TRUE ); |
|---|
| 489 |
someBindings.put( "isBold", Boolean.TRUE ); |
|---|
| 490 |
someBindings.put( "class", "Title" ); |
|---|
| 491 |
SZComponent aComponent = new SZSpanString( this.context(), this, someBindings ); |
|---|
| 492 |
StringBuffer aBuffer = new StringBuffer(); |
|---|
| 493 |
|
|---|
| 494 |
aBuffer.append( SZString.capitalizeString( this.type() ) ); |
|---|
| 495 |
aBuffer.append( " " ); |
|---|
| 496 |
aBuffer.append( this.property( "Description" ) ); |
|---|
| 497 |
|
|---|
| 498 |
someBindings.put( "value", aBuffer.toString() ); |
|---|
| 499 |
|
|---|
| 500 |
return aComponent; |
|---|
| 501 |
} |
|---|
| 502 |
|
|---|
| 503 |
protected SZComponent classVariablesTitle() |
|---|
| 504 |
{ |
|---|
| 505 |
NumberFormat aFormat = NumberFormat.getInstance( Locale.US ); |
|---|
| 506 |
String aTitle = aFormat.format( this.classVariables().size() ) + " " + this.property( "Class Variables" ).toLowerCase(); |
|---|
| 507 |
Map someBindings = new HashMap(); |
|---|
| 508 |
someBindings.put( "value", this.property( "Class Variables" ) ); |
|---|
| 509 |
someBindings.put( "title", aTitle ); |
|---|
| 510 |
someBindings.put( "isBig", Boolean.TRUE ); |
|---|
| 511 |
someBindings.put( "isBold", Boolean.TRUE ); |
|---|
| 512 |
someBindings.put( "class", "Title" ); |
|---|
| 513 |
SZComponent aComponent = new SZSpanString( this.context(), this, someBindings ); |
|---|
| 514 |
|
|---|
| 515 |
return aComponent; |
|---|
| 516 |
} |
|---|
| 517 |
|
|---|
| 518 |
protected SZComponent instanceVariablesTitle() |
|---|
| 519 |
{ |
|---|
| 520 |
NumberFormat aFormat = NumberFormat.getInstance( Locale.US ); |
|---|
| 521 |
String aTitle = aFormat.format( this.instanceVariables().size() ) + " " + this.property( "Instance Variables" ).toLowerCase(); |
|---|
| 522 |
Map someBindings = new HashMap(); |
|---|
| 523 |
someBindings.put( "value", this.property( "Instance Variables" ) ); |
|---|
| 524 |
someBindings.put( "title", aTitle ); |
|---|
| 525 |
someBindings.put( "isBig", Boolean.TRUE ); |
|---|
| 526 |
someBindings.put( "isBold", Boolean.TRUE ); |
|---|
| 527 |
someBindings.put( "class", "Title" ); |
|---|
| 528 |
SZComponent aComponent = new SZSpanString( this.context(), this, someBindings ); |
|---|
| 529 |
|
|---|
| 530 |
return aComponent; |
|---|
| 531 |
} |
|---|
| 532 |
|
|---|
| 533 |
protected SZComponent constructorsTitle() |
|---|
| 534 |
{ |
|---|
| 535 |
NumberFormat aFormat = NumberFormat.getInstance( Locale.US ); |
|---|
| 536 |
String aTitle = aFormat.format( this.constructors().size() ) + " " + this.property( "Constructors" ).toLowerCase(); |
|---|
| 537 |
Map someBindings = new HashMap(); |
|---|
| 538 |
someBindings.put( "value", this.property( "Constructors" ) ); |
|---|
| 539 |
someBindings.put( "title", aTitle ); |
|---|
| 540 |
someBindings.put( "isBig", Boolean.TRUE ); |
|---|
| 541 |
someBindings.put( "isBold", Boolean.TRUE ); |
|---|
| 542 |
someBindings.put( "class", "Title" ); |
|---|
| 543 |
SZComponent aComponent = new SZSpanString( this.context(), this, someBindings ); |
|---|
| 544 |
|
|---|
| 545 |
return aComponent; |
|---|
| 546 |
} |
|---|
| 547 |
|
|---|
| 548 |
protected SZComponent classMethodsTitle() |
|---|
| 549 |
{ |
|---|
| 550 |
NumberFormat aFormat = NumberFormat.getInstance( Locale.US ); |
|---|
| 551 |
String aTitle = aFormat.format( this.classMethods().size() ) + " " + this.property( "Class Methods" ).toLowerCase(); |
|---|
| 552 |
Map someBindings = new HashMap(); |
|---|
| 553 |
someBindings.put( "value", this.property( "Class Methods" ) ); |
|---|
| 554 |
someBindings.put( "title", aTitle ); |
|---|
| 555 |
someBindings.put( "isBig", Boolean.TRUE ); |
|---|
| 556 |
someBindings.put( "isBold", Boolean.TRUE ); |
|---|
| 557 |
someBindings.put( "class", "Title" ); |
|---|
| 558 |
SZComponent aComponent = new SZSpanString( this.context(), this, someBindings ); |
|---|
| 559 |
|
|---|
| 560 |
return aComponent; |
|---|
| 561 |
} |
|---|
| 562 |
|
|---|
| 563 |
protected SZComponent instanceMethodsTitle() |
|---|
| 564 |
{ |
|---|
| 565 |
NumberFormat aFormat = NumberFormat.getInstance( Locale.US ); |
|---|
| 566 |
String aTitle = aFormat.format( this.instanceMethods().size() ) + " " + this.property( "Instance Methods" ).toLowerCase(); |
|---|
| 567 |
Map someBindings = new HashMap(); |
|---|
| 568 |
someBindings.put( "value", this.property( "Instance Methods" ) ); |
|---|
| 569 |
someBindings.put( "title", aTitle ); |
|---|
| 570 |
someBindings.put( "isBig", Boolean.TRUE ); |
|---|
| 571 |
someBindings.put( "isBold", Boolean.TRUE ); |
|---|
| 572 |
someBindings.put( "class", "Title" ); |
|---|
| 573 |
SZComponent aComponent = new SZSpanString( this.context(), this, someBindings ); |
|---|
| 574 |
|
|---|
| 575 |
return aComponent; |
|---|
| 576 |
} |
|---|
| 577 |
|
|---|
| 578 |
protected SZComponent knownClassesTitle() |
|---|
| 579 |
{ |
|---|
| 580 |
NumberFormat aFormat = NumberFormat.getInstance( Locale.US ); |
|---|
| 581 |
String aTitle = aFormat.format( this.knownClasses().size() ) + " " + this.property( "Known Subclasses" ).toLowerCase(); |
|---|
| 582 |
Map someBindings = new HashMap(); |
|---|
| 583 |
someBindings.put( "value", this.property( "Known Subclasses" ) ); |
|---|
| 584 |
someBindings.put( "title", aTitle ); |
|---|
| 585 |
someBindings.put( "isBig", Boolean.TRUE ); |
|---|
| 586 |
someBindings.put( "isBold", Boolean.TRUE ); |
|---|
| 587 |
someBindings.put( "class", "Title" ); |
|---|
| 588 |
SZComponent aComponent = new SZSpanString( this.context(), this, someBindings ); |
|---|
| 589 |
|
|---|
| 590 |
if ( this.value().isInterface() == true ) |
|---|
| 591 |
{ |
|---|
| 592 |
someBindings.put( "value", this.property( "Known Implementations" ) ); |
|---|
| 593 |
|
|---|
| 594 |
aTitle = aFormat.format( this.knownClasses().size() ) + " " + this.property( "Known Subclasses" ).toLowerCase(); |
|---|
| 595 |
someBindings.put( "title", aTitle ); |
|---|
| 596 |
} |
|---|
| 597 |
|
|---|
| 598 |
return aComponent; |
|---|
| 599 |
} |
|---|
| 600 |
|
|---|
| 601 |
protected String inheritsFromComponent() |
|---|
| 602 |
{ |
|---|
| 603 |
if ( this.value().getSuperclass() == null ) |
|---|
| 604 |
{ |
|---|
| 605 |
return this.property( "none" ); |
|---|
| 606 |
} |
|---|
| 607 |
|
|---|
| 608 |
return null; |
|---|
| 609 |
} |
|---|
| 610 |
|
|---|
| 611 |
protected String conformsToComponent() |
|---|
| 612 |
{ |
|---|
| 613 |
if ( this.interfaces().isEmpty() == true ) |
|---|
| 614 |
{ |
|---|
| 615 |
return this.property( "none" ); |
|---|
| 616 |
} |
|---|
| 617 |
|
|---|
| 618 |
return null; |
|---|
| 619 |
} |
|---|
| 620 |
|
|---|
| 621 |
protected SZComponent declaredInComponent() |
|---|
| 622 |
{ |
|---|
| 623 |
return PackageDoc.linkForClassInComponent( this.value(), this ); |
|---|
| 624 |
} |
|---|
| 625 |
|
|---|
| 626 |
protected String descriptionComponent() |
|---|
| 627 |
{ |
|---|
| 628 |
Map someProperties = this.valueProperties(); |
|---|
| 629 |
String aValue = (String) someProperties.get( "description" ); |
|---|
| 630 |
|
|---|
| 631 |
if ( ( aValue == null ) || ( aValue.length() == 0 ) ) |
|---|
| 632 |
{ |
|---|
| 633 |
aValue = this.property( "None available." ); |
|---|
| 634 |
} |
|---|
| 635 |
|
|---|
| 636 |
return aValue; |
|---|
| 637 |
} |
|---|
| 638 |
|
|---|
| 639 |
protected String classVariablesComponent() |
|---|
| 640 |
{ |
|---|
| 641 |
if ( this.classVariables().isEmpty() == true ) |
|---|
| 642 |
{ |
|---|
| 643 |
return this.property( "None declared in this" + " " + this.type() + "." ); |
|---|
| 644 |
} |
|---|
| 645 |
|
|---|
| 646 |
return null; |
|---|
| 647 |
} |
|---|
| 648 |
|
|---|
| 649 |
protected String instanceVariablesComponent() |
|---|
| 650 |
{ |
|---|
| 651 |
if ( this.instanceVariables().isEmpty() == true ) |
|---|
| 652 |
{ |
|---|
| 653 |
return this.property( "None declared in this" + " " + this.type() + "." ); |
|---|
| 654 |
} |
|---|
| 655 |
|
|---|
| 656 |
return null; |
|---|
| 657 |
} |
|---|
| 658 |
|
|---|
| 659 |
protected String constructorsComponent() |
|---|
| 660 |
{ |
|---|
| 661 |
if ( this.constructors().isEmpty() == true ) |
|---|
| 662 |
{ |
|---|
| 663 |
return this.property( "None declared in this" + " " + this.type() + "." ); |
|---|
| 664 |
} |
|---|
| 665 |
|
|---|
| 666 |
return null; |
|---|
| 667 |
} |
|---|
| 668 |
|
|---|
| 669 |
protected String classMethodsComponent() |
|---|
| 670 |
{ |
|---|
| 671 |
if ( this.classMethods().isEmpty() == true ) |
|---|
| 672 |
{ |
|---|
| 673 |
return this.property( "None declared in this" + " " + this.type() + "." ); |
|---|
| 674 |
} |
|---|
| 675 |
|
|---|
| 676 |
return null; |
|---|
| 677 |
} |
|---|
| 678 |
|
|---|
| 679 |
protected String instanceMethodsComponent() |
|---|
| 680 |
{ |
|---|
| 681 |
if ( this.instanceMethods().isEmpty() == true ) |
|---|
| 682 |
{ |
|---|
| 683 |
return this.property( "None declared in this" + " " + this.type() + "." ); |
|---|
| 684 |
} |
|---|
| 685 |
|
|---|
| 686 |
return null; |
|---|
| 687 |
} |
|---|
| 688 |
|
|---|
| 689 |
protected String knownClassesComponent() |
|---|
| 690 |
{ |
|---|
| 691 |
if ( this.knownClasses().isEmpty() == true ) |
|---|
| 692 |
{ |
|---|
| 693 |
return this.property( "None." ); |
|---|
| 694 |
} |
|---|
| 695 |
else |
|---|
| 696 |
if ( this.knownClasses().size() > 100 ) |
|---|
| 697 |
{ |
|---|
| 698 |
return this.property( "Too many to list." ); |
|---|
| 699 |
} |
|---|
| 700 |
|
|---|
| 701 |
return null; |
|---|
| 702 |
} |
|---|
| 703 |
|
|---|
| 704 |
public String toString() |
|---|
| 705 |
{ |
|---|
| 706 |
SZTemplate aTemplate = this.template(); |
|---|
| 707 |
Map someBindings = new HashMap(); |
|---|
| 708 |
someBindings.put( "title", this.title() ); |
|---|
| 709 |
someBindings.put( "navigation", this.navigation() ); |
|---|
| 710 |
someBindings.put( "pathComponents", this.pathComponents() ); |
|---|
| 711 |
someBindings.put( "iconName", this.iconName() ); |
|---|
| 712 |
someBindings.put( "content", aTemplate ); |
|---|
| 713 |
SZComponent aLayout = new PageLayout( this.context(), this, someBindings ); |
|---|
| 714 |
Class aSuperclass = this.value().getSuperclass(); |
|---|
| 715 |
Collection someValues = this.values(); |
|---|
| 716 |
|
|---|
| 717 |
aTemplate.set( "titleAnchor", this.titleAnchor() ); |
|---|
| 718 |
aTemplate.set( "titleComponent", this.titleComponent() ); |
|---|
| 719 |
aTemplate.set( "subTitleComponent", this.subTitleComponent() ); |
|---|
| 720 |
|
|---|
| 721 |
aTemplate.set( "inheritsFromTitle", this.inheritsFromTitle() ); |
|---|
| 722 |
aTemplate.set( "conformsToTitle", this.conformsToTitle() ); |
|---|
| 723 |
aTemplate.set( "declaredInTitle", this.declaredInTitle() ); |
|---|
| 724 |
|
|---|
| 725 |
aTemplate.set( "descriptionTitle", this.descriptionTitle() ); |
|---|
| 726 |
aTemplate.set( "classVariablesTitle", this.classVariablesTitle() ); |
|---|
| 727 |
aTemplate.set( "instanceVariablesTitle", this.instanceVariablesTitle() ); |
|---|
| 728 |
aTemplate.set( "constructorsTitle", this.constructorsTitle() ); |
|---|
| 729 |
aTemplate.set( "classMethodsTitle", this.classMethodsTitle() ); |
|---|
| 730 |
aTemplate.set( "instanceMethodsTitle", this.instanceMethodsTitle() ); |
|---|
| 731 |
aTemplate.set( "knownClassesTitle", this.knownClassesTitle() ); |
|---|
| 732 |
|
|---|
| 733 |
aTemplate.set( "inheritsFromComponent", this.inheritsFromComponent() ); |
|---|
| 734 |
aTemplate.set( "conformsToComponent", this.conformsToComponent() ); |
|---|
| 735 |
aTemplate.set( "declaredInComponent", this.declaredInComponent() ); |
|---|
| 736 |
|
|---|
| 737 |
aTemplate.set( "descriptionComponent", this.descriptionComponent() ); |
|---|
| 738 |
aTemplate.set( "classVariablesComponent", this.classVariablesComponent() ); |
|---|
| 739 |
aTemplate.set( "instanceVariablesComponent", this.instanceVariablesComponent() ); |
|---|
| 740 |
aTemplate.set( "constructorsComponent", this.constructorsComponent() ); |
|---|
| 741 |
aTemplate.set( "classMethodsComponent", this.classMethodsComponent() ); |
|---|
| 742 |
aTemplate.set( "instanceMethodsComponent", this.instanceMethodsComponent() ); |
|---|
| 743 |
aTemplate.set( "knownClassesComponent", this.knownClassesComponent() ); |
|---|
| 744 |
|
|---|
| 745 |
while ( aSuperclass != null ) |
|---|
| 746 |
{ |
|---|
| 747 |
SZComponent aComponent = ClassDoc.altLinkForClassInComponent( aSuperclass, this ); |
|---|
| 748 |
SZTemplate aComponentTemplate = aTemplate.get( "superclasses" ); |
|---|
| 749 |
|
|---|
| 750 |
if ( ClassInfo.contains( someValues, aSuperclass ) == false ) |
|---|
| 751 |
{ |
|---|
| 752 |
aComponent.takeValueForBinding( Boolean.FALSE, "isEnabled" ); |
|---|
| 753 |
} |
|---|
| 754 |
|
|---|
| 755 |
aComponentTemplate.set( "superclass", aComponent ); |
|---|
| 756 |
|
|---|
| 757 |
aSuperclass = aSuperclass.getSuperclass(); |
|---|
| 758 |
|
|---|
| 759 |
if ( aSuperclass != null ) |
|---|
| 760 |
{ |
|---|
| 761 |
aComponentTemplate.set( "superclassSeparator", ": " ); |
|---|
| 762 |
} |
|---|
| 763 |
else |
|---|
| 764 |
{ |
|---|
| 765 |
aComponentTemplate.set( "superclassSeparator", null ); |
|---|
| 766 |
} |
|---|
| 767 |
|
|---|
| 768 |
aTemplate.append( "superclasses", aComponentTemplate ); |
|---|
| 769 |
} |
|---|
| 770 |
|
|---|
| 771 |
for ( Iterator anIterator = this.interfaces().iterator(); anIterator.hasNext(); ) |
|---|
| 772 |
{ |
|---|
| 773 |
Class aValue = (Class) anIterator.next(); |
|---|
| 774 |
SZComponent aComponent = ClassDoc.altLinkForClassInComponent( aValue, this ); |
|---|
| 775 |
SZTemplate aComponentTemplate = aTemplate.get( "interfaces" ); |
|---|
| 776 |
|
|---|
| 777 |
if ( ClassInfo.contains( someValues, aValue ) == false ) |
|---|
| 778 |
{ |
|---|
| 779 |
aComponent.takeValueForBinding( Boolean.FALSE, "isEnabled" ); |
|---|
| 780 |
} |
|---|
| 781 |
|
|---|
| 782 |
aComponentTemplate.set( "interface", aComponent ); |
|---|
| 783 |
|
|---|
| 784 |
if ( anIterator.hasNext() == true ) |
|---|
| 785 |
{ |
|---|
| 786 |
aComponentTemplate.set( "interfaceSeparator", "<br>" ); |
|---|
| 787 |
} |
|---|
| 788 |
else |
|---|
| 789 |
{ |
|---|
| 790 |
aComponentTemplate.set( "interfaceSeparator", null ); |
|---|
| 791 |
} |
|---|
| 792 |
|
|---|
| 793 |
aTemplate.append( "interfaces", aComponentTemplate ); |
|---|
| 794 |
} |
|---|
| 795 |
|
|---|
| 796 |
for ( Iterator anIterator = this.classVariables().iterator(); anIterator.hasNext(); ) |
|---|
| 797 |
{ |
|---|
| 798 |
Field aValue = (Field) anIterator.next(); |
|---|
| 799 |
Map someComponentBindings = new HashMap(); |
|---|
| 800 |
someComponentBindings.put( "value", aValue ); |
|---|
| 801 |
someComponentBindings.put( "values", someValues ); |
|---|
| 802 |
someComponentBindings.put( "valueProperties", this.valueProperties() ); |
|---|
| 803 |
SZComponent aComponent = new FieldDoc( this.context(), this, someComponentBindings ); |
|---|
| 804 |
SZTemplate aComponentTemplate = aTemplate.get( "classVariables" ); |
|---|
| 805 |
|
|---|
| 806 |
aComponentTemplate.set( "classVariable", aComponent ); |
|---|
| 807 |
|
|---|
| 808 |
if ( anIterator.hasNext() == true ) |
|---|
| 809 |
{ |
|---|
| 810 |
aComponentTemplate.set( "classVariableSeparator", "<br><br><br>" ); |
|---|
| 811 |
} |
|---|
| 812 |
else |
|---|
| 813 |
{ |
|---|
| 814 |
aComponentTemplate.set( "classVariableSeparator", null ); |
|---|
| 815 |
} |
|---|
| 816 |
|
|---|
| 817 |
aTemplate.append( "classVariables", aComponentTemplate ); |
|---|
| 818 |
} |
|---|
| 819 |
|
|---|
| 820 |
for ( Iterator anIterator = this.instanceVariables().iterator(); anIterator.hasNext(); ) |
|---|
| 821 |
{ |
|---|
| 822 |
Field aValue = (Field) anIterator.next(); |
|---|
| 823 |
Map someComponentBindings = new HashMap(); |
|---|
| 824 |
someComponentBindings.put( "value", aValue ); |
|---|
| 825 |
someComponentBindings.put( "values", someValues ); |
|---|
| 826 |
someComponentBindings.put( "valueProperties", this.valueProperties() ); |
|---|
| 827 |
SZComponent aComponent = new FieldDoc( this.context(), this, someComponentBindings ); |
|---|
| 828 |
SZTemplate aComponentTemplate = aTemplate.get( "instanceVariables" ); |
|---|
| 829 |
|
|---|
| 830 |
aComponentTemplate.set( "instanceVariable", aComponent ); |
|---|
| 831 |
|
|---|
| 832 |
if ( anIterator.hasNext() == true ) |
|---|
| 833 |
{ |
|---|
| 834 |
aComponentTemplate.set( "instanceVariableSeparator", "<br><br><br>" ); |
|---|
| 835 |
} |
|---|
| 836 |
else |
|---|
| 837 |
{ |
|---|
| 838 |
aComponentTemplate.set( "instanceVariableSeparator", null ); |
|---|
| 839 |
} |
|---|
| 840 |
|
|---|
| 841 |
aTemplate.append( "instanceVariables", aComponentTemplate ); |
|---|
| 842 |
} |
|---|
| 843 |
|
|---|
| 844 |
for ( Iterator anIterator = this.constructors().iterator(); anIterator.hasNext(); ) |
|---|
| 845 |
{ |
|---|
| 846 |
Constructor aValue = (Constructor) anIterator.next(); |
|---|
| 847 |
Map someComponentBindings = new HashMap(); |
|---|
| 848 |
  |
|---|