OSDN Git Service

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