Commons Digester
  1. Commons Digester
  2. DIGESTER-131

[PATCH] commons-digester / Allow recursive match in ExtendedBaseRules.java (see patch)

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.0
    • Labels:
      None
    • Environment:

      all

      Description

      Recursive tags in XML-rules-file only work on root node. Nested nodes like the one below to not work.
      With the attached patch, it is possible to specify rules like
      <...>
      <...>
      <pattern value="*/properties">
      <object-create-rule classname="de.wsy.f4ja.alertbatches.configuration.alerting.alertingconfig.Properties" />
      <set-properties-rule />
      <set-next-rule methodname="addProperties"/>
      </pattern>

      <pattern value="*/property">
      <object-create-rule classname="de.wsy.f4ja.alertbatches.configuration.alerting.alertingconfig.Property" />
      <set-properties-rule />
      <set-next-rule methodname="addProperty" />
      </pattern>
      </...>
      </..>

        Activity

        Simone Tripodi made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Simone Tripodi made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Assignee Simone Tripodi [ simone.tripodi ]
        Fix Version/s 1.8.2 [ 12313577 ]
        Resolution Fixed [ 1 ]
        Simone Tripodi made changes -
        Fix Version/s 3.0 [ 12316679 ]
        Fix Version/s 2.2 [ 12315368 ]
        Simone Tripodi made changes -
        Fix Version/s 2.2 [ 12315368 ]
        Fix Version/s 2.1 [ 12313576 ]
        Rahul Akolkar made changes -
        Fix Version/s 1.8.2 [ 12313577 ]
        Fix Version/s 2.1 [ 12313576 ]
        Volker Karlmeier made changes -
        Description Index: /home/volker/workspace/commons-digester/src/java/org/apache/commons/digester/ExtendedBaseRules.java
        ===================================================================
        - --- /home/volker/workspace/commons-digester/src/java/org/apache/commons/digester/ExtendedBaseRules.java (revision 718060)
        +++ /home/volker/workspace/commons-digester/src/java/org/apache/commons/digester/ExtendedBaseRules.java (working copy)
        @@ -234,6 +234,32 @@
        ~ // we keep the list of universal matches separate
        ~ List universalList = new ArrayList(counter);

        + // Universal wildcards ('*') in the middle of the pattern-string
        + List recList = null;
        + int parentLastIndex=-1;
        + // temporary parentPattern
        + // we don't want to change anything....
        + String tempParentPattern = parentPattern;
        + // look for pattern. Here, we search the whole
        + // parent.
        + while ((parentLastIndex = tempParentPattern.lastIndexOf('/')) > -1 && recList == null) {
        + recList = (List) this.cache.get(tempParentPattern+"/*/"+pattern.substring(lastIndex+1));
        + if (recList != null) {
        + // when /*/-pattern-string is found, add method
        + // list to universalList.
        + // Digester will do the rest
        + universalList.addAll(recList);
        + } else {
        + // if not, shorten tempParent to move /*/ one position
        + // to the left.
        + // as last part of patttern is always added
        + // we make sure pattern is allowed anywhere.
        + tempParentPattern=parentPattern.substring(0, parentLastIndex);
        + }
        + + }
        + + ~ // Universal all wildards ('!*')
        ~ // These are always matched so always add them
        ~ List tempList = (List) this.cache.get("!*");
        Recursive tags in XML-rules-file only work on root node. Nested nodes like the one below to not work.
        With the attached patch, it is possible to specify rules like
        <...>
          <...>
            <pattern value="*/properties">
               <object-create-rule classname="de.wsy.f4ja.alertbatches.configuration.alerting.alertingconfig.Properties" />
               <set-properties-rule />
               <set-next-rule methodname="addProperties"/>
           </pattern>
         
           <pattern value="*/property">
               <object-create-rule classname="de.wsy.f4ja.alertbatches.configuration.alerting.alertingconfig.Property" />
               <set-properties-rule />
               <set-next-rule methodname="addProperty" />
          </pattern>
          </...>
        </..>
        Summary [PATCH] commons-digester / Allow recursive match in ExtendedBaseRules.java (see comments to patch) [PATCH] commons-digester / Allow recursive match in ExtendedBaseRules.java (see patch)
        Volker Karlmeier made changes -
        Field Original Value New Value
        Attachment ExtendedBaseRules.patch [ 12394021 ]
        Volker Karlmeier created issue -

          People

          • Assignee:
            Simone Tripodi
            Reporter:
            Volker Karlmeier
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 10m
              10m
              Remaining:
              Remaining Estimate - 10m
              10m
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development