(no commit message)
[utils] / crawler / kiss / src / org / wamblee / crawler / kiss / Program.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.kiss;
18
19 import org.wamblee.crawler.Action;
20 import org.wamblee.crawler.PageException;
21
22 /**
23  * 
24  */
25 public class Program {
26     
27     private static final String RECORD_ACTION = "record";
28     private static final String INDENT = "       ";
29     
30     private String _channel; 
31     private String _name;
32     private String _description; 
33     private String _keywords;
34     private TimeInterval _interval;
35     private Action _programInfo; 
36     
37     public Program(String aChannel, String aName, String aDescription, String aKeywords, TimeInterval aInterval, Action aProgramInfo) {
38         _channel = aChannel; 
39         _name = aName;  
40         _description = aDescription;
41         _keywords = aKeywords; 
42         _interval = aInterval;
43         _programInfo = aProgramInfo; 
44     }
45     
46     public String getChannel() { 
47         return _channel; 
48     }
49     
50     public String getName() { 
51         return _name; 
52     }
53     
54     public String getDescription() { 
55         return _description;
56     }
57     
58     public String getKeywords() { 
59         return _keywords; 
60     }
61     
62     public TimeInterval getInterval() { 
63         return _interval; 
64     }
65     
66     public boolean record() throws PageException { 
67         Action record = _programInfo.execute().getAction(RECORD_ACTION); 
68         if ( record == null) { 
69             return false;
70         }
71         record.execute(); 
72         return true; 
73     }
74     
75     public void accept(Visitor aVisitor) { 
76         aVisitor.visitProgram(this);
77     }
78     
79     /* (non-Javadoc)
80      * @see java.lang.Object#toString()
81      */
82     @Override
83     public String toString() {
84         return _interval + " - " + _name + " (" + _channel + "/" + _keywords + ")" + "\n" + 
85           (INDENT + _description).replaceAll("\n", "\n" + INDENT);  
86     }
87 }