X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=crawler%2Fbasic%2Fsrc%2Forg%2Fwamblee%2Fcrawler%2Fimpl%2FActionImpl.java;h=ab7068cbda32ee8e8895a6677a2c6db431c8f60f;hb=071ee3b92d229ef0725928e19820fcd1084d11a0;hp=c36637353b6ef2a1588c67e85b629ef3035db9f2;hpb=0c7e22e06b8aa3e5e0e516f2f3c46eee6215bd85;p=utils diff --git a/crawler/basic/src/org/wamblee/crawler/impl/ActionImpl.java b/crawler/basic/src/org/wamblee/crawler/impl/ActionImpl.java index c3663735..ab7068cb 100644 --- a/crawler/basic/src/org/wamblee/crawler/impl/ActionImpl.java +++ b/crawler/basic/src/org/wamblee/crawler/impl/ActionImpl.java @@ -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); } /* @@ -113,4 +120,17 @@ public class ActionImpl implements Action { public Element getContent() { return _content; } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if ( !(obj instanceof ActionImpl )) { + return false; + } + ActionImpl action = (ActionImpl)obj; + return _reference.equals(action._reference) && + _type.equals(action._type); + } }