KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > MetaTagTest


1 //package com.mypackage;
2

3 import java.io.IOException JavaDoc;
4 import java.io.Writer JavaDoc;
5 import org.enhydra.zeus.util.MetaTag;
6 import org.enhydra.zeus.util.MetaTagList;
7 import org.enhydra.zeus.binding.Container;
8
9 /**
10  * <p>
11  * This is a demo <code>GeneratorForTags</code> implementation.
12  * <code>GeneratorForTags</code> is the interface definition for plug-in
13  * code generation services that use the DTD metatags. Use the container's
14  * <code>getMetaTagList</code> to obtain the tags.
15  * </p><p>
16  * <em>Important:</em>
17  * </p><p>
18  * You cannot execute a Zeus JAR when invoking a plug-in such as this one.
19  * The JAR contains its own classpath, and you'd either have to insert the
20  * plug-in's class file into the jar or update the classpath info in the
21  * META-INF/MANIFEST.MF file. Instead, it's recommended to invoke Zeus the
22  * "hard way:"
23  * </p><pre>
24  * java -classpath dir_with_test_class:zeus.jar org.enhydra.zeus.util.ZeusCommand --constraints=...
25  * </pre><p>
26  * <em>Important:</em>
27  * </p><p>
28  * It is very unwise to maintain state in a <code>GeneratorForTags</code>
29  * class. No warrantees are made as to what order the elements are generated
30  * in.
31  * </p>
32  *
33  * @author Tim Holloway timh@mousetech.com
34  * @see org.enhydra.zeus.util.MetaTagList
35  */

36
37 public class MetaTagTest implements org.enhydra.zeus.GeneratorForTags {
38
39     /**
40      * <p>
41      * Default constructor
42      * </p>
43      */

44     public MetaTagTest() {
45     }
46
47     /**
48      * <p>
49      * Generate tag-inspired code for an element's interface.
50      * This method is invoked just before the closing brace
51      * that terminates the interface definition, allowing you to insert
52      * additional methods as needed.
53      * </p>
54      *
55      * @param writer <code>Writer</code> into which added code is to be
56      * generated.
57      * @param container <code>Container</code> that defines the element
58      * that is being generated.
59      * @throws <code>IOException</code> - when errors in writing to the
60      * supplied <code>writer</code> occur.
61      */

62     public void generateInterface(Writer JavaDoc writer, Container container) throws IOException JavaDoc {
63         writer.write(" // Generator for tags...(I/F)\n");
64         writer.write(" public String[] getXPaths();\n");
65     }
66
67     /**
68      * <p>
69      * Generate tag-inspired code for an element's implementation
70      * class. This method is invoked just before the closing brace
71      * that terminates the class definition, allowing you to insert
72      * additional fields and methods as needed.
73      * </p>
74      *
75      * @param writer <code>Writer</code> into which added code is to be
76      * generated.
77      * @param container <code>Container</code> that defines the element
78      * that is being generated.
79      * @throws <code>IOException</code> - when errors in writing to the
80      * supplied <code>writer</code> occur.
81      */

82     public void generateImplementation(Writer JavaDoc writer, Container container) throws IOException JavaDoc {
83         MetaTagList list = container.getMetaTagList();
84
85         // TODO: retrieve the "xpath" tag(s) using list.find[Next]Tag()and stuff them into the following
86
// generated code:
87

88         writer.write(" // Generator for tags...(Impl)\n");
89         writer.write(" public String[] getXPaths() {\n");
90         writer.write(" }\n");
91     }
92 }
93
Popular Tags