Update of /cvsroot/xdoclet/xdoclet/modules/hibernate/src/xdoclet/modules/hibernate
In directory sc8-pr-cvs1:/tmp/cvs-serv32274

Modified Files:
        HibernateSubTask.java HibernateTagsHandler.java 
Log Message:
full support for Hibernate2 (based partially on Matt Raible's patch)
added support for joined-subclass
fixed various minor issues (inconsistency with DTD)

Index: HibernateSubTask.java
===================================================================
RCS file: 
/cvsroot/xdoclet/xdoclet/modules/hibernate/src/xdoclet/modules/hibernate/HibernateSubTask.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** HibernateSubTask.java       30 Dec 2002 14:08:33 -0000      1.3
--- HibernateSubTask.java       9 Mar 2003 04:04:41 -0000       1.4
***************
*** 8,15 ****
  
  import xjavadoc.XClass;
- 
- import xdoclet.TemplateSubTask;
  import xdoclet.XDocletException;
  
  import xdoclet.util.Translator;
  /**
--- 8,15 ----
  
  import xjavadoc.XClass;
  import xdoclet.XDocletException;
  
+ import xdoclet.XmlSubTask;
+ 
  import xdoclet.util.Translator;
  /**
***************
*** 23,32 ****
   */
  public class HibernateSubTask
!      extends TemplateSubTask
  {
  
      //~ Instance/static variables 
......................................................................................
  
!     public final static String DEFAULT_HIBERNATE_CLASS_PATTERN = "{0}";
  
      /**
--- 23,44 ----
   */
  public class HibernateSubTask
!      extends XmlSubTask
  {
  
+     public final static String DEFAULT_HIBERNATE_CLASS_PATTERN = "{0}";
+ 
      //~ Instance/static variables 
......................................................................................
  
!     private final static String HIBERNATE_PUBLICID_11 = "-//Hibernate/Hibernate 
Mapping DTD 1.1//EN";
! 
!     private final static String HIBERNATE_SYSTEMID_11 = 
"http://hibernate.sourceforge.net/hibernate-mapping-1.1.dtd";;
! 
!     private final static String DTD_FILE_NAME_11 = 
"resources/hibernate-mapping_1_1.dtd";
! 
!     private final static String HIBERNATE_PUBLICID_20 = "-//Hibernate/Hibernate 
Mapping DTD 2.0//EN";
! 
!     private final static String HIBERNATE_SYSTEMID_20 = 
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd";;
! 
!     private final static String DTD_FILE_NAME_20 = 
"resources/hibernate-mapping_2_0.dtd";
  
      /**
***************
*** 40,43 ****
--- 52,60 ----
      private static String GENERATED_HIBERNATE_FILE_NAME = "{0}.hbm.xml";
  
+     /**
+      * Defaults to Hibernate 1.1.
+      */
+     private String  hibernateVersion = HibernateVersion.HIBERNATE_1_1;
+ 
      //~ Constructors 
...................................................................................................
  
***************
*** 62,65 ****
--- 79,124 ----
      }
  
+     /**
+      * Get the Hibernate version
+      *
+      * @return
+      */
+     public String getVersion()
+     {
+         return hibernateVersion;
+     }
+ 
+     /**
+      * Sets the hibernate version to use. Legal values are "1.1" and "2.0".
+      *
+      * @param version
+      * @ant.not-required   No. Default is "1.1".
+      */
+     public void setVersion(HibernateVersion version)
+     {
+         hibernateVersion = version.getValue();
+     }
+ 
+     /**
+      * Generate Mapping file (*.hbm.xml)
+      *
+      * @exception XDocletException
+      */
+     public void execute() throws XDocletException
+     {
+ 
+         if (hibernateVersion.equals(HibernateVersion.HIBERNATE_1_1)) {
+             setPublicId(HIBERNATE_PUBLICID_11);
+             setSystemId(HIBERNATE_SYSTEMID_11);
+             setDtdURL(getClass().getResource(DTD_FILE_NAME_11));
+         }
+         else {
+             setPublicId(HIBERNATE_PUBLICID_20);
+             setSystemId(HIBERNATE_SYSTEMID_20);
+             setDtdURL(getClass().getResource(DTD_FILE_NAME_20));
+         }
+         startProcess();
+     }
+ 
      //~ Methods 
........................................................................................................
  
***************
*** 77,79 ****
--- 136,160 ----
      }
  
+     /**
+      * @author    <a href="mailto:[EMAIL PROTECTED]">Matt Raible</a>
+      * @created   February 23, 2003
+      */
+     public static class HibernateVersion extends 
org.apache.tools.ant.types.EnumeratedAttribute
+     {
+         public final static String HIBERNATE_1_1 = "1.1";
+ 
+         public final static String HIBERNATE_2_0 = "2.0";
+ 
+         /**
+          * Gets the Values attribute of the HibernateVersion object
+          *
+          * @return   The Values value
+          */
+         public java.lang.String[] getValues()
+         {
+             return (new java.lang.String[]{
+                 HIBERNATE_1_1, HIBERNATE_2_0
+                 });
+         }
+     }
  }

Index: HibernateTagsHandler.java
===================================================================
RCS file: 
/cvsroot/xdoclet/xdoclet/modules/hibernate/src/xdoclet/modules/hibernate/HibernateTagsHandler.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** HibernateTagsHandler.java   6 Mar 2003 13:06:43 -0000       1.7
--- HibernateTagsHandler.java   9 Mar 2003 04:04:41 -0000       1.8
***************
*** 72,80 ****
          MethodIterator methodIterator = 
XCollections.methodIterator(clazz.getMethods(true));
  
-         XMethod method;
- 
          // iterate through all the methods defined in this class
          while (methodIterator.hasNext()) {
!             method = methodIterator.next();
              if (method.getDoc().hasTag("hibernate.id")) {
                  return method;
--- 72,79 ----
          MethodIterator methodIterator = 
XCollections.methodIterator(clazz.getMethods(true));
  
          // iterate through all the methods defined in this class
          while (methodIterator.hasNext()) {
!             XMethod method = methodIterator.next();
! 
              if (method.getDoc().hasTag("hibernate.id")) {
                  return method;
***************
*** 190,196 ****
      }
  
      /**
!      * 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
--- 189,200 ----
      }
  
+     public void logMapping(Properties attributes) throws XDocletException
+     {
+         System.out.println("   " + getCurrentClass().getQualifiedName());
+     }
+ 
      /**
!      * Iterates over all classes loaded by javadoc and evaluates the body of the tag 
for each class. It discards classes
!      * that have an xdoclet-generated class tag defined.
       *
       * @param template              The body of the block tag
***************
*** 219,238 ****
  
          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.");
!                 }
              }
          }
--- 223,248 ----
  
          for (ClassIterator i = XCollections.classIterator(classes); i.hasNext(); ) {
!             XClass clazz = i.next();
! 
!             log.debug("clazz=" + clazz);
  
!             if (DocletSupport.isDocletGenerated(clazz) || (clazz.isAbstract() && 
acceptAbstractClasses == false)) {
                  log.debug("isDocletGenerated or isAbstract");
              }
!             else if (clazz.getSuperclass().getQualifiedName().equals(typeName)) {
!                 log.debug("isOfType true, generate().");
! 
!                 XClass current = getCurrentClass();
! 
!                 pushCurrentClass(clazz);
!                 generate(template);
!                 popCurrentClass();
! 
!                 if (getCurrentClass() != current)
!                     setCurrentClass(current);
!                 //TODO: why do we need this?!
!             }
!             else {
!                 log.debug("isOfType false.");
              }
          }
***************
*** 315,319 ****
          }
  
!         setCurrentClass(oldClass);
      }
  
--- 325,331 ----
          }
  
!         if (getCurrentClass() != oldClass)
!             setCurrentClass(oldClass);
!         //TODO: Why do we need this!!??
      }
  



-------------------------------------------------------
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

Reply via email to