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