(no commit message)
[utils] / crawler / basic / src / org / wamblee / crawler / impl / ActionImpl.java
1 /*
2  * Copyright 2005 the original author or authors.
3  * 
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
7  * 
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  * 
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.
15  */ 
16
17 package org.wamblee.crawler.impl;
18
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;
25
26 /**
27  * 
28  */
29 public class ActionImpl implements Action {
30     
31     private Crawler _crawler; 
32     private Element _content; 
33     private String _name; 
34     private String _reference; 
35     private PageType _type; 
36     
37     public ActionImpl(Crawler aCrawler, Element aContent, String aName, String aReference) {
38         _crawler = aCrawler; 
39         _content = aContent; 
40         _name = aName;
41         _reference = aReference;
42         _type = null; 
43     }
44     
45     public ActionImpl(Crawler aCrawler, Element aContent, String aName, String aReference, PageType aType) {
46         _crawler = aCrawler;
47         _content = aContent; 
48         _name = aName;
49         _reference = aReference; 
50         _type = aType; 
51     }
52
53     /* (non-Javadoc)
54      * @see org.wamblee.crawler.Action#getName()
55      */
56     public String getName() {
57         return _name;
58     }
59     
60     /* (non-Javadoc)
61      * @see org.wamblee.crawler.Action#execute()
62      */
63     public Page execute() throws PageException {
64         if ( _type == null) {
65             return _crawler.getPage(_reference);
66         }
67         return _crawler.getPage(_reference, _type);
68     }
69     
70     /* (non-Javadoc)
71      * @see org.wamblee.crawler.Action#getContent()
72      */
73     public Element getContent() {
74         return _content; 
75     }
76 }