(no commit message)
[utils] / crawler / kiss / src / org / wamblee / crawler / kiss / Program.java
index 83531ff75100d4040f2c1572d9f44cb28ee84247..7cb86cfdeecea92ccb66b2f2a3a4eae7b5e485a8 100644 (file)
@@ -16,6 +16,8 @@
 
 package org.wamblee.crawler.kiss;
 
+import java.util.Comparator;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.wamblee.crawler.Action;
@@ -27,6 +29,16 @@ import org.wamblee.crawler.PageException;
  */
 public class Program {
     
+    public static class TimeSorter implements Comparator<Program> { 
+     
+        /* (non-Javadoc)
+         * @see java.util.Comparator#compare(T, T)
+         */
+        public int compare(Program o1, Program o2) { 
+            return o1.getInterval().getBegin().compareTo(o2.getInterval().getBegin());
+        }
+    }
+    
     private static final Log LOG = LogFactory.getLog(Program.class);
 
     /**
@@ -161,6 +173,22 @@ public class Program {
     public TimeInterval getInterval() {
         return _interval;
     }
+    
+    /**
+     * Checks if recording is possible. 
+     * @return True iff recording is possible. 
+     */
+    public boolean isRecordingPossible() { 
+        try {
+            Action record = _programInfo.execute().getAction(RECORD_ACTION);
+            if (record == null) {
+                return false; 
+            }
+            return true; 
+        } catch (PageException e) {
+            return false; 
+        }
+    }
 
     /**
      * Records the show.
@@ -202,4 +230,17 @@ public class Program {
                 + ")" + "\n"
                 + (INDENT + _description).replaceAll("\n", "\n" + INDENT);
     }
+    
+    /* (non-Javadoc)
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    @Override
+    public boolean equals(Object obj) {
+        if ( !(obj instanceof Program)) { 
+            return false; 
+        }
+        Program program = (Program)obj; 
+        return getName().equals(program.getName()) && 
+               _programInfo.equals(program._programInfo);
+    }
 }