You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2011/05/10 07:42:23 UTC

svn commit: r1101317 - in /commons/sandbox/digester3/trunk/src: main/java/org/apache/commons/digester3/ main/java/org/apache/commons/digester3/xmlrules/ test/java/org/apache/commons/digester3/

Author: simonetripodi
Date: Tue May 10 05:42:22 2011
New Revision: 1101317

URL: http://svn.apache.org/viewvc?rev=1101317&view=rev
Log:
removed deprecated methods from Rule and related subclasses

Modified:
    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/CallMethodRule.java
    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/CallParamRule.java
    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/NodeCreateRule.java
    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/ObjectCreateRule.java
    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/Rule.java
    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetNestedPropertiesRule.java
    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetNextRule.java
    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetPropertiesRule.java
    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetPropertyRule.java
    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetRootRule.java
    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetTopRule.java
    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/xmlrules/DigesterRuleParser.java
    commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/TestRule.java

Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/CallMethodRule.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/CallMethodRule.java?rev=1101317&r1=1101316&r2=1101317&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/CallMethodRule.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/CallMethodRule.java Tue May 10 05:42:22 2011
@@ -467,7 +467,7 @@ public class CallMethodRule extends Rule
      * @param attributes The attribute list for this element
      */
     @Override
-    public void begin(Attributes attributes) throws Exception {
+    public void begin(String namespace, String name, Attributes attributes) throws Exception {
 
         // Push an array to capture the parameter values if necessary
         if (paramCount > 0) {
@@ -487,10 +487,10 @@ public class CallMethodRule extends Rule
      * @param bodyText The body text of this element
      */
     @Override
-    public void body(String bodyText) throws Exception {
+    public void body(String namespace, String name, String text) throws Exception {
 
         if (paramCount == 0) {
-            this.bodyText = bodyText.trim();
+            this.bodyText = text.trim();
         }
 
     }
@@ -500,7 +500,7 @@ public class CallMethodRule extends Rule
      * Process the end of this element.
      */
     @Override
-    public void end() throws Exception {
+    public void end(String namespace, String name) throws Exception {
 
         // Retrieve or construct the parameter values array
         Object parameters[] = null;

Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/CallParamRule.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/CallParamRule.java?rev=1101317&r1=1101316&r2=1101317&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/CallParamRule.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/CallParamRule.java Tue May 10 05:42:22 2011
@@ -194,7 +194,7 @@ public class CallParamRule extends Rule 
      * @param attributes The attribute list for this element
      */
     @Override
-    public void begin(Attributes attributes) throws Exception {
+    public void begin(String namespace, String name, Attributes attributes) throws Exception {
 
         Object param = null;
         
@@ -235,7 +235,7 @@ public class CallParamRule extends Rule 
      * @param bodyText The body text of this element
      */
     @Override
-    public void body(String bodyText) throws Exception {
+    public void body(String namespace, String name, String text) throws Exception {
 
         if (attributeName == null && !fromStack) {
             // We must wait to set the parameter until end
@@ -244,7 +244,7 @@ public class CallParamRule extends Rule 
             if (bodyTextStack == null) {
                 bodyTextStack = new Stack<String>();
             }
-            bodyTextStack.push(bodyText.trim());
+            bodyTextStack.push(text.trim());
         }
 
     }

Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/NodeCreateRule.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/NodeCreateRule.java?rev=1101317&r1=1101316&r2=1101317&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/NodeCreateRule.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/NodeCreateRule.java Tue May 10 05:42:22 2011
@@ -469,7 +469,7 @@ public class NodeCreateRule extends Rule
      * Pop the Node off the top of the stack.
      */
     @Override
-    public void end() throws Exception {
+    public void end(String namespace, String name) throws Exception {
 
         digester.pop();
 

Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/ObjectCreateRule.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/ObjectCreateRule.java?rev=1101317&r1=1101316&r2=1101317&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/ObjectCreateRule.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/ObjectCreateRule.java Tue May 10 05:42:22 2011
@@ -191,7 +191,7 @@ public class ObjectCreateRule extends Ru
      * @param attributes The attribute list of this element
      */
     @Override
-    public void begin(Attributes attributes) throws Exception {
+    public void begin(String namespace, String name, Attributes attributes) throws Exception {
 
         // Identify the name of the class to instantiate
         String realClassName = className;
@@ -218,7 +218,7 @@ public class ObjectCreateRule extends Ru
      * Process the end of this element.
      */
     @Override
-    public void end() throws Exception {
+    public void end(String namespace, String name) throws Exception {
 
         Object top = digester.pop();
         if (digester.log.isDebugEnabled()) {

Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/Rule.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/Rule.java?rev=1101317&r1=1101316&r2=1101317&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/Rule.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/Rule.java Tue May 10 05:42:22 2011
@@ -52,31 +52,6 @@ import org.xml.sax.Attributes;
 
 public abstract class Rule {
 
-
-    // ----------------------------------------------------------- Constructors
-
-
-    /**
-     * Constructor sets the associated Digester.
-     *
-     * @param digester The digester with which this rule is associated
-     * @deprecated The digester instance is now set in the {@link Digester#addRule} method. Use {@link #Rule()} instead.
-     */
-    @Deprecated
-    public Rule(Digester digester) {
-
-        super();
-        setDigester(digester);
-
-    }
-    
-    /**
-     * <p>Base constructor.
-     * Now the digester will be set when the rule is added.</p>
-     */
-    public Rule() {}
-
-
     // ----------------------------------------------------- Instance Variables
 
 
@@ -141,23 +116,6 @@ public abstract class Rule {
 
     /**
      * This method is called when the beginning of a matching XML element
-     * is encountered.
-     *
-     * @param attributes The attribute list of this element
-     * @deprecated Use the {@link #begin(String,String,Attributes) begin}
-     *   method with <code>namespace</code> and <code>name</code>
-     *   parameters instead.
-     */
-    @Deprecated
-    public void begin(Attributes attributes) throws Exception {
-
-        // The default implementation does nothing
-
-    }
-
-
-    /**
-     * This method is called when the beginning of a matching XML element
      * is encountered. The default implementation delegates to the deprecated
      * method {@link #begin(Attributes) begin} without the 
      * <code>namespace</code> and <code>name</code> parameters, to retain 
@@ -174,24 +132,6 @@ public abstract class Rule {
     public void begin(String namespace, String name, Attributes attributes)
         throws Exception {
 
-        begin(attributes);
-
-    }
-
-
-    /**
-     * This method is called when the body of a matching XML element
-     * is encountered.  If the element has no body, this method is
-     * called with an empty string as the body text.
-     *
-     * @param text The text of the body of this element
-     * @deprecated Use the {@link #body(String,String,String) body} method
-     *   with <code>namespace</code> and <code>name</code> parameters
-     *   instead.
-     */
-    @Deprecated
-    public void body(String text) throws Exception {
-
         // The default implementation does nothing
 
     }
@@ -217,21 +157,6 @@ public abstract class Rule {
     public void body(String namespace, String name, String text)
         throws Exception {
 
-        body(text);
-
-    }
-
-
-    /**
-     * This method is called when the end of a matching XML element
-     * is encountered.
-     * 
-     * @deprecated Use the {@link #end(String,String) end} method with 
-     *   <code>namespace</code> and <code>name</code> parameters instead.
-     */
-    @Deprecated
-    public void end() throws Exception {
-
         // The default implementation does nothing
 
     }
@@ -254,7 +179,7 @@ public abstract class Rule {
     public void end(String namespace, String name)
         throws Exception {
 
-        end();
+        // The default implementation does nothing
 
     }
 

Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetNestedPropertiesRule.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetNestedPropertiesRule.java?rev=1101317&r1=1101316&r2=1101317&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetNestedPropertiesRule.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetNestedPropertiesRule.java Tue May 10 05:42:22 2011
@@ -261,7 +261,7 @@ public class SetNestedPropertiesRule ext
      * child-element-matching.
      */
     @Override
-    public void body(String bodyText) throws Exception {
+    public void body(String namespace, String name, String text) throws Exception {
         AnyChildRules newRules = (AnyChildRules) digester.getRules();
         digester.setRules(newRules.getOldRules());
     }
@@ -397,7 +397,7 @@ public class SetNestedPropertiesRule ext
         }
         
         @Override
-        public void body(String value) throws Exception {
+        public void body(String namespace, String name, String text) throws Exception {
             String propName = currChildElementName;
             if (elementNames.containsKey(currChildElementName)) {
                 // overide propName
@@ -413,7 +413,7 @@ public class SetNestedPropertiesRule ext
             if (debug) {
                 log.debug("[SetNestedPropertiesRule]{" + digester.match +
                         "} Setting property '" + propName + "' to '" +
-                        value + "'");
+                        text + "'");
             }
     
             // Populate the corresponding properties of the top object
@@ -430,7 +430,7 @@ public class SetNestedPropertiesRule ext
             }
  
             if (trimData) {
-                value = value.trim();
+                text = text.trim();
             }
 
             if (!allowUnknownChildElements) {
@@ -455,11 +455,11 @@ public class SetNestedPropertiesRule ext
             
             try
             {
-            BeanUtils.setProperty(top, propName, value);
+            BeanUtils.setProperty(top, propName, text);
             }
             catch(NullPointerException e) {
                 log.error("NullPointerException: "
-                 + "top=" + top + ",propName=" + propName + ",value=" + value + "!");
+                 + "top=" + top + ",propName=" + propName + ",value=" + text + "!");
                  throw e;
             }
         }

Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetNextRule.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetNextRule.java?rev=1101317&r1=1101316&r2=1101317&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetNextRule.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetNextRule.java Tue May 10 05:42:22 2011
@@ -184,7 +184,7 @@ public class SetNextRule extends Rule {
      * Process the end of this element.
      */
     @Override
-    public void end() throws Exception {
+    public void end(String namespace, String name) throws Exception {
 
         // Identify the objects to be used
         Object child = digester.peek(0);

Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetPropertiesRule.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetPropertiesRule.java?rev=1101317&r1=1101316&r2=1101317&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetPropertiesRule.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetPropertiesRule.java Tue May 10 05:42:22 2011
@@ -163,7 +163,7 @@ public class SetPropertiesRule extends R
      * @param attributes The attribute list of this element
      */
     @Override
-    public void begin(Attributes attributes) throws Exception {
+    public void begin(String namespace, String name, Attributes attributes) throws Exception {
         
         // Build a set of attribute names and corresponding values
         HashMap<String, String> values = new HashMap<String, String>();
@@ -180,23 +180,23 @@ public class SetPropertiesRule extends R
         
         
         for (int i = 0; i < attributes.getLength(); i++) {
-            String name = attributes.getLocalName(i);
-            if ("".equals(name)) {
-                name = attributes.getQName(i);
+            String attributeName = attributes.getLocalName(i);
+            if ("".equals(attributeName)) {
+                attributeName = attributes.getQName(i);
             }
             String value = attributes.getValue(i);
             
             // we'll now check for custom mappings
             for (int n = 0; n<attNamesLength; n++) {
-                if (name.equals(attributeNames[n])) {
+                if (attributeName.equals(attributeNames[n])) {
                     if (n < propNamesLength) {
                         // set this to value from list
-                        name = propertyNames[n];
+                        attributeName = propertyNames[n];
                     
                     } else {
                         // set name to null
                         // we'll check for this later
-                        name = null;
+                        attributeName = null;
                     }
                     break;
                 }
@@ -204,11 +204,11 @@ public class SetPropertiesRule extends R
             
             if (digester.log.isDebugEnabled()) {
                 digester.log.debug("[SetPropertiesRule]{" + digester.match +
-                        "} Setting property '" + name + "' to '" +
+                        "} Setting property '" + attributeName + "' to '" +
                         value + "'");
             }
             
-            if ((!ignoreMissingProperty) && (name != null)) {
+            if ((!ignoreMissingProperty) && (attributeName != null)) {
                 // The BeanUtils.populate method silently ignores items in
                 // the map (ie xml entities) which have no corresponding
                 // setter method, so here we check whether each xml attribute
@@ -229,13 +229,13 @@ public class SetPropertiesRule extends R
                 // compatible so we'll accept the risk here.
                 
                 Object top = digester.peek();
-                boolean test =  PropertyUtils.isWriteable(top, name);
+                boolean test =  PropertyUtils.isWriteable(top, attributeName);
                 if (!test)
-                    throw new NoSuchMethodException("Property " + name + " can't be set");
+                    throw new NoSuchMethodException("Property " + attributeName + " can't be set");
             }
             
-            if (name != null) {
-                values.put(name, value);
+            if (attributeName != null) {
+                values.put(attributeName, value);
             } 
         }
 

Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetPropertyRule.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetPropertyRule.java?rev=1101317&r1=1101316&r2=1101317&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetPropertyRule.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetPropertyRule.java Tue May 10 05:42:22 2011
@@ -103,7 +103,7 @@ public class SetPropertyRule extends Rul
      *  have a writeable property of the specified name
      */
     @Override
-    public void begin(Attributes attributes) throws Exception {
+    public void begin(String namespace, String name, Attributes attributes) throws Exception {
 
         if (attributes.getLength() == 0 ) {
             return;
@@ -113,14 +113,14 @@ public class SetPropertyRule extends Rul
         String actualName = null;
         String actualValue = null;
         for (int i = 0; i < attributes.getLength(); i++) {
-            String name = attributes.getLocalName(i);
-            if ("".equals(name)) {
-                name = attributes.getQName(i);
+            String attributeName = attributes.getLocalName(i);
+            if ("".equals(attributeName)) {
+                attributeName = attributes.getQName(i);
             }
             String value = attributes.getValue(i);
-            if (name.equals(this.name)) {
+            if (attributeName.equals(this.name)) {
                 actualName = value;
-            } else if (name.equals(this.value)) {
+            } else if (attributeName.equals(this.value)) {
                 actualValue = value;
             }
         }

Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetRootRule.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetRootRule.java?rev=1101317&r1=1101316&r2=1101317&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetRootRule.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetRootRule.java Tue May 10 05:42:22 2011
@@ -177,7 +177,7 @@ public class SetRootRule extends Rule {
      * Process the end of this element.
      */
     @Override
-    public void end() throws Exception {
+    public void end(String namespace, String name) throws Exception {
 
         // Identify the objects to be used
         Object child = digester.peek(0);

Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetTopRule.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetTopRule.java?rev=1101317&r1=1101316&r2=1101317&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetTopRule.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetTopRule.java Tue May 10 05:42:22 2011
@@ -175,7 +175,7 @@ public class SetTopRule extends Rule {
      * Process the end of this element.
      */
     @Override
-    public void end() throws Exception {
+    public void end(String namespace, String name) throws Exception {
 
         // Identify the objects to be used
         Object child = digester.peek(0);

Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/xmlrules/DigesterRuleParser.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/xmlrules/DigesterRuleParser.java?rev=1101317&r1=1101316&r2=1101317&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/xmlrules/DigesterRuleParser.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/xmlrules/DigesterRuleParser.java Tue May 10 05:42:22 2011
@@ -310,7 +310,7 @@ public class DigesterRuleParser extends 
          * pattern stack.
          */
         @Override
-        public void begin(Attributes attributes) {
+        public void begin(String namespace, String name, Attributes attributes) throws Exception {
             pattern = attributes.getValue(attrName);
             if (pattern != null) {
                 patternStack.push(pattern);
@@ -322,7 +322,7 @@ public class DigesterRuleParser extends 
          * stack.
          */
         @Override
-        public void end() {
+        public void end(String namespace, String name) throws Exception {
             if (pattern != null) {
                 patternStack.pop();
             }
@@ -350,7 +350,7 @@ public class DigesterRuleParser extends 
          * tell the Digester to parse the file.
          */
         @Override
-        public void begin(Attributes attributes) throws Exception {
+        public void begin(String namespace, String name, Attributes attributes) throws Exception {
             // The path attribute gives the URI to another digester rules xml file
             String fileName = attributes.getValue("path");
             if (fileName != null && fileName.length() > 0) {
@@ -833,7 +833,7 @@ public class DigesterRuleParser extends 
          * enclosing <set-properties-rule> tag.
          */
         @Override
-        public void begin(Attributes attributes) {
+        public void begin(String namespace, String name, Attributes attributes) throws Exception {
             String attrName = attributes.getValue("attr-name");
             String propName = attributes.getValue("prop-name");
     
@@ -860,7 +860,7 @@ public class DigesterRuleParser extends 
          * enclosing <set-nested-properties-rule> tag.
          */
         @Override
-        public void begin(Attributes attributes) {
+        public void begin(String namespace, String name, Attributes attributes) throws Exception {
             String attrName = attributes.getValue("attr-name");
             String propName = attributes.getValue("prop-name");
     

Modified: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/TestRule.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/TestRule.java?rev=1101317&r1=1101316&r2=1101317&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/TestRule.java (original)
+++ commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/TestRule.java Tue May 10 05:42:22 2011
@@ -83,7 +83,7 @@ public class TestRule extends Rule {
      * 'Begin' call.
      */
     @Override
-    public void begin(Attributes attributes) {
+    public void begin(String namespace, String name, Attributes attributes) throws Exception {
         appendCall();
     }
 
@@ -92,7 +92,7 @@ public class TestRule extends Rule {
      * 'Body' call.
      */
     @Override
-    public void body(String text) {
+    public void body(String namespace, String name, String text) throws Exception {
         this.bodyText = text;
         appendCall();
     }
@@ -102,7 +102,7 @@ public class TestRule extends Rule {
      * 'End' call.
      */
     @Override
-    public void end() {
+    public void end(String namespace, String name) throws Exception {
         appendCall();
     }