(no commit message)
[utils] / crawler / kiss / src / org / wamblee / crawler / kiss / guide / Program.java
index 5f1bb67eb6325857ec70906e6bab890bd9616b80..44bdc52110b6b36a9e5e59163d5d91553d6601d0 100644 (file)
@@ -32,11 +32,27 @@ import org.wamblee.crawler.kiss.main.SystemProperties;
  */
 public class Program {
 
+    private static final String ELEM_PROGRAM = "program";
+
+    private static final String ELEM_NAME = "name";
+
+    private static final String ELEM_KEYWORDS = "keywords";
+
+    private static final String ELEM_DESCRIPTION = "description";
+
+    private static final String ELEM_CHANNEL = "channel";
+
+    private static final String ELEM_INTERVAL = "interval";
+
+    private static final String ELEM_END_TIME = "end";
+
+    private static final String ELEM_BEGIN_TIME = "begin";
+
     /**
      * Lexicographical comparison of programs based on (time, title, channel).
      * 
      */
-    public static class TimeSorter implements Comparator<Program> {
+    public static class TimeComparator implements Comparator<Program> {
 
         /**
          * Lexicographical comparison based on start time, program name, and
@@ -69,8 +85,6 @@ public class Program {
      */
     private static final String RECORD_ACTION = "record";
 
-    private static final String RESULT_ELEM = "result";
-
     /**
      * Result of recording a program.
      * 
@@ -79,41 +93,27 @@ public class Program {
         /**
          * Successfully recorded.
          */
-        OK("Successfully recorded programs"),
+        OK,
 
         /**
          * Already recorded program.
          */
-        DUPLICATE("Already recorded programs"),
+        DUPLICATE,
 
         /**
          * Recording conflict with another program.
          */
-        CONFLICT("Programs in conflict with another recorded program"),
+        CONFLICT,
 
         /**
          * Program occurred in the past.
          */
-        OLDSHOW("Programs that occurred in the past"),
+        OLDSHOW,
 
         /**
          * Program could not be recorded for technical reasons.
          */
-        ERROR("Programs that could not be recorded for technical reasons");
-
-        private String _description;
-
-        private RecordingResult(String aDescription) {
-            _description = aDescription;
-        }
-
-        /**
-         * Gets the description. 
-         * @return Description. 
-         */
-        public String getDescription() {
-            return _description;
-        }
+        ERROR;
     };
 
     /**
@@ -231,11 +231,7 @@ public class Program {
      */
     public boolean isRecordingPossible() {
         try {
-            Action record = _programInfo.execute().getAction(RECORD_ACTION);
-            if (record == null) {
-                return false;
-            }
-            return true;
+            return _programInfo.execute().getAction(RECORD_ACTION) != null;
         } catch (PageException e) {
             return false;
         }
@@ -323,15 +319,16 @@ public class Program {
      */
     public Element asXml() {
         DocumentFactory factory = DocumentFactory.getInstance();
-        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(
+        Element program = factory.createElement(ELEM_PROGRAM);
+        program.addElement(ELEM_NAME).setText(getName());
+        program.addElement(ELEM_DESCRIPTION).setText(getDescription());
+        program.addElement(ELEM_KEYWORDS).setText(getKeywords());
+        program.addElement(ELEM_CHANNEL).setText(getChannel());
+        Element interval = program.addElement(ELEM_INTERVAL);
+        interval.addElement(ELEM_BEGIN_TIME).setText(
                 getInterval().getBegin().toString());
-        interval.addElement("end").setText(getInterval().getEnd().toString());
+        interval.addElement(ELEM_END_TIME).setText(
+                getInterval().getEnd().toString());
         return program;
     }
 }