commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject cvs commit: jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io BeanCreateRule.java
Date Tue, 30 Jul 2002 20:12:47 GMT
mvdb        2002/07/30 13:12:47

  Modified:    betwixt/src/java/org/apache/commons/betwixt/io
                        BeanCreateRule.java
  Log:
  Now also allowing recursive elements. Ran into it a couple of times myself and so have others..
  TestCases will follow (fixing the writer before I add the testcase).
  
  Revision  Changes    Path
  1.8       +30 -8     jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/BeanCreateRule.java
  
  Index: BeanCreateRule.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/BeanCreateRule.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- BeanCreateRule.java	9 Jul 2002 21:50:31 -0000	1.7
  +++ BeanCreateRule.java	30 Jul 2002 20:12:47 -0000	1.8
  @@ -222,7 +222,6 @@
           }
       }
   
  -
       /**
        * Process the end of this element.
        */
  @@ -294,7 +293,7 @@
                   final ElementDescriptor childDescriptor = childDescriptors[i];
                   if (log.isTraceEnabled()) {
                       log.trace("Processing child " + childDescriptor);
  -                }	
  +                }
                   
                   String propertyName = childDescriptor.getPropertyName();
                   String qualifiedName = childDescriptor.getQualifiedName();
  @@ -303,7 +302,30 @@
                       continue;
                   }
                   String path = prefix + qualifiedName;
  -                
  +                // this code is for making sure that recursive elements
  +                // can also be used..
  +                if (qualifiedName.equals(currentDescriptor.getQualifiedName())) {
  +                    log.trace("Creating generic rule for recursive elements");
  +                    int index = -1;
  +                    if (childDescriptor.isWrapCollectionsInElement()) {
  +                        index = prefix.indexOf(qualifiedName);
  +                        if (index == -1) {
  +                            // shouldn't happen.. 
  +                            continue;
  +                        }
  +                        int removeSlash = prefix.endsWith("/")?1:0;
  +                        path = "*/" + prefix.substring(index, prefix.length()-removeSlash);
  +                    }else{
  +                        // we have a element/element type of thing..
  +                        ElementDescriptor[] desc = currentDescriptor.getElementDescriptors();
  +                        if (desc.length == 1) {
  +                            path = "*/"+desc[0].getQualifiedName();
  +                        }
  +                    }
  +                    Rule rule = new BeanCreateRule( childDescriptor, context, path);
  +                    addRule(path, rule);
  +                    continue;
  +                }
                   if ( childDescriptor.getUpdater() != null ) {
                       if (log.isTraceEnabled()) {
                           log.trace("Element has updater "
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message