CVS: xdoclet/modules/jdo/src/xdoclet/modules/jdo JdoTagsHandler.java,1.11,1.12

Marco Schulze <[email protected]>
Newsgroups gmane.comp.java.xdoclet.devel
Message-ID <[email protected]>
Update of /cvsroot/xdoclet/xdoclet/modules/jdo/src/xdoclet/modules/jdo
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19978/modules/jdo/src/xdoclet/modules/jdo

Modified Files:
	JdoTagsHandler.java 
Log Message:
The project-wide default-fetch-depth is now only applied, if the field is a member of at least one fetch-group.

Index: JdoTagsHandler.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet/modules/jdo/src/xdoclet/modules/jdo/JdoTagsHandler.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** JdoTagsHandler.java	20 Jul 2005 14:43:48 -0000	1.11
--- JdoTagsHandler.java	17 Sep 2005 22:44:43 -0000	1.12
***************
*** 6,15 ****
  
  import java.util.ArrayList;
- 
  import java.util.Collection;
  import java.util.Iterator;
  import java.util.Properties;
! 
! import xjavadoc.*;
  
  import xdoclet.SubTask;
--- 6,18 ----
  
  import java.util.ArrayList;
  import java.util.Collection;
+ import java.util.HashSet;
  import java.util.Iterator;
  import java.util.Properties;
! import java.util.Set;
! import xjavadoc.XClass;
! import xjavadoc.XDoc;
! import xjavadoc.XPackage;
! import xjavadoc.XTag;
  
  import xdoclet.SubTask;
***************
*** 31,34 ****
--- 34,50 ----
  
      /**
+      * @see   #cacheFieldsInFetchGroups
+      */
+     private XClass  cacheFieldsInFetchGroupsClass = null;
+     /**
+      * This Set stores all fields that are declared in the current class (cached in {@link
+      * #cacheFieldsInFetchGroupsClass}) to be included in a fetch-group. If a field is in no fetch-group, it is not
+      * contained in this Set. This Set is null if {@link #ifCurrentFieldIsInFetchGroup(String, Properties)} has not yet
+      * been called. If {@link #cacheFieldsInFetchGroupsClass} specifies a class that is different from {@link
+      * XDocletTagSupport#getCurrentClass()} then this Set needs to be recreated.
+      */
+     private Set     cacheFieldsInFetchGroups = null;
+ 
+     /**
       * The <code>forAllPackages</code> iterates through all packages, and generates the template if the
       * jdo.persistence-capable tag is present in at least one class in the package. <p>
***************
*** 179,182 ****
--- 195,231 ----
      }
  
+     public void ifCurrentFieldIsInFetchGroup(String template, Properties attributes) throws XDocletException
+     {
+         if (cacheFieldsInFetchGroupsClass != getCurrentClass())
+             cacheFieldsInFetchGroupsClass = null;
+ 
+         if (cacheFieldsInFetchGroupsClass == null || cacheFieldsInFetchGroups == null) {
+             if (cacheFieldsInFetchGroups == null)
+                 cacheFieldsInFetchGroups = new HashSet();
+             else
+                 cacheFieldsInFetchGroups.clear();
+ 
+             for (Iterator it = getCurrentClass().getDoc().getTags("jdo.fetch-group").iterator(); it.hasNext(); ) {
+                 XTag fgt = (XTag) it.next();
+                 String fieldStr = fgt.getAttributeValue("field-names");
+ 
+                 if (fieldStr != null) {
+                     String[] fieldNames = fieldStr.split(",");
+ 
+                     for (int i = 0; i < fieldNames.length; ++i) {
+                         String fieldName = fieldNames[i].replaceAll(" ", "");
+ 
+                         if (!cacheFieldsInFetchGroups.contains(fieldName))
+                             cacheFieldsInFetchGroups.add(fieldName);
+                     }
+                 }
+             }
+             cacheFieldsInFetchGroupsClass = getCurrentClass();
+         }
+ 
+         if (cacheFieldsInFetchGroups.contains(getCurrentField().getName()))
+             generate(template);
+     }
+ 
      protected void setCurrentVendorExtension(VendorExtension vendorExtension)
      {



-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. 
Download it for free - -and be entered to win a 42" plasma tv or your very
own Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.