(no commit message)
[utils] / crawler / 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.PageType;
24
25 /**
26  * 
27  */
28 public class ActionImpl implements Action {
29     
30     private Crawler _crawler; 
31     private Element _content; 
32     private String _name; 
33     private String _reference; 
34     private PageType _type; 
35     
36     public ActionImpl(Crawler aCrawler, Element aContent, String aName, String aReference) {
37         _crawler = aCrawler; 
38         _content = aContent; 
39         _name = aName;
40         _reference = aReference;
41         _type = null; 
42     }
43     
44     public ActionImpl(Crawler aCrawler, Element aContent, String aName, String aReference, PageType aType) {
45         _crawler = aCrawler;
46         _content = aContent; 
47         _name = aName;
48         _reference = aReference; 
49         _type = aType; 
50     }
51
52     /* (non-Javadoc)
53      * @see org.wamblee.crawler.Action#getName()
54      */
55     public String getName() {
56         return _name;
57     }
58     
59     /* (non-Javadoc)
60      * @see org.wamblee.crawler.Action#execute()
61      */
62     public Page execute() {
63         if ( _type == null) {
64             return _crawler.getPage(_reference);
65         }
66         return _crawler.getPage(_reference, _type);
67     }
68     
69     /* (non-Javadoc)
70      * @see org.wamblee.crawler.Action#getContent()
71      */
72     public Element getContent() {
73         return _content; 
74     }
75 }