Update of /cvsroot/xdoclet/xdoclet2/src/java/xdoclet/plugins
In directory sc8-pr-cvs1:/tmp/cvs-serv23313/src/java/xdoclet/plugins
Modified Files:
JellyPlugin.java ScriptPlugin.java VelocityPlugin.java
XMLPlugin.java ZeusPlugin.java
Log Message:
- Applied formatting with Jalopy.
- Added our own Jalopy and Checkstyle settings.
- Added custom tag definitions to keep JavaDoc silent about custom tags.
Index: JellyPlugin.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet2/src/java/xdoclet/plugins/JellyPlugin.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** JellyPlugin.java 27 Feb 2003 00:13:01 -0000 1.1.1.1
--- JellyPlugin.java 5 Mar 2003 22:27:10 -0000 1.2
***************
*** 5,24 ****
package xdoclet.plugins;
- import java.io.*;
- import java.net.URL;
-
- import org.apache.commons.logging.LogFactory;
import org.apache.commons.jelly.JellyContext;
- import org.apache.commons.jelly.XMLOutput;
import org.apache.commons.jelly.JellyException;
!
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;
- import org.dom4j.io.HTMLWriter;
-
import org.xml.sax.SAXException;
import xdoclet.*;
/**
* Generator backed by <a
href="http://jakarta.apache.org/commons/sandbox/jelly/">Jelly</a>.
--- 5,23 ----
package xdoclet.plugins;
import org.apache.commons.jelly.JellyContext;
import org.apache.commons.jelly.JellyException;
! import org.apache.commons.jelly.XMLOutput;
! import org.apache.commons.logging.LogFactory;
! import org.dom4j.io.HTMLWriter;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;
import org.xml.sax.SAXException;
import xdoclet.*;
+ import java.io.*;
+
+ import java.net.URL;
+
/**
* Generator backed by <a
href="http://jakarta.apache.org/commons/sandbox/jelly/">Jelly</a>.
***************
*** 26,31 ****
* @version $Revision$
*/
! public class JellyPlugin extends ScriptPlugin
! {
/**
* Invokes Jelly to render a template.
--- 25,29 ----
* @version $Revision$
*/
! public class JellyPlugin extends ScriptPlugin {
/**
* Invokes Jelly to render a template.
***************
*** 34,48 ****
* @throws xdoclet.XDocletException
*/
! protected final void generate(File file) throws XDocletException
! {
try {
// Find the template
URL templateURL =
getXDoclet().getClasspathManager().getResource(getTemplateName());
! if( templateURL == null ) {
! throw new XDocletException("Couldn't find " + getTemplateName() + "
on the classpath: " + getXDoclet().getClasspathManager().getClasspath());
}
// Make a JellyContext holding all the context objects
JellyContext context = new JellyContext();
context.setVariables(getContextObjects());
--- 32,49 ----
* @throws xdoclet.XDocletException
*/
! protected final void generate(File file)
! throws XDocletException {
try {
// Find the template
URL templateURL =
getXDoclet().getClasspathManager().getResource(getTemplateName());
!
! if (templateURL == null) {
! throw new XDocletException("Couldn't find " + getTemplateName() + "
on the classpath: "
! + getXDoclet().getClasspathManager().getClasspath());
}
// Make a JellyContext holding all the context objects
JellyContext context = new JellyContext();
+
context.setVariables(getContextObjects());
***************
*** 50,89 ****
Writer writer = new FileWriter(file);
OutputFormat format = OutputFormat.createPrettyPrint();
! format.setEncoding( getEncoding() );
// Set pretty printing based on the file extension
! boolean isHtml = file.getName().endsWith( ".html" );
! final XMLWriter xmlWriter = (isHtml)
! ? new HTMLWriter(writer, format)
! : new XMLWriter(writer, format);
// Create the output
XMLOutput xmlOutput = new XMLOutput() {
! public void close() throws IOException {
! xmlWriter.close();
! }
! };
xmlOutput.setContentHandler(xmlWriter);
xmlOutput.setLexicalHandler(xmlWriter);
! xmlOutput.startDocument();
context.runScript(templateURL, xmlOutput);
! xmlOutput.endDocument();
writer.flush();
writer.close();
! }
! catch (JellyException e) {
LogFactory.getLog(JellyPlugin.class).error(e.getMessage(), e);
throw new XDocletException(e.getMessage(), e);
! }
! catch (SAXException e) {
LogFactory.getLog(JellyPlugin.class).error(e.getMessage(), e);
throw new XDocletException(e.getMessage(), e);
! }
! catch (IOException e) {
LogFactory.getLog(JellyPlugin.class).error(e.getMessage(), e);
throw new XDocletException(e.getMessage(), e);
}
}
! }
\ No newline at end of file
--- 51,88 ----
Writer writer = new FileWriter(file);
OutputFormat format = OutputFormat.createPrettyPrint();
!
! format.setEncoding(getEncoding());
// Set pretty printing based on the file extension
! boolean isHtml = file.getName().endsWith(".html");
! final XMLWriter xmlWriter = (isHtml) ? new HTMLWriter(writer, format) :
new XMLWriter(writer, format);
// Create the output
XMLOutput xmlOutput = new XMLOutput() {
! public void close()
! throws IOException {
! xmlWriter.close();
! }
! };
!
xmlOutput.setContentHandler(xmlWriter);
xmlOutput.setLexicalHandler(xmlWriter);
! xmlOutput.startDocument();
context.runScript(templateURL, xmlOutput);
! xmlOutput.endDocument();
writer.flush();
writer.close();
! } catch (JellyException e) {
LogFactory.getLog(JellyPlugin.class).error(e.getMessage(), e);
throw new XDocletException(e.getMessage(), e);
! } catch (SAXException e) {
LogFactory.getLog(JellyPlugin.class).error(e.getMessage(), e);
throw new XDocletException(e.getMessage(), e);
! } catch (IOException e) {
LogFactory.getLog(JellyPlugin.class).error(e.getMessage(), e);
throw new XDocletException(e.getMessage(), e);
}
}
! }
Index: ScriptPlugin.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet2/src/java/xdoclet/plugins/ScriptPlugin.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** ScriptPlugin.java 27 Feb 2003 00:13:01 -0000 1.1.1.1
--- ScriptPlugin.java 5 Mar 2003 22:27:10 -0000 1.2
***************
*** 1,8 ****
package xdoclet.plugins;
- import java.io.File;
-
- import xdoclet.XDocletException;
import xdoclet.Plugin;
/**
--- 1,8 ----
package xdoclet.plugins;
import xdoclet.Plugin;
+ import xdoclet.XDocletException;
+
+ import java.io.File;
/**
***************
*** 13,17 ****
*/
public abstract class ScriptPlugin extends Plugin {
-
/** Relative path to template (from one of the files/zips on the classpath). */
private String _templateName;
--- 13,16 ----
***************
*** 24,29 ****
* @param templateName name of the template to use during generation.
*/
! public void setTemplateName(String templateName)
! {
_templateName = templateName;
}
--- 23,27 ----
* @param templateName name of the template to use during generation.
*/
! public void setTemplateName(String templateName) {
_templateName = templateName;
}
***************
*** 35,40 ****
* @throws xdoclet.XDocletException if the templateName wasn't specified.
*/
! public final String getTemplateName() throws XDocletException
! {
return _templateName;
}
--- 33,38 ----
* @throws xdoclet.XDocletException if the templateName wasn't specified.
*/
! public final String getTemplateName()
! throws XDocletException {
return _templateName;
}
***************
*** 44,49 ****
* This method will put the collection on a context variable named ${classes}
and ${collection}.
*/
! protected final void generateOneFileForAll(File file) throws XDocletException
! {
generate(file);
}
--- 42,47 ----
* This method will put the collection on a context variable named ${classes}
and ${collection}.
*/
! protected final void generateOneFileForAll(File file)
! throws XDocletException {
generate(file);
}
***************
*** 53,58 ****
* This method will put the custom object on a context variable named ${custom}.
*/
! protected final void generateOneFileForEach(File file, Object object) throws
XDocletException
! {
generate(file);
}
--- 51,56 ----
* This method will put the custom object on a context variable named ${custom}.
*/
! protected final void generateOneFileForEach(File file, Object object)
! throws XDocletException {
generate(file);
}
***************
*** 63,66 ****
* @throws xdoclet.XDocletException if generation fails.
*/
! protected abstract void generate(File file) throws XDocletException;
}
--- 61,65 ----
* @throws xdoclet.XDocletException if generation fails.
*/
! protected abstract void generate(File file)
! throws XDocletException;
}
Index: VelocityPlugin.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet2/src/java/xdoclet/plugins/VelocityPlugin.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** VelocityPlugin.java 27 Feb 2003 00:13:02 -0000 1.1.1.1
--- VelocityPlugin.java 5 Mar 2003 22:27:10 -0000 1.2
***************
*** 5,18 ****
package xdoclet.plugins;
! import java.io.File;
! import java.io.FileWriter;
!
import org.apache.velocity.VelocityContext;
- import org.apache.velocity.runtime.resource.loader.JarResourceLoader;
- import org.apache.velocity.runtime.resource.loader.FileResourceLoader;
import org.apache.velocity.app.VelocityEngine;
- import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.exception.MethodInvocationException;
! import org.apache.commons.logging.LogFactory;
import xdoclet.*;
--- 5,15 ----
package xdoclet.plugins;
! import org.apache.commons.logging.LogFactory;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.exception.MethodInvocationException;
! import org.apache.velocity.exception.ResourceNotFoundException;
! import org.apache.velocity.runtime.resource.loader.FileResourceLoader;
! import org.apache.velocity.runtime.resource.loader.JarResourceLoader;
import xdoclet.*;
***************
*** 20,23 ****
--- 17,23 ----
import xdoclet.util.velocity.VelocityConfigurer;
+ import java.io.File;
+ import java.io.FileWriter;
+
/**
* Plugin backed by <a href="http://jakarta.apache.org/velocity/">Velocity</a>.
***************
*** 26,58 ****
* @version $Revision$
*/
! public class VelocityPlugin extends ScriptPlugin
! {
/** Shared among all instances. */
private static VelocityEngine _velocityEngine;
! /**
! * Sets the template name. Velocity will search for this template on
! * the classpath XDoclet was launched with.
! *
! * [EMAIL PROTECTED]
! */
! public void setTemplateName(String templateName)
! {
! super.setTemplateName( templateName );
! }
!
! public VelocityPlugin()
! {
// Initialises Velocity by registering a FileResourceLoader and a
JarResourceLoader that
// use the dirsctories and jar files supplied by the classpathManager.
VelocityConfigurer velocityConfigurer = new
VelocityConfigurer(getXDoclet().getClasspathManager());
// We're adding FileResourceLoader first, so users can easily override
templates
// by putting them earlier on the classpath
velocityConfigurer.addLoader(FileResourceLoader.class,
getXDoclet().getClasspathManager().getDirectories());
velocityConfigurer.addLoader(JarResourceLoader.class,
getXDoclet().getClasspathManager().getJars());
try {
_velocityEngine = velocityConfigurer.initVelocity();
! }
! catch (Exception e) {
// It's a shame Velocity doesn't throw more specific exceptions. Oh
well...
throw new IllegalStateException("Couldn't initialise Velocity: " +
e.getMessage());
--- 26,46 ----
* @version $Revision$
*/
! public class VelocityPlugin extends ScriptPlugin {
/** Shared among all instances. */
private static VelocityEngine _velocityEngine;
! public VelocityPlugin() {
// Initialises Velocity by registering a FileResourceLoader and a
JarResourceLoader that
// use the dirsctories and jar files supplied by the classpathManager.
VelocityConfigurer velocityConfigurer = new
VelocityConfigurer(getXDoclet().getClasspathManager());
+
// We're adding FileResourceLoader first, so users can easily override
templates
// by putting them earlier on the classpath
velocityConfigurer.addLoader(FileResourceLoader.class,
getXDoclet().getClasspathManager().getDirectories());
velocityConfigurer.addLoader(JarResourceLoader.class,
getXDoclet().getClasspathManager().getJars());
+
try {
_velocityEngine = velocityConfigurer.initVelocity();
! } catch (Exception e) {
// It's a shame Velocity doesn't throw more specific exceptions. Oh
well...
throw new IllegalStateException("Couldn't initialise Velocity: " +
e.getMessage());
***************
*** 61,64 ****
--- 49,62 ----
/**
+ * Sets the template name. Velocity will search for this template on
+ * the classpath XDoclet was launched with.
+ *
+ * [EMAIL PROTECTED]
+ */
+ public void setTemplateName(String templateName) {
+ super.setTemplateName(templateName);
+ }
+
+ /**
* Invokes Velocity to render a template.
*
***************
*** 66,97 ****
* @throws xdoclet.XDocletException
*/
! protected final void generate(File file) throws XDocletException
! {
try {
FileWriter writer = new FileWriter(file);
VelocityContext context = new VelocityContext(getContextObjects());
String templateName = getTemplateName();
if (templateName == null) {
throw new XDocletException("templateName was not specified");
}
LogFactory.getLog(getClass()).debug("Using templateName:" +
templateName);
_velocityEngine.mergeTemplate(templateName, getEncoding(), context,
writer);
writer.flush();
writer.close();
! }
! catch (ResourceNotFoundException e) {
// Unable to find resource 'path/to/template.vm'
LogFactory.getLog(getClass()).error(e.getMessage());
! LogFactory.getLog(getClass()).error("file.resource.loader.path:" +
_velocityEngine.getProperty("file.resource.loader.path"));
! LogFactory.getLog(getClass()).error("jar.resource.loader.path:" +
_velocityEngine.getProperty("jar.resource.loader.path"));
throw new XDocletException(e.getMessage(), e);
! }
! catch (MethodInvocationException e) {
Throwable t = e.getWrappedThrowable();
throw new XDocletException(t.getMessage(), t);
! }
! catch (Exception e) {
throw new XDocletException(e.getMessage(), e);
}
}
! }
\ No newline at end of file
--- 64,97 ----
* @throws xdoclet.XDocletException
*/
! protected final void generate(File file)
! throws XDocletException {
try {
FileWriter writer = new FileWriter(file);
VelocityContext context = new VelocityContext(getContextObjects());
String templateName = getTemplateName();
+
if (templateName == null) {
throw new XDocletException("templateName was not specified");
}
+
LogFactory.getLog(getClass()).debug("Using templateName:" +
templateName);
_velocityEngine.mergeTemplate(templateName, getEncoding(), context,
writer);
writer.flush();
writer.close();
! } catch (ResourceNotFoundException e) {
// Unable to find resource 'path/to/template.vm'
LogFactory.getLog(getClass()).error(e.getMessage());
! LogFactory.getLog(getClass()).error("file.resource.loader.path:"
! + _velocityEngine.getProperty("file.resource.loader.path"));
! LogFactory.getLog(getClass()).error("jar.resource.loader.path:"
! + _velocityEngine.getProperty("jar.resource.loader.path"));
throw new XDocletException(e.getMessage(), e);
! } catch (MethodInvocationException e) {
Throwable t = e.getWrappedThrowable();
+
throw new XDocletException(t.getMessage(), t);
! } catch (Exception e) {
throw new XDocletException(e.getMessage(), e);
}
}
! }
Index: XMLPlugin.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet2/src/java/xdoclet/plugins/XMLPlugin.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** XMLPlugin.java 27 Feb 2003 00:13:02 -0000 1.1.1.1
--- XMLPlugin.java 5 Mar 2003 22:27:10 -0000 1.2
***************
*** 1,25 ****
package xdoclet.plugins;
! import xdoclet.XDocletException;
import xdoclet.Plugin;
! //import xdoclet.plugins.CastorPlugin;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
! import java.util.*;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
! import org.xml.sax.helpers.DefaultHandler;
! import org.xml.sax.Attributes;
! import org.xml.sax.SAXParseException;
! import org.xml.sax.SAXException;
!
! import javax.xml.parsers.SAXParserFactory;
! import javax.xml.parsers.SAXParser;
! import javax.xml.parsers.ParserConfigurationException;
!
! import xjavadoc.XClass;
/**
--- 1,27 ----
package xdoclet.plugins;
! import org.xml.sax.Attributes;
! import org.xml.sax.SAXException;
! import org.xml.sax.SAXParseException;
! import org.xml.sax.helpers.DefaultHandler;
!
import xdoclet.Plugin;
! import xdoclet.XDocletException;
!
! import xjavadoc.XClass;
!
! import javax.xml.parsers.ParserConfigurationException;
! import javax.xml.parsers.SAXParser;
! import javax.xml.parsers.SAXParserFactory;
+ //import xdoclet.plugins.CastorPlugin;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
!
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
! import java.util.*;
/**
***************
*** 33,47 ****
*/
public abstract class XMLPlugin extends Plugin {
-
- public interface Delegate {
- public void generateForClasses(File file, Object root, Config config)
throws XDocletException;
- }
-
private final Map _configs = new HashMap();
-
private Config _config;
! protected XMLPlugin() throws XDocletException
! {
// Read the special xmlgenerator.xml descriptor. That's
// where we discover what configurations are available.
--- 35,42 ----
*/
public abstract class XMLPlugin extends Plugin {
private final Map _configs = new HashMap();
private Config _config;
! protected XMLPlugin() throws XDocletException {
// Read the special xmlgenerator.xml descriptor. That's
// where we discover what configurations are available.
***************
*** 51,54 ****
--- 46,50 ----
private void parse() throws XDocletException {
SAXParserFactory factory = SAXParserFactory.newInstance();
+
factory.setValidating(false);
***************
*** 58,62 ****
InputStream in = getClass().getResourceAsStream("xml/xmlgenerator.xml");
! if(in == null) {
throw new XDocletException("No xmlgenerator.xml along with " +
getClass().getName());
}
--- 54,58 ----
InputStream in = getClass().getResourceAsStream("xml/xmlgenerator.xml");
! if (in == null) {
throw new XDocletException("No xmlgenerator.xml along with " +
getClass().getName());
}
***************
*** 64,85 ****
parser.parse(in, new DescriptorHandler());
in.close();
! }
! catch (IOException e) {
e.printStackTrace();
throw new IllegalStateException("Error reading xmlgenerator.xml");
! }
! catch (IllegalArgumentException e) {
e.printStackTrace();
throw new IllegalStateException("Error reading xmlgenerator.xml");
! }
! catch (ParserConfigurationException e) {
e.printStackTrace();
throw new IllegalStateException("Error reading xmlgenerator.xml");
! }
! catch (SAXParseException e) {
e.printStackTrace();
! throw new IllegalStateException("SAXParseException at line=" +
e.getLineNumber() + " column=" + e.getColumnNumber() + " xmlgenerator.xml" );
! }
! catch (SAXException e) {
e.printStackTrace();
throw new IllegalStateException("Error reading xmlgenerator.xml");
--- 60,77 ----
parser.parse(in, new DescriptorHandler());
in.close();
! } catch (IOException e) {
e.printStackTrace();
throw new IllegalStateException("Error reading xmlgenerator.xml");
! } catch (IllegalArgumentException e) {
e.printStackTrace();
throw new IllegalStateException("Error reading xmlgenerator.xml");
! } catch (ParserConfigurationException e) {
e.printStackTrace();
throw new IllegalStateException("Error reading xmlgenerator.xml");
! } catch (SAXParseException e) {
e.printStackTrace();
! throw new IllegalStateException("SAXParseException at line=" +
e.getLineNumber() + " column="
! + e.getColumnNumber() + " xmlgenerator.xml");
! } catch (SAXException e) {
e.printStackTrace();
throw new IllegalStateException("Error reading xmlgenerator.xml");
***************
*** 87,99 ****
}
! protected void fill( Object root ) throws XDocletException {
throw new UnsupportedOperationException();
}
! protected void fill( Object root, XClass clazz ) throws XDocletException{
throw new UnsupportedOperationException();
}
! public final void generateOneFileForAll( File out ) throws XDocletException {
// create adaptee and adapter roots
Object[] roots = createRoots();
--- 79,94 ----
}
! protected void fill(Object root)
! throws XDocletException {
throw new UnsupportedOperationException();
}
! protected void fill(Object root, XClass clazz)
! throws XDocletException {
throw new UnsupportedOperationException();
}
! public final void generateOneFileForAll(File out)
! throws XDocletException {
// create adaptee and adapter roots
Object[] roots = createRoots();
***************
*** 103,110 ****
// write it out
! _config.getDelegate().generateForClasses( out, roots[1], _config );
}
! public final void generateForClass( File out, XClass clazz ) throws
XDocletException {
// create adaptee and adapter roots
Object[] roots = createRoots();
--- 98,106 ----
// write it out
! _config.getDelegate().generateForClasses(out, roots[1], _config);
}
! public final void generateForClass(File out, XClass clazz)
! throws XDocletException {
// create adaptee and adapter roots
Object[] roots = createRoots();
***************
*** 114,121 ****
// write it out
! _config.getDelegate().generateForClasses( out, roots[1], _config );
}
-
/**
* Sets the version to use. It's this value that decides whether the underlying
--- 110,116 ----
// write it out
! _config.getDelegate().generateForClasses(out, roots[1], _config);
}
/**
* Sets the version to use. It's this value that decides whether the underlying
***************
*** 124,137 ****
* @param version
*/
! public final void setVersion( String version ) throws XDocletException {
! _config = (Config) _configs.get( version );
! if( _config == null ) {
// Display the versions in sorted order
List versionList = new ArrayList(_configs.keySet());
Collections.sort(versionList);
StringBuffer versions = new StringBuffer();
! for(Iterator i = versionList.iterator(); i.hasNext();) {
versions.append(i.next()).append(" ");
}
throw new XDocletException("Unknown version:" + version + ". Supported
versions are: " + versions);
}
--- 119,138 ----
* @param version
*/
! public final void setVersion(String version)
! throws XDocletException {
! _config = (Config) _configs.get(version);
!
! if (_config == null) {
// Display the versions in sorted order
List versionList = new ArrayList(_configs.keySet());
+
Collections.sort(versionList);
+
StringBuffer versions = new StringBuffer();
!
! for (Iterator i = versionList.iterator(); i.hasNext();) {
versions.append(i.next()).append(" ");
}
+
throw new XDocletException("Unknown version:" + version + ". Supported
versions are: " + versions);
}
***************
*** 144,156 ****
* @throws xdoclet.XDocletException
*/
! private final Object[] createRoots() throws XDocletException {
try {
// Use reflection to instantiate the adaptee and adapter root objects
Object adapteeRoot = _config.getAdapteeClass().newInstance();
! Constructor adapterRootConstructor =
_config.getAdapterClass().getConstructor(new Class[]{_config.getAdapteeClass()});
! Object adapterRoot = adapterRootConstructor.newInstance(new Object[]
{adapteeRoot});
! return new Object[]{adapterRoot, adapteeRoot};
} catch (NoSuchMethodException e) {
throw new XDocletException(e);
--- 145,160 ----
* @throws xdoclet.XDocletException
*/
! private final Object[] createRoots()
! throws XDocletException {
try {
// Use reflection to instantiate the adaptee and adapter root objects
Object adapteeRoot = _config.getAdapteeClass().newInstance();
! Constructor adapterRootConstructor =
_config.getAdapterClass().getConstructor(new Class[] {
! _config.getAdapteeClass()
! });
! Object adapterRoot = adapterRootConstructor.newInstance(new Object[] {
adapteeRoot });
! return new Object[] { adapterRoot, adapteeRoot };
} catch (NoSuchMethodException e) {
throw new XDocletException(e);
***************
*** 168,184 ****
}
public static class Config {
public static final Delegate ZEUS = new ZeusPlugin();
- // public static final Delegate CASTOR = new CastorPlugin();
private Class _adapteeClass;
private Class _adapterClass;
private Delegate _delegate;
-
private String _docType;
private String _publicId;
private String _systemId;
! public Config(Class adapteeClass, Class adapterClass, Delegate delegate,
String docType, String publicId, String systemId ) {
_adapteeClass = adapteeClass;
_adapterClass = adapterClass;
--- 172,193 ----
}
+ public interface Delegate {
+ public void generateForClasses(File file, Object root, Config config)
+ throws XDocletException;
+ }
+
public static class Config {
public static final Delegate ZEUS = new ZeusPlugin();
+ // public static final Delegate CASTOR = new CastorPlugin();
private Class _adapteeClass;
private Class _adapterClass;
private Delegate _delegate;
private String _docType;
private String _publicId;
private String _systemId;
! public Config(Class adapteeClass, Class adapterClass, Delegate delegate,
String docType, String publicId,
! String systemId) {
_adapteeClass = adapteeClass;
_adapterClass = adapterClass;
***************
*** 192,198 ****
--- 201,209 ----
return _adapteeClass;
}
+
public Class getAdapterClass() {
return _adapterClass;
}
+
public Delegate getDelegate() {
return _delegate;
***************
*** 212,223 ****
}
! private class DescriptorHandler extends DefaultHandler
! {
! public void startElement(String namespaceURI, String localName, String
qName, Attributes attributes)
! {
if (qName.equals("xmlgenerator")) {
! String filename = attributes.getValue("filename").trim();
! XMLPlugin.this.setFileName(filename);
}
if (qName.equals("config")) {
String adapteePackage = attributes.getValue("adapteePackage").trim();
--- 223,234 ----
}
! private class DescriptorHandler extends DefaultHandler {
! public void startElement(String namespaceURI, String localName, String
qName, Attributes attributes) {
if (qName.equals("xmlgenerator")) {
! String filename = attributes.getValue("filename").trim();
!
! XMLPlugin.this.setFileName(filename);
}
+
if (qName.equals("config")) {
String adapteePackage = attributes.getValue("adapteePackage").trim();
***************
*** 231,243 ****
Delegate delegate;
! if(!publicId.equals("")) {
// Use Castor's conversion. It's on the classpath anyway.
delegate = Config.ZEUS;
! // rootJavaName =
org.exolab.castor.xml.JavaNaming.toJavaClassName(root);
} else {
! // delegate = Config.CASTOR;
delegate = null;
throw new Error("CASTOR NOT SUPPORTED YET");
-
}
--- 242,254 ----
Delegate delegate;
! if (!publicId.equals("")) {
// Use Castor's conversion. It's on the classpath anyway.
delegate = Config.ZEUS;
!
! // rootJavaName =
org.exolab.castor.xml.JavaNaming.toJavaClassName(root);
} else {
! // delegate = Config.CASTOR;
delegate = null;
throw new Error("CASTOR NOT SUPPORTED YET");
}
***************
*** 246,260 ****
Class adapterClass = Class.forName(adapterPackage + "." +
rootJavaName + "Adapter");
! Config config = new Config(
! adapteeClass,
! adapterClass,
! delegate,
! root,
! publicId,
! systemId
! );
XMLPlugin.this.addConfig(version, config);
! } catch(ClassNotFoundException e) {
e.printStackTrace();
}
--- 257,264 ----
Class adapterClass = Class.forName(adapterPackage + "." +
rootJavaName + "Adapter");
! Config config = new Config(adapteeClass, adapterClass, delegate,
root, publicId, systemId);
XMLPlugin.this.addConfig(version, config);
! } catch (ClassNotFoundException e) {
e.printStackTrace();
}
Index: ZeusPlugin.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet2/src/java/xdoclet/plugins/ZeusPlugin.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** ZeusPlugin.java 27 Feb 2003 00:13:02 -0000 1.1.1.1
--- ZeusPlugin.java 5 Mar 2003 22:27:10 -0000 1.2
***************
*** 7,12 ****
import java.io.FileWriter;
import java.io.Writer;
! import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
/**
--- 7,13 ----
import java.io.FileWriter;
import java.io.Writer;
!
import java.lang.reflect.InvocationTargetException;
+ import java.lang.reflect.Method;
/**
***************
*** 15,23 ****
* @author <a href="aslak.hellesoy at netcom.no">Aslak Hellesøy</a>
*/
! class ZeusPlugin implements XMLPlugin.Delegate
! {
public final void generateForClasses(File out, Object root, XMLPlugin.Config
config)
! throws XDocletException
! {
try {
FileWriter writer = new FileWriter(out);
--- 16,22 ----
* @author <a href="aslak.hellesoy at netcom.no">Aslak Hellesøy</a>
*/
! class ZeusPlugin implements XMLPlugin.Delegate {
public final void generateForClasses(File out, Object root, XMLPlugin.Config
config)
! throws XDocletException {
try {
FileWriter writer = new FileWriter(out);
***************
*** 25,47 ****
// We must use reflection. No API method available.
// But all Zeus classes have a marshal(Writer) method.
-
// Set the DTD declaration
// Method startDTD = root.getClass().getMethod( "startDTD",
new Class[]{String.class,String.class,String.class});
// startDTD.invoke( root, new Object[]{config.getDocType(),
config.getPublicId(), config.getSystemId()} );
-
// Write out the XML
! Method marshal = root.getClass().getMethod("marshal", new
Class[]{Writer.class});
! marshal.invoke(root, new Object[]{writer});
! }
! catch (NoSuchMethodException e) {
throw new XDocletException(e.getMessage(), e);
! }
! catch (InvocationTargetException e) {
throw new XDocletException(e.getMessage(), e);
! }
! catch (Exception e) {
throw new XDocletException(e.getMessage(), e);
}
}
! }
\ No newline at end of file
--- 24,41 ----
// We must use reflection. No API method available.
// But all Zeus classes have a marshal(Writer) method.
// Set the DTD declaration
// Method startDTD = root.getClass().getMethod( "startDTD",
new Class[]{String.class,String.class,String.class});
// startDTD.invoke( root, new Object[]{config.getDocType(),
config.getPublicId(), config.getSystemId()} );
// Write out the XML
! Method marshal = root.getClass().getMethod("marshal", new Class[] {
Writer.class });
! marshal.invoke(root, new Object[] { writer });
! } catch (NoSuchMethodException e) {
throw new XDocletException(e.getMessage(), e);
! } catch (InvocationTargetException e) {
throw new XDocletException(e.getMessage(), e);
! } catch (Exception e) {
throw new XDocletException(e.getMessage(), e);
}
}
! }
-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger
for complex code. Debugging C/C++ programs can leave you feeling lost and
disoriented. TotalView can help you find your way. Available on major UNIX
and Linux platforms. Try it free. www.etnus.com
_______________________________________________
xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel