checkstyle and checkdoc are now ok.
authorerik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Tue, 21 Mar 2006 21:51:33 +0000 (21:51 +0000)
committererik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Tue, 21 Mar 2006 21:51:33 +0000 (21:51 +0000)
14 files changed:
crawler/kiss/src/org/wamblee/crawler/kiss/guide/Program.java
crawler/kiss/src/org/wamblee/crawler/kiss/guide/Time.java
crawler/kiss/src/org/wamblee/crawler/kiss/guide/TimeInterval.java
crawler/kiss/src/org/wamblee/crawler/kiss/main/KissCrawler.java
crawler/kiss/src/org/wamblee/crawler/kiss/main/ProgramAction.java
crawler/kiss/src/org/wamblee/crawler/kiss/main/ProgramActionExecutor.java
crawler/kiss/src/org/wamblee/crawler/kiss/main/ProgramConfigurationParser.java
crawler/kiss/src/org/wamblee/crawler/kiss/main/ProgramFilter.java
crawler/kiss/src/org/wamblee/crawler/kiss/main/RecordProgramAction.java
crawler/kiss/src/org/wamblee/crawler/kiss/main/SystemProperties.java
crawler/kiss/src/org/wamblee/crawler/kiss/notification/MailServer.java
crawler/kiss/src/org/wamblee/crawler/kiss/notification/NotificationException.java
crawler/kiss/src/org/wamblee/crawler/kiss/notification/Notifier.java
crawler/kiss/src/org/wamblee/crawler/kiss/notification/UsernamePasswordAuthenticator.java

index 6b1656478dd9ded48d8259f64d971406f76fa1cd..5f1bb67eb6325857ec70906e6bab890bd9616b80 100644 (file)
@@ -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<Program> { 
-     
-        /* (non-Javadoc)
-         * @see java.util.Comparator#compare(T, T)
+    public static class TimeSorter implements Comparator<Program> {
+
+        /**
+         * 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;
     }
 }
index de1065cf2f3ed024a68734b51fa6267a6b1d6f03..52695e109ec1acca802da69e4543a7a343db5fdd 100644 (file)
@@ -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
index a22a3e7967d354915d9e963793ee38377abeda60..a189e0391d10ea35b42ead086d8b0b6d60443045 100644 (file)
 
 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
index 5d7e85ca94868eb0a283b6e9739462bf3f06772a..b2f6064a06a524394e808f6c0957ade3a35384c9 100644 (file)
@@ -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<ProgramFilter> programFilters = parser.getFilters(); 
-            
+            List<ProgramFilter> 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);
         }
     }
index e9d3bcbe84c9cef2cdb2ff21cf09661a5c2e1252..a2da90fd5a580c8654119df2c39b0db24e18f0ef 100644 (file)
  * 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);
 }
index 27297a6f0d2c625c9383bf069f81821a60817819..d47868f5ad040871340a905f7a58ccd5beff2521 100644 (file)
@@ -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<String, Set<Program>> _interestingShows;
-    
+
     /**
-     * Set of programs to record. 
+     * Set of programs to record.
      */
     private Set<Program> _showsToRecord;
-   
+
     /**
-     * Map or recording result to a set of programs. 
+     * Map or recording result to a set of programs.
      */
     private EnumMap<RecordingResult, Set<Program>> _recordings;
-    
+
     /**
-     * Constructs the program action executor. 
-     *
+     * Constructs the program action executor.
+     * 
      */
-    public ProgramActionExecutor() { 
-        _interestingShows = new TreeMap<String,Set<Program>>();
+    public ProgramActionExecutor() {
+        _interestingShows = new TreeMap<String, Set<Program>>();
         _showsToRecord = new TreeSet<Program>(new Program.TimeSorter());
         _recordings = new EnumMap<RecordingResult, Set<Program>>(
                 RecordingResult.class);
         for (RecordingResult result : RecordingResult.values()) {
-            _recordings.put(result, new TreeSet<Program>(new Program.TimeSorter()));
+            _recordings.put(result, new TreeSet<Program>(
+                    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<Program> programs = _interestingShows.get(aCategory);   
-        if ( programs == null ) { 
+    public void interestingProgram(String aCategory, Program aProgram) {
+        Set<Program> programs = _interestingShows.get(aCategory);
+        if (programs == null) {
             programs = new TreeSet<Program>(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;
     }
 }
index 24d7d9b3f93dda8f1e933e08f7dc01c1d925190d..103ec0702c6caea299ca6583e265797c6e7cc8ee 100644 (file)
@@ -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<ProgramFilter> _filters; 
-    
-    private Notifier _notifier; 
-    
-    ProgramConfigurationParser() { 
-        _filters = null; 
-        _notifier = null; 
+
+    private List<ProgramFilter> _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<Condition<Program>> regexConditions = 
-                    new ArrayList<Condition<Program>>();
-                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<Condition<Program>> regexConditions = new ArrayList<Condition<Program>>();
+                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<Program>(fieldName, pattern, true));
+                    String pattern = ".*(" + patternElem.getText() + ").*";
+                    regexConditions.add(new PropertyRegexCondition<Program>(
+                            fieldName, pattern, true));
                 }
-                Condition<Program> condition = new AndCondition<Program>(regexConditions);
+                Condition<Program> condition = new AndCondition<Program>(
+                        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<ProgramFilter> getFilters() { 
+    public List<ProgramFilter> 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;
     }
 }
index 397cfe9c54a3aab3abed61adb80105264d93f881..e8633401222faa21e6478ae4b1ec295d2778d9c8 100644 (file)
@@ -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<Program> _condition; 
-    
-    private ProgramAction _action; 
-    
-    public ProgramFilter(Condition<Program> aCondition, ProgramAction aAction) { 
-        _condition = aCondition; 
-        _action = aAction; 
+
+    private Condition<Program> _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<Program> aCondition, ProgramAction aAction) {
+        _condition = aCondition;
+        _action = aAction;
     }
-    
-    public ProgramAction getAction() { 
+
+    /**
+     * Gets the action. 
+     * @return Action. 
+     */
+    public ProgramAction getAction() {
         return _action;
     }
-    
-    public List<Program> apply(TVGuide aGuide) { 
+
+    /**
+     * Applies the filter to a TV guide. 
+     * @param aGuide TV guide. 
+     * @return List of matching programs. 
+     */
+    public List<Program> apply(TVGuide aGuide) {
         MatchVisitor matcher = new MatchVisitor(_condition);
         aGuide.accept(matcher);
-        return matcher.getMatches(); 
+        return matcher.getMatches();
     }
 }
index 00367934d19ea4293eb05e3c7b00dc665022edb6..8458a957495a2f79a4d62f71175b94edc44ecce7 100644 (file)
  * 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);
     }
 
index 4153eb7e00acbf4a3afb55a4fb2b032b2f6c7bac..87003af49481edc0b014f87c3ec9a2e587e8a22f 100644 (file)
  * 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;
     }
-    
+
 }
index 1fe66dde36b45438e3de41a94c6b90490d126da7..d397594c3343a37371c8fdf3c11b6d7eae82021c 100644 (file)
@@ -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();
     }
index 63989d56fc9f86ab2b8118af2905eb8b33d240a8..bd80ba23b79196869685e5787708eed500e10a3d 100644 (file)
@@ -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);
     }
 }
index 2befac736ecbf6e947765268080b140f2d2f04a1..b2d35a909fa2f9a7feaa7f3482004fa56a01ca4e 100644 (file)
@@ -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;
 }
index 88112b4e2bafc3d8190d9851c5e51fd10d5715bf..5d1e9f8f3160b209b488244992549fb22c301661 100644 (file)
@@ -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);
     }