OSDN Git Service

remove subversion keyword
[jindolf/Jindolf.git] / src / main / java / jp / sourceforge / jindolf / HtmlSequence.java
1 /*\r
2  * HTML sequence\r
3  *\r
4  * License : The MIT License\r
5  * Copyright(c) 2009 olyutorskii\r
6  */\r
7 \r
8 package jp.sourceforge.jindolf;\r
9 \r
10 import java.net.URL;\r
11 import jp.sourceforge.jindolf.parser.DecodedContent;\r
12 \r
13 /**\r
14  * HTML本文。\r
15  * 任意のDecodedContentをラップする。\r
16  * 由来となるURLと受信時刻を含む。\r
17  */\r
18 // TODO Dateも含めたい\r
19 public class HtmlSequence implements CharSequence{\r
20 \r
21     private final URL url;\r
22     private final long datems;\r
23     private final DecodedContent html;\r
24 \r
25     /**\r
26      * コンストラクタ。\r
27      * @param url 由来のURL\r
28      * @param datems 受信時刻(エポックミリ秒)\r
29      * @param html HTML本文\r
30      * @throws java.lang.NullPointerException 引数がnull\r
31      */\r
32     public HtmlSequence(URL url, long datems, DecodedContent html)\r
33         throws NullPointerException{\r
34         if(url == null || html == null){\r
35             throw new NullPointerException();\r
36         }\r
37         this.url = url;\r
38         this.datems = datems;\r
39         this.html = html;\r
40         return;\r
41     }\r
42 \r
43     /**\r
44      * URLを返す。\r
45      * @return URL\r
46      */\r
47     public URL getURL(){\r
48         return this.url;\r
49     }\r
50 \r
51     /**\r
52      * 受信時刻を返す。\r
53      * 単位はエポック時からのミリ秒。\r
54      * @return 受信時刻\r
55      */\r
56     public long getDateMs(){\r
57         return this.datems;\r
58     }\r
59 \r
60     /**\r
61      * HTML文字列を返す。\r
62      * @return HTML文字列\r
63      */\r
64     public DecodedContent getContent(){\r
65         return this.html;\r
66     }\r
67 \r
68     /**\r
69      * {@inheritDoc}\r
70      * @param index {@inheritDoc}\r
71      * @return {@inheritDoc}\r
72      */\r
73     public char charAt(int index){\r
74         return this.html.charAt(index);\r
75     }\r
76 \r
77     /**\r
78      * {@inheritDoc}\r
79      * @return {@inheritDoc}\r
80      */\r
81     public int length(){\r
82         return this.html.length();\r
83     }\r
84 \r
85     /**\r
86      * {@inheritDoc}\r
87      * @param start {@inheritDoc}\r
88      * @param end {@inheritDoc}\r
89      * @return {@inheritDoc}\r
90      */\r
91     public CharSequence subSequence(int start, int end){\r
92         return this.html.subSequence(start, end);\r
93     }\r
94 \r
95     /**\r
96      * {@inheritDoc}\r
97      * @return {@inheritDoc}\r
98      */\r
99     @Override\r
100     public String toString(){\r
101         return this.html.toString();\r
102     }\r
103 \r
104 }\r