Java Reference
In-Depth Information
/** put a Field's information to the standard output. */
protected
protected
void
void
putField
(
Field fld
,
Class
<?>
c
) {
println
(
fld
.
getName
() +
" field "
+
c
.
getName
() +
" "
);
}
/** put a Method's information to the standard output. */
protected
protected
void
void
putMethod
(
Method method
,
Class
<?>
c
) {
String methName
=
method
.
getName
();
println
(
methName
+
" method "
+
c
.
getName
() +
" "
);
}
/** Print the start of a class. Unused in this version,
* designed to be overridden */
protected
protected
void
void
startClass
(
Class
<?>
c
) {
}
/** Print the end of a class. Unused in this version,
* designed to be overridden */
protected
protected
void
void
endClass
() {
}
/** Convenience routine, short for System.out.println */
protected
protected final
void
println
(
String s
) {
System
.
out
.
println
(
s
);
final
void
}
}
You probably noticed the methods
startClass()
and
endClass()
, which are null. These
methods are placeholders designed to make subclassing easy for when you need to write
something at the start and end of each class. One example might be a fancy text formatting
application in which you need to output a bold header at the beginning of each class. Another
subclass that generates (limited) XML for each field and method.
Example 23-22. CrossRefXML.java
public
public class
class
CrossRefXML
CrossRefXML
extends
extends
CrossRef
{
public
public static
static
void
void
main
(
String
[]
argv
)
throws
throws
IOException
{
CrossRef xref
=
new
new
CrossRefXML
();
xref
.
doArgs
(
argv
);
}
/** Print the start of a class.