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

        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        948d 18h 34m 1 Simone Tripodi 23/Jun/11 16:51
        Resolved Resolved Closed Closed
        12d 20h 1 Simone Tripodi 06/Jul/11 12:51
        Simone Tripodi made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Hide
        Simone Tripodi added a comment -

        included in Apache Commons Digester 3.0 release

        Show
        Simone Tripodi added a comment - included in Apache Commons Digester 3.0 release
        Simone Tripodi made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Assignee Simone Tripodi [ simone.tripodi ]
        Fix Version/s 1.8.2 [ 12313577 ]
        Resolution Fixed [ 1 ]
        Hide
        Simone Tripodi added a comment -

        Patch applied, see org.apache.commons.digester3.ExtendedBaseRules r1138914

        Show
        Simone Tripodi added a comment - Patch applied, see org.apache.commons.digester3.ExtendedBaseRules r1138914
        Simone Tripodi made changes -
        Fix Version/s 3.0 [ 12316679 ]
        Fix Version/s 2.2 [ 12315368 ]
        Hide
        Simone Tripodi added a comment -

        Hi Volker,
        apologizes but I wasn't able to manage that issue before
        Looking forward to publish 2.2 ASAP including the submitted patch, It would be nicer if you can provide in the patch also a TestCase that shows the benefit of the submitted code.
        Sorry but I'm not familiar with XML config, can you post here in the comments a sample that shows which is now allowed that was not admitted before?
        Many thanks in advance and apologizes once again,
        Simo

        Show
        Simone Tripodi added a comment - Hi Volker, apologizes but I wasn't able to manage that issue before Looking forward to publish 2.2 ASAP including the submitted patch, It would be nicer if you can provide in the patch also a TestCase that shows the benefit of the submitted code. Sorry but I'm not familiar with XML config, can you post here in the comments a sample that shows which is now allowed that was not admitted before? Many thanks in advance and apologizes once again, Simo
        Hide
        Volker Karlmeier added a comment -

        Hi Simone,

        why do you move this patch to the future ?
        Rahul told me to consider this patch in 2.1

        Regards

        Volker


        -------------------------------
        words a just some place to hide
        a wall that we can run behind..
        -------------------------------
        Volker Karlmeier
        Friedrich-Freye-Str. 61
        45481 Mlheim/Ruhr

        Tel. : (+49) 208-7785675
        Mobil: (+49) 176-21056587
        Mail : Volker@magiccode.eu

        Show
        Volker Karlmeier added a comment - Hi Simone, why do you move this patch to the future ? Rahul told me to consider this patch in 2.1 Regards Volker – ------------------------------- words a just some place to hide a wall that we can run behind.. ------------------------------- Volker Karlmeier Friedrich-Freye-Str. 61 45481 Mlheim/Ruhr Tel. : (+49) 208-7785675 Mobil: (+49) 176-21056587 Mail : Volker@magiccode.eu
        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 ]
        Hide
        Rahul Akolkar added a comment -

        Setting fix versions so this will be looked at before the next release.

        Show
        Rahul Akolkar added a comment - Setting fix versions so this will be looked at before the next release.
        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 ]
        Hide
        Volker Karlmeier added a comment -

        The above patch for ExtendedBaseRules provides the possibility of matching recursive patterns in subnodes.

        Show
        Volker Karlmeier added a comment - The above patch for ExtendedBaseRules provides the possibility of matching recursive patterns in subnodes.
        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