Java Reference
In-Depth Information
L.addChild(T3);
B.addChild(L);
ByteArrayOutputStream buffer #
new ByteArrayOutputStream();
P.serialize( new PrintStream(buffer));
String[] expected # {
"<HTML>", "<HEAD><TITLE>Test</TITLE></HEAD>",
"<BODY","bgcolor # \"white\"",
"<H1>","This is a test","</H1>",
"This is plain text",
"<A HREF # \"http://www.w3c.org\"", "Click here...",
"</A>", "</BODY>", "</HTML>"
};
System.out.println(buffer.toString());
assertContainsInOrder(buffer.toString(),expected);
}
protected void assertContainsInOrder(String output,
String[] strings){
int lastIndex # -1;
int currentIndex # -1;
output # output.toUpperCase();
for ( int i # 0; i < strings.length; i !! ) {
currentIndex # output.indexOf(strings[i].
toUpperCase(),lastIndex ! 1);
assertTrue("Couldn't find [" ! i ! "]:" ! strings[i]
,currentIndex>-1);
lastIndex # currentIndex;
}
}
}
8.5
Prototype 2: Language front end
The analysis and design of the language front end component will be carried
out for the sample documentation case laid out in the specification section.
8.5.1
Analysis
The front-end module has the purpose of parsing the source code of a Java
class and to generate the corresponding HTML documentation.
Looking at Figure 8.11, the parsing task consists of finding out the name
of the class and then, inside the class, identifying the declarations of the
public members. Since we are interested only in the signature of methods
and of variables, the parser must extract only a part of the members. In
particular, all the text following the “public” keyword and preceding either a
 
Search WWH ::




Custom Search