KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > xdoclet > modules > jdo > VendorExtensionsSubTask


1 /*
2  * Copyright (c) 2001, 2002 The XDoclet team
3  * All rights reserved.
4  */

5 package xdoclet.modules.jdo;
6
7 import java.util.Collection JavaDoc;
8 import xjavadoc.XClass;
9 import xjavadoc.XConstructor;
10 import xjavadoc.XField;
11 import xjavadoc.XMethod;
12 import xjavadoc.XPackage;
13 import xdoclet.SubTask;
14 import xdoclet.XDocletException;
15
16 /**
17  * @author Ludovic Claude (ludovicc@users.sourceforge.net)
18  * @created 10 October 2002
19  * @version $Revision: 1.1 $
20  */

21 public abstract class VendorExtensionsSubTask extends SubTask
22 {
23
24     // Standard tags for vendor extensions
25
public final static String JavaDoc SQL_TABLE_TAG = "sql.table";
26     public final static String JavaDoc SQL_FIELD_TAG = "sql.field";
27     public final static String JavaDoc TABLE_NAME_ATTR = "table-name";
28     public final static String JavaDoc COLUMN_NAME_ATTR = "column-name";
29     public final static String JavaDoc RELATED_FIELD_ATTR = "related-field";
30
31     public final static String JavaDoc SQL_RELATION_TAG = "sql.relation";
32     public final static String JavaDoc STYLE_ATTR = "style";
33     public final static String JavaDoc STYLE_FOREIGN_KEY_VALUE = "foreign-key";
34     public final static String JavaDoc STYLE_RELATION_TABLE_VALUE = "relation-table";
35
36     // uses TABLE_NAME_ATTR
37
// uses RELATED_FIELD_ATTR
38

39
40     public abstract String JavaDoc getVendorName();
41
42     public abstract String JavaDoc getVendorDescription();
43
44     // Redirect all get/setCurrentXXX methods to the metadataSubTask
45

46     /**
47      * Peeks and return the current class from top of currentClassStack stack.
48      *
49      * @return The CurrentClass value
50      * @see #setCurrentClass(xjavadoc.XClass)
51      */

52     public XClass getCurrentClass()
53     {
54         return getMetadataSubTask().getCurrentClass();
55     }
56
57     /**
58      * Returns current package.
59      *
60      * @return The CurrentPackage value
61      * @see #setCurrentPackage(xjavadoc.XPackage)
62      */

63     public XPackage getCurrentPackage()
64     {
65         return getMetadataSubTask().getCurrentPackage();
66     }
67
68     /**
69      * Returns current method.
70      *
71      * @return The CurrentMethod value
72      * @see #setCurrentMethod(xjavadoc.XMethod)
73      */

74     public XMethod getCurrentMethod()
75     {
76         return getMetadataSubTask().getCurrentMethod();
77     }
78
79     /**
80      * Returns current constructor.
81      *
82      * @return The CurrentConstructor value
83      * @see #setCurrentConstructor(xjavadoc.XConstructor)
84      */

85     public XConstructor getCurrentConstructor()
86     {
87         return getMetadataSubTask().getCurrentConstructor();
88     }
89
90     /**
91      * Returns current field.
92      *
93      * @return The CurrentField value
94      * @see #setCurrentField(xjavadoc.XField)
95      */

96     public XField getCurrentField()
97     {
98         return getMetadataSubTask().getCurrentField();
99     }
100
101     /**
102      * Returns current package.
103      *
104      * @param pakkage The new CurrentPackage value
105      * @see #setCurrentPackage(xjavadoc.XPackage)
106      * @ant.ignore
107      */

108     public void setCurrentPackage(XPackage pakkage)
109     {
110         getMetadataSubTask().setCurrentPackage(pakkage);
111     }
112
113     /**
114      * Sets the CurrentMethod attribute of the DocletSupport object
115      *
116      * @param method The new CurrentMethod value
117      * @ant.ignore
118      */

119     public void setCurrentMethod(XMethod method)
120     {
121         getMetadataSubTask().setCurrentMethod(method);
122     }
123
124     /**
125      * Sets the CurrentConstructor attribute of the DocletSupport object
126      *
127      * @param constructor The new CurrentConstructor value
128      * @ant.ignore
129      */

130     public void setCurrentConstructor(XConstructor constructor)
131     {
132         getMetadataSubTask().setCurrentConstructor(constructor);
133     }
134
135     /**
136      * Sets the CurrentField attribute of the DocletSupport object
137      *
138      * @param field The new CurrentField value
139      * @ant.ignore
140      */

141     public void setCurrentField(XField field)
142     {
143         getMetadataSubTask().setCurrentField(field);
144     }
145
146     /**
147      * Sets current class to clazz by clearing currentClassStack stack and pushing clazz into top of it.
148      *
149      * @param clazz The new CurrentClass value
150      * @see #getCurrentClass()
151      * @ant.ignore
152      */

153     public void setCurrentClass(XClass clazz)
154     {
155         getMetadataSubTask().setCurrentClass(clazz);
156     }
157
158     /**
159      * Pushes class clazz to top of currentClassStack stack, making it effectively the current class.
160      *
161      * @param clazz Description of Parameter
162      * @return Description of the Returned Value
163      * @see #getCurrentClass()
164      * @see #setCurrentClass(xjavadoc.XClass)
165      * @see #popCurrentClass()
166      */

167     public XClass pushCurrentClass(XClass clazz)
168     {
169         return getMetadataSubTask().pushCurrentClass(clazz);
170     }
171
172     /**
173      * Popes current class from top currentClassStack stack. The poped class is no longer the current class.
174      *
175      * @return Description of the Returned Value
176      * @see #getCurrentClass()
177      * @see #setCurrentClass(xjavadoc.XClass)
178      * @see #pushCurrentClass(xjavadoc.XClass)
179      */

180     public XClass popCurrentClass()
181     {
182         return getMetadataSubTask().popCurrentClass();
183     }
184
185     /**
186      * @exception XDocletException
187      * @see xdoclet.SubTask#execute()
188      */

189     public void execute() throws XDocletException
190     {
191         // noop
192
}
193
194     protected JdoXmlMetadataSubTask getMetadataSubTask()
195     {
196         return (JdoXmlMetadataSubTask) getContext().getSubTaskBy("jdometadata");
197     }
198
199     protected Collection JavaDoc getExtensions(String JavaDoc level) throws XDocletException
200     {
201         if ("class".equals(level))
202             return getClassExtensions();
203         else if ("field".equals(level))
204             return getFieldExtensions();
205         else if ("collection".equals(level))
206             return getCollectionExtensions();
207         else if ("array".equals(level))
208             return getArrayExtensions();
209         else if ("map".equals(level))
210             return getMapExtensions();
211         else
212             return null;
213     }
214
215     protected abstract Collection JavaDoc getClassExtensions() throws XDocletException;
216
217     protected abstract Collection JavaDoc getFieldExtensions() throws XDocletException;
218
219     protected abstract Collection JavaDoc getCollectionExtensions() throws XDocletException;
220
221     protected abstract Collection JavaDoc getArrayExtensions() throws XDocletException;
222
223     protected abstract Collection JavaDoc getMapExtensions() throws XDocletException;
224 }
225
Popular Tags