/* * Copyright 2005 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.wamblee.crawler.kiss; import org.wamblee.crawler.Action; /** * */ public class Program { private static final String RECORD_ACTION = "record"; private static final String INDENT = " "; private String _channel; private String _name; private String _description; private String _keywords; private TimeInterval _interval; private Action _programInfo; public Program(String aChannel, String aName, String aDescription, String aKeywords, TimeInterval aInterval, Action aProgramInfo) { _channel = aChannel; _name = aName; _description = aDescription; _keywords = aKeywords; _interval = aInterval; _programInfo = aProgramInfo; } public String getChannel() { return _channel; } public String getName() { return _name; } public String getDescription() { return _description; } public String getKeywords() { return _keywords; } public TimeInterval getInterval() { return _interval; } public boolean record() { Action record = _programInfo.execute().getAction(RECORD_ACTION); if ( record == null) { return false; } record.execute(); return true; } public void accept(Visitor aVisitor) { aVisitor.visitProgram(this); } /* (non-Javadoc) * @see java.lang.Object#toString() */ @Override public String toString() { return _interval + " - " + _name + " (" + _channel + "/" + _keywords + ")" + "\n" + (INDENT + _description).replaceAll("\n", "\n" + INDENT); } }