commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject cvs commit: jakarta-commons/betwixt/src/java/org/apache/commons/betwixt ElementDescriptor.java
Date Tue, 27 Apr 2004 20:01:33 GMT
rdonkin     2004/04/27 13:01:33

  Modified:    betwixt/src/java/org/apache/commons/betwixt Tag:
                        REFACTORING-BRANCH_2004-01-13
                        ElementDescriptor.java
  Log:
  Added support for array property setters
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.14.2.7  +17 -17    jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/ElementDescriptor.java
  
  Index: ElementDescriptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/ElementDescriptor.java,v
  retrieving revision 1.14.2.6
  retrieving revision 1.14.2.7
  diff -u -r1.14.2.6 -r1.14.2.7
  --- ElementDescriptor.java	19 Apr 2004 21:31:13 -0000	1.14.2.6
  +++ ElementDescriptor.java	27 Apr 2004 20:01:33 -0000	1.14.2.7
  @@ -335,6 +335,11 @@
       
       /**
         * Gets a child ElementDescriptor matching the given name if one exists.
  +      * Note that (so long as there are no better matches), a null name
  +      * acts as a wildcard. In other words, an 
  +      * <code>ElementDescriptor</code> the first descriptor 
  +      * with a null name will match any name
  +      * passed in, unless some other matches the name exactly.
         *
         * @param name the localname to be matched, not null
         * @returns the child ElementDescriptor with the given name if one exists, 
  @@ -343,25 +348,20 @@
       public ElementDescriptor getElementDescriptor(String name) {
       
           ElementDescriptor elementDescriptor = null;
  +        ElementDescriptor descriptorWithNullName = null;
           ElementDescriptor[] elementDescriptors = getElementDescriptors();
           for (int i=0, size=elementDescriptors.length; i<size; i++) {
  -            if (name.equals(elementDescriptors[i].getQualifiedName())) {
  +            String elementName = elementDescriptors[i].getQualifiedName();
  +            if (name.equals(elementName)) {
                   elementDescriptor = elementDescriptors[i];
                   break;
               }
  -            else {
  -                // workaround for wrapped collections
  -                // really, should probably have silent elements (which aren't expressed)
  -                if (!elementDescriptors[i].isWrapCollectionsInElement() && 
  -                    elementDescriptors[i].isCollective()) {
  -
  -                    ElementDescriptor grandchild = elementDescriptors[i].getElementDescriptor(name);
  -                    if (grandchild != null) {
  -                        elementDescriptor = grandchild;
  -                        break;
  -                    }
  -                }
  +            if (descriptorWithNullName == null && elementName == null) {
  +                descriptorWithNullName = elementDescriptors[i];
               }
  +        }
  +        if (elementDescriptor == null) {
  +            elementDescriptor = descriptorWithNullName;
           }
           return elementDescriptor;
       }
  
  
  

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


Mime
View raw message