Update of /cvsroot/xdoclet/xdoclet/modules/hibernate/src/cirrus/hibernate/tools/xdoclet
In directory
sc8-pr-cvs1:/tmp/cvs-serv9767/modules/hibernate/src/cirrus/hibernate/tools/xdoclet
Added Files:
HibernateDocletTask.java HibernateSubTask.java
HibernateTagsHandler.java XDocletModulesHibernateMessages.java
Log Message:
Initial import of the xdoclet hibernate module.
--- NEW FILE: HibernateDocletTask.java ---
/*
* Copyright (c) 2001, 2002 The XDoclet team
* All rights reserved.
*/
package cirrus.hibernate.tools.xdoclet;
import xdoclet.DocletTask;
/**
* @author S�bastien Guimont ([EMAIL PROTECTED])
* @created August 9th, 2002
* @version $Revision: 1.2 $
* @ant.element name="hibernatedoclet" display-name="Hibernate Task"
*/
public class HibernateDocletTask extends DocletTask
{
}
--- NEW FILE: HibernateSubTask.java ---
/*
* Copyright (c) 2001, 2002 The XDoclet team
* All rights reserved.
*/
package cirrus.hibernate.tools.xdoclet;
import xdoclet.TemplateSubTask;
import xdoclet.XDocletException;
import xdoclet.util.Translator;
/**
* Generates Hibernate xml mapping file for a given class.
*
* @author S�bastien Guimont ([EMAIL PROTECTED])
* @created August 9th, 2002
* @version $Revision: 1.2 $
* @ant.element name="hibernate" display-name="Hibernate Mapping File"
* parent="cirrus.hibernate.tools.xdoclet.HibernateDocletTask"
*/
public class HibernateSubTask
extends TemplateSubTask
{
//~ Instance/static variables
......................................................................................
public final static String DEFAULT_HIBERNATE_CLASS_PATTERN = "{0}";
/**
* Default template to use for hibernate files
*/
private static String DEFAULT_HIBERNATE_TEMPLATE_FILE = "resources/hibernate.xdt";
/**
* Pattern for generation of hibernate files
*/
private static String GENERATED_HIBERNATE_FILE_NAME = "{0}.hbm.xml";
//~ Constructors
...................................................................................................
/**
* Constructor for the HibernateSubTask object
*/
public HibernateSubTask()
{
setHavingClassTag("hibernate.class");
setTemplateURL(getClass().getResource(DEFAULT_HIBERNATE_TEMPLATE_FILE));
setDestinationFile(GENERATED_HIBERNATE_FILE_NAME);
}
//~ Methods
........................................................................................................
/**
* Called when the engine is started
*
* @exception XDocletException Thrown in case of problem
*/
protected void engineStarted()
throws XDocletException
{
System.out.println(Translator.getString(XDocletModulesHibernateMessages.class,
XDocletModulesHibernateMessages.GENERATING_HIBERNATE_FOR,
new String[]{getCurrentClass().getQualifiedName()}));
}
}
--- NEW FILE: HibernateTagsHandler.java ---
/*
* Copyright (c) 2001, 2002 The XDoclet team
* All rights reserved.
*/
package cirrus.hibernate.tools.xdoclet;
import java.util.Collection;
import java.util.Properties;
import org.apache.commons.logging.Log;
import xdoclet.DocletSupport;
import xdoclet.XDocletException;
import xdoclet.XDocletTagSupport;
import xdoclet.tagshandler.ClassTagsHandler;
import xdoclet.util.LogUtil;
import xdoclet.util.TypeConversionUtil;
import xjavadoc.ClassIterator;
import xjavadoc.XClass;
import xjavadoc.XCollections;
/**
* Specific tags handler to make the template easy.
*
* @author S�bastien Guimont ([EMAIL PROTECTED])
* @created August 9th, 2002
* @version $Revision: 1.2 $
* @xdoclet.taghandler namespace="Hibernate"
*/
public class HibernateTagsHandler
extends XDocletTagSupport
{
//~ Methods
........................................................................................................
/**
* Returns full path of hibernate file for the current class.
*
* @return The full file path of the current class.
* @exception XDocletException
* @doc.tag type="content"
*/
public String getFileName()
throws XDocletException
{
StringBuffer fileName = new StringBuffer(getCurrentClass().getQualifiedName());
int stringLength = fileName.length();
for (int i = 0; i < stringLength; i++) {
if (fileName.charAt(i) == '.') {
fileName.setCharAt(i, '/');
}
}
return fileName.toString();
}
/**
* Iterates over all classes loaded by javadoc and evaluates the body of the tag
for each class. It descards classes
* that have a xdoclet-generated class tag defined.
*
* @param template The body of the block tag
* @param attributes The attributes of the template tag
* @exception XDocletException Description of Exception
* @doc.tag type="block"
* @doc.param name="abstract" optional="true"
values="true,false" description="If true then accept
* abstract classes also; otherwise don't."
* @doc.param name="type" optional="false" description="For all
classes that are extends by the
* type."
*/
public void forAllClasses(String template, Properties attributes) throws
XDocletException
{
Log log = LogUtil.getLog(HibernateTagsHandler.class, "forAllClasses");
String abstractStr = attributes.getProperty("abstract");
boolean acceptAbstractClasses =
TypeConversionUtil.stringToBoolean(abstractStr, true);
String typeName = attributes.getProperty("type");
if (log.isDebugEnabled()) {
log.debug("acceptAbstractClasses=" + acceptAbstractClasses);
log.debug("typeName=" + typeName);
}
Collection classes = ClassTagsHandler.getAllClasses();
for (ClassIterator i = XCollections.classIterator(classes); i.hasNext(); ) {
XClass currentClass = i.next();
setCurrentClass(currentClass);
log.debug("currentClass=" + currentClass);
if (DocletSupport.isDocletGenerated(getCurrentClass()) ||
(getCurrentClass().isAbstract() && acceptAbstractClasses == false)) {
log.debug("isDocletGenerated or isAbstract");
continue;
}
if (typeName != null) {
if
(getCurrentClass().getSuperclass().getQualifiedName().equals(typeName)) {
log.debug("isOfType true, generate().");
generate(template);
}
else {
log.debug("isOfType false.");
}
}
}
}
}
--- NEW FILE: XDocletModulesHibernateMessages.java ---
/*
* Copyright (c) 2001, 2002 The XDoclet team
* All rights reserved.
*/
package cirrus.hibernate.tools.xdoclet;
/**
* @author S�bastien Guimont ([EMAIL PROTECTED])
* @created August 9th, 2002
* @version $Revision: 1.2 $
*/
public final class XDocletModulesHibernateMessages
{
//~ Instance/static variables
......................................................................................
/**
* @msg.bundle msg="Generating mapping file for {0}."
*/
public final static String GENERATING_HIBERNATE_FOR = "GENERATING_HIBERNATE_FOR";
}
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel