OSDN Git Service

過去ログ要求時に指定するwhen値を内部的にはlongで保持するよう変更.
authoryukihane <yukihane.feather@gmail.com>
Thu, 18 Aug 2011 23:48:59 +0000 (08:48 +0900)
committeryukihane <yukihane.feather@gmail.com>
Thu, 18 Aug 2011 23:48:59 +0000 (08:48 +0900)
frontend/src/saccubus/converter/filegetter/WebFileInstanciator.java
frontend/src/saccubus/net/CommentInfo.java
frontend/src/saccubus/util/WayBackTimeParser.java
frontend/test/saccubus/util/WayBackTimeParserTest.java

index 19c4343..0401729 100644 (file)
@@ -56,7 +56,7 @@ public class WebFileInstanciator extends FileInstanciator {
             videoInfo = client.getVideoInfo(tag);
             if (StringUtils.isNotBlank(time)) {
                 System.out.print("Setting wayback time...");
-                final String waybacktime = WayBackTimeParser.parse(time);
+                final long waybacktime = WayBackTimeParser.parse(time);
                 String waybackkey = client.getWayBackKey(videoInfo);
                 commentInfo = new CommentInfo(waybackkey, waybacktime);
             }else{
index 790d4c1..3a35556 100644 (file)
@@ -7,9 +7,9 @@ package saccubus.net;
 public class CommentInfo {
 
     private final String wayBackKey;
-    private final String wayBackTime;
+    private final long wayBackTime;
 
-    public CommentInfo(String wayBackKey, String wayBackTime) {
+    public CommentInfo(String wayBackKey, long wayBackTime) {
         this.wayBackKey = wayBackKey;
         this.wayBackTime = wayBackTime;
     }
@@ -18,7 +18,7 @@ public class CommentInfo {
         return wayBackKey;
     }
 
-    public String getWayBackTime() {
+    public long getWayBackTime() {
         return wayBackTime;
     }
 }
index 8df9342..69a3f35 100644 (file)
@@ -32,10 +32,10 @@ public final class WayBackTimeParser {
      * @return パース結果.
      * @throws IOException パース失敗.
      */
-    public static String parse(String time) throws IOException {
+    public static long parse(String time) throws IOException {
         final Matcher mNumber = PATTERN_NUMBER.matcher(time);
         if (mNumber.matches()) {
-            return time;
+            return Long.parseLong(time);
         }
 
         final Matcher mHMS = PATTERN_YYMMDD_HH_MM_SS.matcher(time);
@@ -48,7 +48,7 @@ public final class WayBackTimeParser {
                     str.append(":");
                 }
                 final Date date = fmt.parse(str.toString());
-                return Long.toString(date.getTime() / 1000);
+                return date.getTime() / 1000;
             } catch (ParseException ex) {
                 throw new IOException("Cannot parse wayback time: " + time, ex);
             }
@@ -64,7 +64,7 @@ public final class WayBackTimeParser {
                     str.append(":");
                 }
                 final Date date = fmt.parse(str.toString());
-                return Long.toString(date.getTime() / 1000);
+                return date.getTime() / 1000;
             } catch (ParseException ex) {
                 throw new IOException("Cannot parse wayback time: " + time, ex);
             }
index 69874e0..5d64ec5 100644 (file)
@@ -14,8 +14,8 @@ public class WayBackTimeParserTest {
     @Test
     public void testParseYYYYMMDD_H_M_S() throws IOException {
         final String text = "2011/08/19 00:00:12";
-        final String expected = "1313679612";
-        final String actual = WayBackTimeParser.parse(text);
+        final long expected = 1313679612L;
+        final long actual = WayBackTimeParser.parse(text);
         assertEquals(expected, actual);
     }
 
@@ -23,8 +23,8 @@ public class WayBackTimeParserTest {
     @Test
     public void testParseYYYYMMDD_H_M() throws IOException {
         final String text = "2011/08/19 00:00";
-        final String expected = "1313679600";
-        final String actual = WayBackTimeParser.parse(text);
+        final long expected = 1313679600L;
+        final long actual = WayBackTimeParser.parse(text);
         assertEquals(expected, actual);
     }
 
@@ -32,7 +32,7 @@ public class WayBackTimeParserTest {
     @Test
     public void testParseNumber() throws IOException {
         final String text = "1313679600";
-        final String actual = WayBackTimeParser.parse(text);
-        assertEquals(text, actual);
+        final long actual = WayBackTimeParser.parse(text);
+        assertEquals(Long.parseLong(text), actual);
     }
 }