2 * Copyright 2005 the original author or authors.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.wamblee.crawler.impl;
19 import org.dom4j.Element;
20 import org.wamblee.crawler.Action;
21 import org.wamblee.crawler.Crawler;
22 import org.wamblee.crawler.Page;
23 import org.wamblee.crawler.PageException;
24 import org.wamblee.crawler.PageType;
27 * Action implementation.
29 public class ActionImpl implements Action {
31 private Crawler _crawler;
33 private Element _content;
37 private String _reference;
39 private PageType _type;
42 * Constructs the action.
47 * Content of the action element in the page where the action
52 * URL of the reference.
54 public ActionImpl(Crawler aCrawler, Element aContent, String aName,
59 _reference = aReference;
64 * Constructs the action.
69 * Content of the action element in the page where the action
74 * URL of the reference.
76 * Type of the referenced page.
78 public ActionImpl(Crawler aCrawler, Element aContent, String aName,
79 String aReference, PageType aType) {
83 _reference = aReference;
90 * @see org.wamblee.crawler.Action#getName()
92 public String getName() {
99 * @see org.wamblee.crawler.Action#execute()
101 public Page execute() throws PageException {
103 return _crawler.getPage(_reference);
105 return _crawler.getPage(_reference, _type);
111 * @see org.wamblee.crawler.Action#getContent()
113 public Element getContent() {
118 * @see java.lang.Object#equals(java.lang.Object)
121 public boolean equals(Object obj) {
122 if ( !(obj instanceof ActionImpl )) {
125 ActionImpl action = (ActionImpl)obj;
126 return _reference.equals(action._reference) &&
127 _type.equals(action._type);