First Delivery: DumpClass for Monday Feb. 11, by
midnight, in cs639/pa1a (sources under cs639/pa1a/src, etc.)
Second Delivery: JavaToXML, DTD, Schema due Wed, Feb. 20, midnight, in
your cs639/pa1b (sources under cs639/pa1b/src, etc.)
For help, post messages in the Google group.
Suppose you are adding a feature to eclipse to allow it to support efficient
remote access to Java sources via Web Services. To support the Package
Explorer, a Web Service is set up to supply just the needed data for one
class's display, that is, the fields and methods of each class, and nested
within that display, the fields and methods of a nested class (and so on.)
The first step is getting the needed data into XML, the task of this
project. This XML will be eventually carried as the payload of the Web
Services. For simplicity, let's concentrate on the Java classes and their
methods, including the inner classes, but excluding local and anonymous classes,
so methods can't have enclosed classes.
Of course we are not yet doing Web Services for this project. For this project, we will express the structure of Java programs (as summarized in eclipse) in XML. Here's what we want to record
Here's an example of the desired XML,
<?xml
version="1.0" encoding="UTF-8"?>
<source>
<sourceName>Hello.java</sourceName>
<jclass>
<className>Hello</className>
<visibility>public</visibility>
<innerclasses>
<!--inner classes here before methods (see
eclipse display) -->
</innerclasses>
<methods>
<static> <!-- static methods before non-static ones -->
<method>
<name>main</name>
<visibility>public</visibility>
<params> <!--params but
not return types -->
<param>
<paramType>String[]</paramType>
</param>
</params>
</method>
<nonstatic>
<!--use same <method> elements here, as needed -->
</nonstaticMethods>
</methods>
</jclass>
</source>
Note: We're using "jclass" instead of
"class" to avoid using Java reserved words. We're ignoring
constructors and fields for simplicity. Note that paramType may have
parametrized type such as Set<Something>.
Implementation Notes
Inner Classes to Support. Note that inner classes can declared in many
different places in a class. But for simplicity, let's only handle public
inner classes defined at the level of a class's methods, not ones local to
a method. In other words, ignore any classes defined locally within a
method. Regardless of the inner class location between the methods in the .java
file, the XML should show them before the methods.
Packages. Use the supplied skeleton of packages, in particular, cs639.presentation
for the top-level program, cs639.jsource for the java source related code and
cs639.validation for the validator code.
Steps for JavaToXML:
Second delivery (pa1b)
main program: java cs639.jsource.JavaToXML <classname>
Base directory (pa1b): output files Grid.xml, etc. (or write XML
to standard output, or both), JavaSource.dtd, javaSource.xsd
build.xml: with test3 to output Grid's XML, test4 to output SortEx's XML,
test3v to output Grid's XML with linkage to DTD, and validate it, and test3sv
to output Grid's XML with linkage to the XML Schema and validate it.
src/cs639/presentation: JavaToXML.java, a small top-level program.
src/cs639/jsource: JavaMethod.java, JavaSource.java: the main XML
processing code
src/cs639/validation: Counter.java, and your own RunCounter.java or
whatever you want to call it. Hopefully you can leave Counter.java
unchanged.