Java Reference
In-Depth Information
observable
observer
Parser
«interface»
Documenter
+
getResult()
parse()
1
1
SimpleDocumenter
JavaLanguage
getResult()
update()
parse()
issues
JavaParseEvent
receives
type
info
Figure 8.12
Front-end component classes
Class
JavaParseEvent
carries two pieces of information: the type of event
(e.g. the start of parsing, class found ...) and additional information specific
for the event (e.g. the name of the class found). The complete list of event
types and their related information is given in Table 8.1.
8.5.3
Implementation
All the classes in the front-end component are in the same package
frontend
.
Class
Parser
extends class
Observable
and defines the abstract method
parse()
that takes as argument one
StringTokenizer
. In addition it provides another
parse()
method that adapts the previous to use a string containing the code
to be parsed.
public abstract class
Parser
extends
Observable {
public final void
parse(String code){
StringTokenizer scanner
#
new
StringTokenizer(code);
parse(scanner);
}
public abstract void
parse(StringTokenizer scanner);
}
Table 8.1
Java parse event types
Event type
Description
Specific information
The parser is about to begin parsing
BEGIN_PARSING
A class has been found
The name of the class
FOUND_CLASS
A member of the class has been found
The signature of the member
FOUND_MEMBER
The parse has finished parsing
END_PARSING