From 94445186085ec1ec27bed5a5c07b634da957eb08 Mon Sep 17 00:00:00 2001 From: erik Date: Tue, 21 Mar 2006 21:51:33 +0000 Subject: [PATCH] checkstyle and checkdoc are now ok. --- .../wamblee/crawler/kiss/guide/Program.java | 141 ++++++++++++------ .../org/wamblee/crawler/kiss/guide/Time.java | 30 ++-- .../crawler/kiss/guide/TimeInterval.java | 48 +++--- .../crawler/kiss/main/KissCrawler.java | 8 +- .../crawler/kiss/main/ProgramAction.java | 13 +- .../kiss/main/ProgramActionExecutor.java | 117 ++++++++------- .../kiss/main/ProgramConfigurationParser.java | 106 +++++++------ .../crawler/kiss/main/ProgramFilter.java | 47 +++--- .../kiss/main/RecordProgramAction.java | 29 ++-- .../crawler/kiss/main/SystemProperties.java | 53 ++++--- .../crawler/kiss/notification/MailServer.java | 43 ++++-- .../notification/NotificationException.java | 27 ++-- .../crawler/kiss/notification/Notifier.java | 8 +- .../UsernamePasswordAuthenticator.java | 36 +++-- 14 files changed, 417 insertions(+), 289 deletions(-) diff --git a/crawler/kiss/src/org/wamblee/crawler/kiss/guide/Program.java b/crawler/kiss/src/org/wamblee/crawler/kiss/guide/Program.java index 6b165647..5f1bb67e 100644 --- a/crawler/kiss/src/org/wamblee/crawler/kiss/guide/Program.java +++ b/crawler/kiss/src/org/wamblee/crawler/kiss/guide/Program.java @@ -31,29 +31,37 @@ import org.wamblee.crawler.kiss.main.SystemProperties; * Represents a television program. */ public class Program { - + /** - * Lexicographical comparison of programs based on (time, title, channel). - * + * Lexicographical comparison of programs based on (time, title, channel). + * */ - public static class TimeSorter implements Comparator { - - /* (non-Javadoc) - * @see java.util.Comparator#compare(T, T) + public static class TimeSorter implements Comparator { + + /** + * Lexicographical comparison based on start time, program name, and + * channel. + * + * @param aProgram1 + * First program. + * @param aProgram2 + * Second program. + * @return See {@link Comparator#compare(T, T)} */ - public int compare(Program o1, Program o2) { - int value = o1.getInterval().getBegin().compareTo(o2.getInterval().getBegin()); - if ( value != 0 ) { - return value; + public int compare(Program aProgram1, Program aProgram2) { + int value = aProgram1.getInterval().getBegin().compareTo( + aProgram2.getInterval().getBegin()); + if (value != 0) { + return value; } - value = o1.getName().compareTo(o2.getName()); - if (value != 0 ) { - return value; + value = aProgram1.getName().compareTo(aProgram2.getName()); + if (value != 0) { + return value; } - return o1.getChannel().compareTo(o2.getChannel()); + return aProgram1.getChannel().compareTo(aProgram2.getChannel()); } } - + private static final Log LOG = LogFactory.getLog(Program.class); /** @@ -63,12 +71,35 @@ public class Program { private static final String RESULT_ELEM = "result"; + /** + * Result of recording a program. + * + */ public enum RecordingResult { - OK("Successfully recorded programs"), DUPLICATE( - "Already recorded programs"), CONFLICT( - "Programs in conflict with another recorded program"), OLDSHOW( - "Programs that occurred in the past"), ERROR( - "Programs that could not be recorded for technical reasons"); + /** + * Successfully recorded. + */ + OK("Successfully recorded programs"), + + /** + * Already recorded program. + */ + DUPLICATE("Already recorded programs"), + + /** + * Recording conflict with another program. + */ + CONFLICT("Programs in conflict with another recorded program"), + + /** + * Program occurred in the past. + */ + OLDSHOW("Programs that occurred in the past"), + + /** + * Program could not be recorded for technical reasons. + */ + ERROR("Programs that could not be recorded for technical reasons"); private String _description; @@ -76,6 +107,10 @@ public class Program { _description = aDescription; } + /** + * Gets the description. + * @return Description. + */ public String getDescription() { return _description; } @@ -188,20 +223,21 @@ public class Program { public TimeInterval getInterval() { return _interval; } - + /** - * Checks if recording is possible. - * @return True iff recording is possible. + * Checks if recording is possible. + * + * @return True iff recording is possible. */ - public boolean isRecordingPossible() { + public boolean isRecordingPossible() { try { Action record = _programInfo.execute().getAction(RECORD_ACTION); if (record == null) { - return false; + return false; } - return true; + return true; } catch (PageException e) { - return false; + return false; } } @@ -212,7 +248,7 @@ public class Program { */ public RecordingResult record() { LOG.info("Recording " + this); - if ( SystemProperties.isRecordDisabled() ) { + if (SystemProperties.isRecordDisabled()) { return RecordingResult.OK; } try { @@ -222,7 +258,8 @@ public class Program { return RecordingResult.OLDSHOW; } Page result = record.execute(); - RecordingResult recordingResult = RecordingResult.valueOf(result.getContent().getText()); + RecordingResult recordingResult = RecordingResult.valueOf(result + .getContent().getText()); LOG.info(" result: " + recordingResult); return recordingResult; } catch (PageException e) { @@ -253,34 +290,48 @@ public class Program { + ")" + "\n" + (INDENT + _description).replaceAll("\n", "\n" + INDENT); } - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see java.lang.Object#equals(java.lang.Object) */ @Override - public boolean equals(Object obj) { - if ( !(obj instanceof Program)) { - return false; + public boolean equals(Object aObject) { + if (!(aObject instanceof Program)) { + return false; } - Program program = (Program)obj; - return getName().equals(program.getName()) && - _programInfo.equals(program._programInfo); + Program program = (Program) aObject; + return getName().equals(program.getName()) + && _programInfo.equals(program._programInfo); + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + return getName().hashCode(); } - + /** - * Converts program information to XML. - * @return XML representation of program information. + * Converts program information to XML. + * + * @return XML representation of program information. */ - public Element asXml() { + public Element asXml() { DocumentFactory factory = DocumentFactory.getInstance(); - Element program = factory.createElement("program"); + Element program = factory.createElement("program"); program.addElement("name").setText(getName()); program.addElement("description").setText(getDescription()); program.addElement("keywords").setText(getKeywords()); program.addElement("channel").setText(getChannel()); Element interval = program.addElement("interval"); - interval.addElement("begin").setText(getInterval().getBegin().toString()); + interval.addElement("begin").setText( + getInterval().getBegin().toString()); interval.addElement("end").setText(getInterval().getEnd().toString()); - return program; + return program; } } diff --git a/crawler/kiss/src/org/wamblee/crawler/kiss/guide/Time.java b/crawler/kiss/src/org/wamblee/crawler/kiss/guide/Time.java index de1065cf..52695e10 100644 --- a/crawler/kiss/src/org/wamblee/crawler/kiss/guide/Time.java +++ b/crawler/kiss/src/org/wamblee/crawler/kiss/guide/Time.java @@ -96,25 +96,29 @@ public class Time implements Comparable { * @see java.lang.Object#equals(java.lang.Object) */ @Override - public boolean equals(Object obj) { - if ( !(obj instanceof Time )) { - return false; + public boolean equals(Object aObject) { + if (!(aObject instanceof Time)) { + return false; } - return toString().equals(obj.toString()); + return toString().equals(aObject.toString()); } - - /* (non-Javadoc) - * @see java.lang.Comparable#compareTo(T) + + /** + * Compares based on time. + * @param aObject Time object to compare to. + * @return See {@link Comparable#compareTo(T)}. */ - public int compareTo(Object o) { - if ( !(o instanceof Time)) { - throw new RuntimeException("object not an instance of Time"); + public int compareTo(Object aObject) { + if (!(aObject instanceof Time)) { + throw new RuntimeException("object not an instance of Time"); } - Time time = (Time)o; + Time time = (Time) aObject; return new Float(asFloat()).compareTo(new Float(time.asFloat())); } - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see java.lang.Object#hashCode() */ @Override diff --git a/crawler/kiss/src/org/wamblee/crawler/kiss/guide/TimeInterval.java b/crawler/kiss/src/org/wamblee/crawler/kiss/guide/TimeInterval.java index a22a3e79..a189e039 100644 --- a/crawler/kiss/src/org/wamblee/crawler/kiss/guide/TimeInterval.java +++ b/crawler/kiss/src/org/wamblee/crawler/kiss/guide/TimeInterval.java @@ -16,26 +16,28 @@ package org.wamblee.crawler.kiss.guide; - /** - * Time interval. + * Time interval. */ public class TimeInterval { /** - * Begin time. + * Begin time. */ private Time _begin; /** - * End time. + * End time. */ private Time _end; /** - * Construts the interval. - * @param aBegin Start time. - * @param aEnd End time. + * Construts the interval. + * + * @param aBegin + * Start time. + * @param aEnd + * End time. */ public TimeInterval(Time aBegin, Time aEnd) { _begin = aBegin; @@ -43,16 +45,18 @@ public class TimeInterval { } /** - * Gets the begin time. - * @return Begin time. + * Gets the begin time. + * + * @return Begin time. */ public Time getBegin() { return _begin; } /** - * Gets the end time. - * @return End time. + * Gets the end time. + * + * @return End time. */ public Time getEnd() { return _end; @@ -102,19 +106,23 @@ public class TimeInterval { boolean isUncertain() { return _begin.asFloat() > _end.asFloat(); } - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see java.lang.Object#equals(java.lang.Object)j */ @Override - public boolean equals(Object obj) { - if ( !(obj instanceof TimeInterval)) { - return false; - } - return obj.toString().equals(obj.toString()); + public boolean equals(Object aObject) { + if (!(aObject instanceof TimeInterval)) { + return false; + } + return aObject.toString().equals(aObject.toString()); } - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see java.lang.Object#hashCode() */ @Override diff --git a/crawler/kiss/src/org/wamblee/crawler/kiss/main/KissCrawler.java b/crawler/kiss/src/org/wamblee/crawler/kiss/main/KissCrawler.java index 5d7e85ca..b2f6064a 100644 --- a/crawler/kiss/src/org/wamblee/crawler/kiss/main/KissCrawler.java +++ b/crawler/kiss/src/org/wamblee/crawler/kiss/main/KissCrawler.java @@ -126,15 +126,15 @@ public class KissCrawler { try { HttpClient client = new HttpClient(); - //client.getHostConfiguration().setProxy("127.0.0.1", 3128); + // client.getHostConfiguration().setProxy("127.0.0.1", 3128); Crawler crawler = createCrawler(aCrawlerConfig, os, client); InputStream programConfigFile = new FileInputStream(new File( aProgramConfig)); ProgramConfigurationParser parser = new ProgramConfigurationParser(); parser.parse(programConfigFile); - List programFilters = parser.getFilters(); - + List programFilters = parser.getFilters(); + Page page = getStartPage(aStartUrl, crawler); TVGuide guide = createGuide(page); PrintVisitor printer = new PrintVisitor(System.out); @@ -170,7 +170,7 @@ public class KissCrawler { executor.commit(); try { aNotifier.send(executor.getReport()); - } catch (NotificationException e) { + } catch (NotificationException e) { throw new RuntimeException(e); } } diff --git a/crawler/kiss/src/org/wamblee/crawler/kiss/main/ProgramAction.java b/crawler/kiss/src/org/wamblee/crawler/kiss/main/ProgramAction.java index e9d3bcbe..a2da90fd 100644 --- a/crawler/kiss/src/org/wamblee/crawler/kiss/main/ProgramAction.java +++ b/crawler/kiss/src/org/wamblee/crawler/kiss/main/ProgramAction.java @@ -12,21 +12,24 @@ * 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.main; import org.wamblee.crawler.kiss.guide.Program; /** - * Represents an action configured for a program. + * Represents an action configured for a program. */ public interface ProgramAction { /** - * Executes the action. - * @param aProgram Program to execute the action for. - * @param aExecutor Report to use. + * Executes the action. + * + * @param aProgram + * Program to execute the action for. + * @param aExecutor + * Report to use. */ void execute(Program aProgram, ProgramActionExecutor aExecutor); } diff --git a/crawler/kiss/src/org/wamblee/crawler/kiss/main/ProgramActionExecutor.java b/crawler/kiss/src/org/wamblee/crawler/kiss/main/ProgramActionExecutor.java index 27297a6f..d47868f5 100644 --- a/crawler/kiss/src/org/wamblee/crawler/kiss/main/ProgramActionExecutor.java +++ b/crawler/kiss/src/org/wamblee/crawler/kiss/main/ProgramActionExecutor.java @@ -12,7 +12,7 @@ * 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.main; @@ -28,111 +28,118 @@ import org.wamblee.crawler.kiss.guide.Program; import org.wamblee.crawler.kiss.guide.Program.RecordingResult; /** - * Provides execution of actions for programs. Actions use - * this class to tell the executor what to do. The executor then decide - * on exactly what to do and in what order and makes decisions in case - * of conflicts. + * Provides execution of actions for programs. Actions use this class to tell + * the executor what to do. The executor then decide on exactly what to do and + * in what order and makes decisions in case of conflicts. */ public class ProgramActionExecutor { - + /** - * A map of category name to a set of program. Useful for displaying the output of - * possibly interesting programs on a per category basis. + * A map of category name to a set of program. Useful for displaying the + * output of possibly interesting programs on a per category basis. */ private Map> _interestingShows; - + /** - * Set of programs to record. + * Set of programs to record. */ private Set _showsToRecord; - + /** - * Map or recording result to a set of programs. + * Map or recording result to a set of programs. */ private EnumMap> _recordings; - + /** - * Constructs the program action executor. - * + * Constructs the program action executor. + * */ - public ProgramActionExecutor() { - _interestingShows = new TreeMap>(); + public ProgramActionExecutor() { + _interestingShows = new TreeMap>(); _showsToRecord = new TreeSet(new Program.TimeSorter()); _recordings = new EnumMap>( RecordingResult.class); for (RecordingResult result : RecordingResult.values()) { - _recordings.put(result, new TreeSet(new Program.TimeSorter())); + _recordings.put(result, new TreeSet( + new Program.TimeSorter())); } } - + /** * Called by an action to indicate the desire to record a program. - * @param aPriority Priority of the program. Used to resolve conflicts. - * @param aProgram Program to record. + * + * @param aPriority + * Priority of the program. Used to resolve conflicts. + * @param aProgram + * Program to record. */ - public void recordProgram(int aPriority, Program aProgram) { + public void recordProgram(int aPriority, Program aProgram) { _showsToRecord.add(aProgram); } - + /** - * Called by an action to indicate that a program is interesting. - * @param aCategory Category of the program. - * @param aProgram Program. + * Called by an action to indicate that a program is interesting. + * + * @param aCategory + * Category of the program. + * @param aProgram + * Program. */ - public void interestingProgram(String aCategory, Program aProgram) { - Set programs = _interestingShows.get(aCategory); - if ( programs == null ) { + public void interestingProgram(String aCategory, Program aProgram) { + Set programs = _interestingShows.get(aCategory); + if (programs == null) { programs = new TreeSet(new Program.TimeSorter()); _interestingShows.put(aCategory, programs); } programs.add(aProgram); } - + /** * Makes sure that the actions are performed. - * + * */ - public void commit() { - for (Program program: _showsToRecord) { - RecordingResult result = program.record(); + public void commit() { + for (Program program : _showsToRecord) { + RecordingResult result = program.record(); _recordings.get(result).add(program); } } - + /** - * Get report as XML. - * @return XML report + * Get report as XML. + * + * @return XML report */ - public Element getReport() { - DocumentFactory factory = DocumentFactory.getInstance(); - Element report = factory.createElement("report"); - + public Element getReport() { + DocumentFactory factory = DocumentFactory.getInstance(); + Element report = factory.createElement("report"); + for (RecordingResult result : RecordingResult.values()) { if (_recordings.get(result).size() > 0) { - Element recordingResult = report.addElement("recorded").addAttribute("result", result.toString()); - + Element recordingResult = report.addElement("recorded") + .addAttribute("result", result.toString()); + for (Program program : _recordings.get(result)) { - recordingResult.add(program.asXml()); + recordingResult.add(program.asXml()); } } } - - - if ( _interestingShows.size() > 0 ) { + + if (_interestingShows.size() > 0) { Element interesting = report.addElement("interesting"); - for (String category: _interestingShows.keySet()) { - Element categoryElem = interesting; - if ( category.length() > 0 ) { + for (String category : _interestingShows.keySet()) { + Element categoryElem = interesting; + if (category.length() > 0) { categoryElem = interesting.addElement("category"); categoryElem.addAttribute("name", category); } - for (Program program: _interestingShows.get(category)) { - categoryElem.add(program.asXml()); + for (Program program : _interestingShows.get(category)) { + categoryElem.add(program.asXml()); } } - + } - - return report; + + return report; } } diff --git a/crawler/kiss/src/org/wamblee/crawler/kiss/main/ProgramConfigurationParser.java b/crawler/kiss/src/org/wamblee/crawler/kiss/main/ProgramConfigurationParser.java index 24d7d9b3..103ec070 100644 --- a/crawler/kiss/src/org/wamblee/crawler/kiss/main/ProgramConfigurationParser.java +++ b/crawler/kiss/src/org/wamblee/crawler/kiss/main/ProgramConfigurationParser.java @@ -39,6 +39,11 @@ import org.wamblee.crawler.kiss.notification.Notifier; */ class ProgramConfigurationParser { + /** + * + */ + private static final int DEFAULT_SMTP_PORT = 25; + private static final String ELEM_PASSWORD = "password"; private static final String ELEM_USERNAME = "username"; @@ -49,16 +54,15 @@ class ProgramConfigurationParser { // Formatting configuration. private static final String ELEM_FORMAT = "format"; - + private static final String ELEM_TEXT = "text"; private static final String ELEM_HTML = "html"; - // Mail server configuration. private static final String ELEM_NOTIFICATION = "notification"; - + private static final String ELEM_SMTP = "smtp"; private static final String ELEM_SUBJECT = "subject"; @@ -74,18 +78,18 @@ class ProgramConfigurationParser { private static final String ELEM_PATTERN = "match"; private static final String ELEM_ACTION = "action"; - + private static final String ELEM_CATEGORY = "category"; private static final String ACTION_NOTIFY = "notify"; - - private List _filters; - - private Notifier _notifier; - - ProgramConfigurationParser() { - _filters = null; - _notifier = null; + + private List _filters; + + private Notifier _notifier; + + ProgramConfigurationParser() { + _filters = null; + _notifier = null; } /** @@ -108,95 +112,101 @@ class ProgramConfigurationParser { Element categoryElem = program.element(ELEM_CATEGORY); String category = ""; - if ( categoryElem != null ) { - category = categoryElem.getText().trim(); + if (categoryElem != null) { + category = categoryElem.getText().trim(); } - + Element actionElem = program.element(ELEM_ACTION); - ProgramAction action = new RecordProgramAction(); + ProgramAction action = new RecordProgramAction(1); if (actionElem != null) { if (actionElem.getText().equals(ACTION_NOTIFY)) { action = new InterestingProgramAction(category); } } - - List> regexConditions = - new ArrayList>(); - for (Iterator j = program.elementIterator(ELEM_PATTERN); j.hasNext(); ) { - Element patternElem = (Element)j.next(); - String fieldName = "name"; - Attribute fieldAttribute = patternElem.attribute("field"); - if ( fieldAttribute != null ) { - fieldName = fieldAttribute.getText(); + + List> regexConditions = new ArrayList>(); + for (Iterator j = program.elementIterator(ELEM_PATTERN); j + .hasNext();) { + Element patternElem = (Element) j.next(); + String fieldName = "name"; + Attribute fieldAttribute = patternElem.attribute("field"); + if (fieldAttribute != null) { + fieldName = fieldAttribute.getText(); } - String pattern = ".*(" + patternElem.getText() - + ").*"; - regexConditions.add(new PropertyRegexCondition(fieldName, pattern, true)); + String pattern = ".*(" + patternElem.getText() + ").*"; + regexConditions.add(new PropertyRegexCondition( + fieldName, pattern, true)); } - Condition condition = new AndCondition(regexConditions); + Condition condition = new AndCondition( + regexConditions); filters.add(new ProgramFilter(condition, action)); } _filters = filters; - + Element notifier = root.element(ELEM_NOTIFICATION); _notifier = parseNotifier(notifier); - + } catch (DocumentException e) { throw new RuntimeException("Error parsing program configuraiton", e); } } - + /** * Parses the notifier + * * @return Notifier */ - private Notifier parseNotifier(Element aNotifier) { + private Notifier parseNotifier(Element aNotifier) { String from = aNotifier.elementTextTrim(ELEM_FROM); String to = aNotifier.elementTextTrim(ELEM_TO); String subject = aNotifier.elementTextTrim(ELEM_SUBJECT); - + Element smtp = aNotifier.element(ELEM_SMTP); - MailServer server = parseMailServer( smtp ); - + MailServer server = parseMailServer(smtp); + Element format = aNotifier.element(ELEM_FORMAT); String htmlXslt = format.elementTextTrim(ELEM_HTML); String textXslt = format.elementTextTrim(ELEM_TEXT); - + return new MailNotifier(from, to, subject, htmlXslt, textXslt, server); } /** * Parses the mail server from the XML. - * @param aSmtp Mail server configuration. + * + * @param aSmtp + * Mail server configuration. * @return Mail server. */ - private MailServer parseMailServer( Element aSmtp ) { + private MailServer parseMailServer(Element aSmtp) { String host = aSmtp.elementTextTrim(ELEM_HOST); Element portElem = aSmtp.element(ELEM_PORT); - int port = 25; - if ( portElem != null ) { + int port = DEFAULT_SMTP_PORT; + if (portElem != null) { port = Integer.valueOf(portElem.getTextTrim()); } String username = aSmtp.elementTextTrim(ELEM_USERNAME); String password = aSmtp.elementTextTrim(ELEM_PASSWORD); - + MailServer server = new MailServer(host, port, username, password); return server; } - + /** * Returns the list of program filters. + * * @return Filter list. */ - public List getFilters() { + public List getFilters() { return _filters; } - + /** - * Returns the notifier to use. + * Returns the notifier to use. + * * @return Notifier. */ - public Notifier getNotifier() { - return _notifier; + public Notifier getNotifier() { + return _notifier; } } diff --git a/crawler/kiss/src/org/wamblee/crawler/kiss/main/ProgramFilter.java b/crawler/kiss/src/org/wamblee/crawler/kiss/main/ProgramFilter.java index 397cfe9c..e8633401 100644 --- a/crawler/kiss/src/org/wamblee/crawler/kiss/main/ProgramFilter.java +++ b/crawler/kiss/src/org/wamblee/crawler/kiss/main/ProgramFilter.java @@ -12,7 +12,7 @@ * 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.main; @@ -23,29 +23,42 @@ import org.wamblee.crawler.kiss.guide.MatchVisitor; import org.wamblee.crawler.kiss.guide.Program; import org.wamblee.crawler.kiss.guide.TVGuide; - /** - * Obtains a list of interesting programs from a TV guide and decides - * what to do with them. + * Obtains a list of interesting programs from a TV guide and decides what to do + * with them. */ public class ProgramFilter { - - private Condition _condition; - - private ProgramAction _action; - - public ProgramFilter(Condition aCondition, ProgramAction aAction) { - _condition = aCondition; - _action = aAction; + + private Condition _condition; + + private ProgramAction _action; + + /** + * Constructs the program filter. + * @param aCondition Condition used to find interesting programs. + * @param aAction Corresponding action to execute for matching programs. + */ + public ProgramFilter(Condition aCondition, ProgramAction aAction) { + _condition = aCondition; + _action = aAction; } - - public ProgramAction getAction() { + + /** + * Gets the action. + * @return Action. + */ + public ProgramAction getAction() { return _action; } - - public List apply(TVGuide aGuide) { + + /** + * Applies the filter to a TV guide. + * @param aGuide TV guide. + * @return List of matching programs. + */ + public List apply(TVGuide aGuide) { MatchVisitor matcher = new MatchVisitor(_condition); aGuide.accept(matcher); - return matcher.getMatches(); + return matcher.getMatches(); } } diff --git a/crawler/kiss/src/org/wamblee/crawler/kiss/main/RecordProgramAction.java b/crawler/kiss/src/org/wamblee/crawler/kiss/main/RecordProgramAction.java index 00367934..8458a957 100644 --- a/crawler/kiss/src/org/wamblee/crawler/kiss/main/RecordProgramAction.java +++ b/crawler/kiss/src/org/wamblee/crawler/kiss/main/RecordProgramAction.java @@ -12,32 +12,35 @@ * 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.main; import org.wamblee.crawler.kiss.guide.Program; - /** - * Represents an action to record a program. + * Represents an action to record a program. */ public class RecordProgramAction implements ProgramAction { - - private int _priority; - + + private int _priority; + /** - * Constructs the action. - * + * Constructs the action. + * @param aPriority Priority of the recording action. Lower values mean + * higher priority. */ - public void ReportProgramAction(int aPriority) { - _priority = aPriority; + public RecordProgramAction(int aPriority) { + _priority = aPriority; } - /* (non-Javadoc) - * @see org.wamblee.crawler.kiss.ProgramAction#execute(org.wamblee.crawler.kiss.Program, org.wamblee.crawler.kiss.Report) + /* + * (non-Javadoc) + * + * @see org.wamblee.crawler.kiss.ProgramAction#execute(org.wamblee.crawler.kiss.Program, + * org.wamblee.crawler.kiss.Report) */ - public void execute(Program aProgram, ProgramActionExecutor aReport) { + public void execute(Program aProgram, ProgramActionExecutor aReport) { aReport.recordProgram(_priority, aProgram); } diff --git a/crawler/kiss/src/org/wamblee/crawler/kiss/main/SystemProperties.java b/crawler/kiss/src/org/wamblee/crawler/kiss/main/SystemProperties.java index 4153eb7e..87003af4 100644 --- a/crawler/kiss/src/org/wamblee/crawler/kiss/main/SystemProperties.java +++ b/crawler/kiss/src/org/wamblee/crawler/kiss/main/SystemProperties.java @@ -12,50 +12,55 @@ * 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.main; /** - * Access to system properties for the crawler. + * Access to system properties for the crawler. */ public final class SystemProperties { - + private static final String DEBUG_PROPERTY = "kiss.debug"; + private static final String NO_PROGRAM_DETAILS = "kiss.nodetails"; - private static final String DISABLE_RECORD = "kiss.norecord"; - + + private static final String DISABLE_RECORD = "kiss.norecord"; + /** - * Disabled constructor. - * + * Disabled constructor. + * */ - private SystemProperties() { - // Empty. + private SystemProperties() { + // Empty. } /** - * Determines if the system is run in debug mode. When in debug mode, less extensive crawling is done. - * @return True iff we are running in debug mode. + * Determines if the system is run in debug mode. When in debug mode, less + * extensive crawling is done. + * + * @return True iff we are running in debug mode. */ - public static boolean isDebugMode() { - return System.getProperties().getProperty(DEBUG_PROPERTY) != null; + public static boolean isDebugMode() { + return System.getProperties().getProperty(DEBUG_PROPERTY) != null; } - + /** - * Determines if no program details are required. - * @return True iff no program details are required. + * Determines if no program details are required. + * + * @return True iff no program details are required. */ - public static boolean isNoProgramDetailsRequired() { - return System.getProperties().getProperty(NO_PROGRAM_DETAILS) != null; + public static boolean isNoProgramDetailsRequired() { + return System.getProperties().getProperty(NO_PROGRAM_DETAILS) != null; } - /** - * Determines if recording is disabled. - * @return True iff no recording should be done. + * Determines if recording is disabled. + * + * @return True iff no recording should be done. */ - public static boolean isRecordDisabled() { - return System.getProperties().getProperty(DISABLE_RECORD) != null; + public static boolean isRecordDisabled() { + return System.getProperties().getProperty(DISABLE_RECORD) != null; } - + } diff --git a/crawler/kiss/src/org/wamblee/crawler/kiss/notification/MailServer.java b/crawler/kiss/src/org/wamblee/crawler/kiss/notification/MailServer.java index 1fe66dde..d397594c 100644 --- a/crawler/kiss/src/org/wamblee/crawler/kiss/notification/MailServer.java +++ b/crawler/kiss/src/org/wamblee/crawler/kiss/notification/MailServer.java @@ -15,32 +15,44 @@ import org.apache.commons.mail.EmailException; * Mail server. */ public class MailServer { - - private String _host; + + private String _host; + private int _port; + private String _username; + private String _password; /** - * Constructs the mail server interface. - * @param aHost Host name of the SMTP server. - * @param aPort Port name of the SMTP server. - * @param aUsername Username to use for authentication or null if no authentication is - * required. - * @param aPassword Password to use for authentication or null if no authenticatio is - * required. + * Constructs the mail server interface. + * + * @param aHost + * Host name of the SMTP server. + * @param aPort + * Port name of the SMTP server. + * @param aUsername + * Username to use for authentication or null if no + * authentication is required. + * @param aPassword + * Password to use for authentication or null if no authenticatio + * is required. */ - public MailServer(String aHost, int aPort, String aUsername, String aPassword) { + public MailServer(String aHost, int aPort, String aUsername, + String aPassword) { _host = aHost; _port = aPort; _username = aUsername; _password = aPassword; } - + /** - * Sends an e-mail. - * @param aMail Mail to send. - * @throws EmailException In case of problems sending the mail. + * Sends an e-mail. + * + * @param aMail + * Mail to send. + * @throws EmailException + * In case of problems sending the mail. */ public void send(Email aMail) throws EmailException { Properties props = new Properties(); @@ -48,7 +60,8 @@ public class MailServer { props.put("mail.smtp.host", _host); props.put("mail.smtp.port", "" + _port); - Session mailSession = Session.getInstance(props, new UsernamePasswordAuthenticator(_username, _password)); + Session mailSession = Session.getInstance(props, + new UsernamePasswordAuthenticator(_username, _password)); aMail.setMailSession(mailSession); aMail.send(); } diff --git a/crawler/kiss/src/org/wamblee/crawler/kiss/notification/NotificationException.java b/crawler/kiss/src/org/wamblee/crawler/kiss/notification/NotificationException.java index 63989d56..bd80ba23 100644 --- a/crawler/kiss/src/org/wamblee/crawler/kiss/notification/NotificationException.java +++ b/crawler/kiss/src/org/wamblee/crawler/kiss/notification/NotificationException.java @@ -5,26 +5,31 @@ package org.wamblee.crawler.kiss.notification; /** - * Notification exception thrown in case of problems sending - * a notification to a user. - * + * Notification exception thrown in case of problems sending a notification to a + * user. + * */ public class NotificationException extends Exception { /** - * Constructs the notification. - * @param aMsg Message. + * Constructs the notification. + * + * @param aMsg + * Message. */ - public NotificationException(String aMsg) { + public NotificationException(String aMsg) { super(aMsg); } - + /** - * Constructs the notification. - * @param aMsg Message. - * @param aCause Cause. + * Constructs the notification. + * + * @param aMsg + * Message. + * @param aCause + * Cause. */ - public NotificationException(String aMsg, Throwable aCause) { + public NotificationException(String aMsg, Throwable aCause) { super(aMsg, aCause); } } diff --git a/crawler/kiss/src/org/wamblee/crawler/kiss/notification/Notifier.java b/crawler/kiss/src/org/wamblee/crawler/kiss/notification/Notifier.java index 2befac73..b2d35a90 100644 --- a/crawler/kiss/src/org/wamblee/crawler/kiss/notification/Notifier.java +++ b/crawler/kiss/src/org/wamblee/crawler/kiss/notification/Notifier.java @@ -8,13 +8,15 @@ import org.dom4j.Element; /** * Object used to send notifications about the actions of the crawler. - * + * */ public interface Notifier { /** - * Sends a notification. - * @param aReport Report to send. + * Sends a notification. + * + * @param aReport + * Report to send. */ void send(Element aReport) throws NotificationException; } diff --git a/crawler/kiss/src/org/wamblee/crawler/kiss/notification/UsernamePasswordAuthenticator.java b/crawler/kiss/src/org/wamblee/crawler/kiss/notification/UsernamePasswordAuthenticator.java index 88112b4e..5d1e9f8f 100644 --- a/crawler/kiss/src/org/wamblee/crawler/kiss/notification/UsernamePasswordAuthenticator.java +++ b/crawler/kiss/src/org/wamblee/crawler/kiss/notification/UsernamePasswordAuthenticator.java @@ -8,33 +8,37 @@ import javax.mail.Authenticator; import javax.mail.PasswordAuthentication; /** - * Authenticator to supply username and password to the mail server - * (if needed). - * + * Authenticator to supply username and password to the mail server (if needed). + * */ public class UsernamePasswordAuthenticator extends Authenticator { - - private String _username; - private String _password; + + private String _username; + + private String _password; /** * Constructs the authenticator. - * @param aUsername User name. - * @param aPassword Password. + * + * @param aUsername + * User name. + * @param aPassword + * Password. */ - public UsernamePasswordAuthenticator(String aUsername, String aPassword) { - _username = aUsername; - _password = aPassword; + public UsernamePasswordAuthenticator(String aUsername, String aPassword) { + _username = aUsername; + _password = aPassword; } - + /* - * (non-Javadoc) + * (non-Javadoc) + * * @see javax.mail.Authenticator#getPasswordAuthentication() */ @Override - protected PasswordAuthentication getPasswordAuthentication( ) { - if ( _username == null ) { - return null; + protected PasswordAuthentication getPasswordAuthentication() { + if (_username == null) { + return null; } return new PasswordAuthentication(_username, _password); } -- 2.31.1