support for parameters on actions.
[utils] / crawler / basic / src / org / wamblee / crawler / impl / ActionImpl.java
index 0ff4252d98804712981f46f842748e0bc024215b..ab7068cbda32ee8e8895a6677a2c6db431c8f60f 100644 (file)
@@ -16,6 +16,7 @@
 
 package org.wamblee.crawler.impl;
 
+import org.apache.commons.httpclient.NameValuePair;
 import org.dom4j.Element;
 import org.wamblee.crawler.Action;
 import org.wamblee.crawler.Crawler;
@@ -37,6 +38,8 @@ public class ActionImpl implements Action {
     private String _reference;
 
     private PageType _type;
+    
+    private NameValuePair[] _parameters; 
 
     /**
      * Constructs the action.
@@ -50,14 +53,16 @@ public class ActionImpl implements Action {
      *            Name of the action.
      * @param aReference
      *            URL of the reference.
+     * @param aParameters Parameters to use for the action. 
      */
     public ActionImpl(Crawler aCrawler, Element aContent, String aName,
-            String aReference) {
+            String aReference, NameValuePair[] aParameters) {
         _crawler = aCrawler;
         _content = aContent;
         _name = aName;
         _reference = aReference;
         _type = null;
+        _parameters = aParameters; 
     }
 
     /**
@@ -74,14 +79,16 @@ public class ActionImpl implements Action {
      *            URL of the reference.
      * @param aType
      *            Type of the referenced page.
+     * @param aParameters Parameters to use. 
      */
     public ActionImpl(Crawler aCrawler, Element aContent, String aName,
-            String aReference, PageType aType) {
+            String aReference, PageType aType, NameValuePair[] aParameters) {
         _crawler = aCrawler;
         _content = aContent;
         _name = aName;
         _reference = aReference;
         _type = aType;
+        _parameters = aParameters; 
     }
 
     /*
@@ -100,9 +107,9 @@ public class ActionImpl implements Action {
      */
     public Page execute() throws PageException {
         if (_type == null) {
-            return _crawler.getPage(_reference);
+            return _crawler.getPage(_reference, _parameters);
         }
-        return _crawler.getPage(_reference, _type);
+        return _crawler.getPage(_reference, _parameters, _type);
     }
 
     /*