Uploaded image for project: 'Commons Digester'
  1. Commons Digester
  2. DIGESTER-33

[PATCH] for SetTopRule.java to fix misleading debug message and other clarifications

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • Nightly Builds
    • None
    • None
    • Operating System: All
      Platform: All

    • 6043

    Description

      This patch addresses three items in SetTopRule.java,v 1.11

      The first item is a misleading debug message in end (). The patch replaces
      '[NULL PARENT]' with '[NULL CHILD]'.

      The second item comprises a few clarifications in the API docs for the
      constructors and elsewhere. The potential for misinterpreting 'parent method' as
      meaning a method of the parent object (which it's not) has been reduced with
      less ambiguous wording.

      The last change is a simple exchange of object names in end () to match the
      roles they have. Very useful if you are reading the class to understand it!

      This patch was generated against SetTopRule.java 1.11 and the test cases run
      okay.

      — SetTopRule.java-1.11 Sat Jan 26 00:06:20 2002
      +++ SetTopRule.java Sat Jan 26 00:08:38 2002
      @@ -71,8 +71,8 @@

      /**

      • * Rule implementation that calls a method on the top (parent)
      • * object, passing the (top-1) (child) object as an argument.
        + * Rule implementation that calls a method on the top (child)
        + * object, passing the (top-1) (parent) object as an argument.
        *
      • @author Craig McClanahan
      • @author Scott Sanders
        @@ -87,11 +87,12 @@

      /**

      • Construct a "set parent" rule with the specified method name. The
      • * parent method's argument type is assumed to be the class of the
      • * child object.
        + * "set parent" method's argument type is assumed to be the class of the
        + * parent object.
        *
      • @param digester The associated Digester
      • * @param methodName Method name of the parent method to call
        + * @param methodName Method name of the "set parent" method to call on
        + * the child object
        */
        public SetTopRule(Digester digester, String methodName) {

      @@ -104,8 +105,9 @@

      • Construct a "set parent" rule with the specified method name.
        *
      • @param digester The associated Digester
      • * @param methodName Method name of the parent method to call
      • * @param paramType Java class of the parent method's argument
        + * @param methodName Method name of the "set parent" method to call on
        + * the child object
        + * @param paramType Java class of the "set parent" method's argument
      • (if you wish to use a primitive type, specify the corresonding
      • Java wrapper class instead, such as <code>java.lang.Boolean</code>
      • for a <code>boolean</code> parameter)
        @@ -124,7 +126,7 @@

      /**

      • * The method name to call on the parent object.
        + * The method name to call on the child object.
        */
        protected String methodName = null;

      @@ -144,17 +146,17 @@
      public void end() throws Exception {

      // Identify the objects to be used

      • Object child = digester.peek(1);
      • Object parent = digester.peek(0);
        + Object child = digester.peek(0);
        + Object parent = digester.peek(1);
        if (digester.log.isDebugEnabled()) {
      • if (parent == null) {
        + if (child == null) {
        digester.log.debug("[SetTopRule] {" + digester.match + - "} Call [NULL PARENT]." +
        - methodName + "(" + child + ")");
        + "} Call [NULL CHILD]." +
        + methodName + "(" + parent + ")");
        } else {
        digester.log.debug("[SetTopRule]{" + digester.match +- "}

        Call " + parent.getClass().getName() + "." +

      • methodName + "(" + child + ")");
        + "} Call " + child.getClass().getName() + "." +
        + methodName + "(" + parent + ")");
        }
        }

      @@ -164,10 +166,10 @@
      paramTypes[0] =
      digester.getClassLoader().loadClass(paramType);
      } else

      { - paramTypes[0] = child.getClass(); + paramTypes[0] = parent.getClass(); }
      • MethodUtils.invokeExactMethod(parent, methodName,
      • new Object[] { child }

        , paramTypes);
        + MethodUtils.invokeExactMethod(child, methodName,
        + new Object[]

        { parent }

        , paramTypes);

      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            janekdb@yahoo.co.uk Janek Bogucki
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: