Changeset 35648
- Timestamp:
- 10/21/09 00:39:23 (4 years ago)
- Location:
- lang/java/misc/hatenahaiku4j/trunk
- Files:
-
- 6 added
- 6 modified
-
changelog.txt (modified) (1 diff)
-
src/hatenahaiku4j/Entity.java (added)
-
src/hatenahaiku4j/HatenaHaikuAPI.java (modified) (24 diffs)
-
src/hatenahaiku4j/HatenaHaikuAPILight.java (modified) (50 diffs)
-
src/hatenahaiku4j/Keyword.java (modified) (2 diffs)
-
src/hatenahaiku4j/Status.java (modified) (2 diffs)
-
src/hatenahaiku4j/User.java (modified) (2 diffs)
-
src/hatenahaiku4j/op (added)
-
src/hatenahaiku4j/op/CollectOp.java (added)
-
src/hatenahaiku4j/op/MultipleReduceOp.java (added)
-
src/hatenahaiku4j/op/ReduceOp.java (added)
-
src/hatenahaiku4j/sample/Sample005.java (added)
Legend:
- Unmodified
- Added
- Removed
-
lang/java/misc/hatenahaiku4j/trunk/changelog.txt
r35469 r35648 1 HatenaHaiku4J v1.1.0 2009-10-21 2 ・v593kdrg氏による集約操作のインタフェースを追加。 3 ・Status, Keyword, UserにComparableを実装させた。 4 1 5 HatenaHaiku4J v1.0.3 2009-09-24 2 6 ・ユーザ名取得用のメソッドを追加。⇒HatenaUtil#getUserName(String userId) -
lang/java/misc/hatenahaiku4j/trunk/src/hatenahaiku4j/HatenaHaikuAPI.java
r35467 r35648 1 1 package hatenahaiku4j; 2 2 3 import hatenahaiku4j.op.ReduceOp; 3 4 import hatenahaiku4j.util.HttpUtil; 4 5 import hatenahaiku4j.util.StringUtil; … … 23 24 public class HatenaHaikuAPI extends HatenaHaikuAPILight { 24 25 /** URL: フレンドタイムライン(XML) */ 25 protected static final String URL_FRIENDS_TIMELINE_XML = "http://h.hatena.ne.jp/api/statuses/friends_timeline.xml";26 protected static final String URL_FRIENDS_TIMELINE_XML = "http://h.hatena.ne.jp/api/statuses/friends_timeline.xml"; 26 27 /** URL: ユーザタイムライン(XML) */ 27 protected static final String URL_USER_TIMELINE_XML = "http://h.hatena.ne.jp/api/statuses/user_timeline.xml";28 protected static final String URL_USER_TIMELINE_XML = "http://h.hatena.ne.jp/api/statuses/user_timeline.xml"; 28 29 /** URL: 投稿(XML) */ 29 protected static final String URL_UPDATE_STATUS_XML = "http://h.hatena.ne.jp/api/statuses/update.xml";30 protected static final String URL_UPDATE_STATUS_XML = "http://h.hatena.ne.jp/api/statuses/update.xml"; 30 31 /** URL: エントリを削除 */ 31 protected static final String URL_DELETE_STATUS = "http://h.hatena.ne.jp/api/statuses/destroy/";32 protected static final String URL_DELETE_STATUS = "http://h.hatena.ne.jp/api/statuses/destroy/"; 32 33 /** URL: エントリにスターを一つ追加 */ 33 protected static final String URL_ADD_STAR = "http://h.hatena.ne.jp/api/favorites/create/";34 protected static final String URL_ADD_STAR = "http://h.hatena.ne.jp/api/favorites/create/"; 34 35 /** URL: エントリのスターを一つ減らす */ 35 36 protected static final String URL_DELETE_STAR = "http://h.hatena.ne.jp/api/favorites/destroy/"; … … 41 42 protected static final String URL_FOLLOW_USER = "http://h.hatena.ne.jp/api/friendships/create/"; 42 43 /** URL: ユーザのフォローをやめる */ 43 protected static final String URL_UNFOLLOW_USER = "http://h.hatena.ne.jp/api/friendships/destroy/";44 protected static final String URL_UNFOLLOW_USER = "http://h.hatena.ne.jp/api/friendships/destroy/"; 44 45 /** URL: ユーザがフォローしているキーワードのリスト(XML) */ 45 46 protected static final String URL_FOLLOWING_KEYWORD_LIST_XML = "http://h.hatena.ne.jp/api/statuses/keywords.xml"; … … 47 48 protected static final String URL_FOLLOW_KEYWORD = "http://h.hatena.ne.jp/api/keywords/create/"; 48 49 /** URL: キーワードのフォローをやめる */ 49 protected static final String URL_UNFOLLOW_KEYWORD = "http://h.hatena.ne.jp/api/keywords/destroy/";50 protected static final String URL_UNFOLLOW_KEYWORD = "http://h.hatena.ne.jp/api/keywords/destroy/"; 50 51 /** URL: 関連キーワードを設定(XML) */ 51 52 protected static final String URL_RELATE_KEYWORD_XML = "http://h.hatena.ne.jp/api/keywords/relation/create.xml"; 52 53 /** URL: 関連キーワードを解除(XML) */ 53 protected static final String URL_UNRELATE_KEYWORD_XML = "http://h.hatena.ne.jp/api/keywords/relation/destroy.xml";54 protected static final String URL_UNRELATE_KEYWORD_XML = "http://h.hatena.ne.jp/api/keywords/relation/destroy.xml"; 54 55 55 56 /** ログインユーザ */ … … 126 127 */ 127 128 public List<Status> getFriendsTimeline(int page, int count, Date since) throws HatenaHaikuException { 129 return getFriendsTimeline(this.<Status>createCollectOp(), page, count, since); 130 } 131 132 /** 133 * 認証したユーザのフレンドタイムラインを取得します。<br/> 134 * <i>http://h.hatena.ne.jp/api/statuses/friends_timeline.xml</i> 135 * 136 * @see <a href="http://h.hatena.ne.jp/api#statuses-friends_timeline">statuses/friends_timeline</a> 137 * @param op 集合操作 138 * @param page 取得するページです。最大数は100です。 139 * @param count 取得数を指定します。最大数は 200 です。 140 * @param since その日時よりも新しい投稿のみに絞り込むための日時を指定します。 141 * @return 認証したユーザのフレンドタイムライン 142 * @throws HatenaHaikuException 143 * @since v1.1.0 144 */ 145 public <T> T getFriendsTimeline(ReduceOp<Status, T> op, int page, int count, Date since) throws HatenaHaikuException { 128 146 try { 129 147 QueryParameter param = new QueryParameter(); … … 132 150 param.setSince(since); 133 151 String resultXml = HttpUtil.doGet(loginUser, URL_FRIENDS_TIMELINE_XML, param, isNeedHttpLog()); 134 return toStatusList( XmlUtil.getRootElement(resultXml));152 return toStatusList(op, XmlUtil.getRootElement(resultXml)); 135 153 136 154 } catch (ParserConfigurationException e) { … … 155 173 */ 156 174 public List<Status> getUserTimeline() throws HatenaHaikuException { 157 return _getUserTimeline(0, 0, null, false);175 return getUserTimeline(0, 0, null); 158 176 } 159 177 … … 169 187 */ 170 188 public List<Status> getUserTimeline(int page) throws HatenaHaikuException { 171 return _getUserTimeline(page, 0, null, false);189 return getUserTimeline(page, 0, null); 172 190 } 173 191 … … 184 202 */ 185 203 public List<Status> getUserTimeline(int page, int count) throws HatenaHaikuException { 186 return _getUserTimeline(page, count, null, false);204 return getUserTimeline(page, count, null); 187 205 } 188 206 … … 200 218 */ 201 219 public List<Status> getUserTimeline(int page, int count, Date since) throws HatenaHaikuException { 202 return _getUserTimeline(page, count, since, false); 220 return getUserTimeline(this.<Status>createCollectOp(), page, count, since); 221 } 222 223 /** 224 * 認証したユーザのユーザタイムラインを取得します。<br/> 225 * <i>http://h.hatena.ne.jp/api/statuses/user_timeline.xml</i> 226 * 227 * @see <a href="http://h.hatena.ne.jp/api#statuses-user_timeline">statuses/user_timeline</a> 228 * @param op 集合操作 229 * @param page 取得するページです。最大数は100です。 230 * @param count 取得数を指定します。最大数は 200 です。 231 * @param since その日時よりも新しい投稿のみに絞り込むための日時を指定します。 232 * @return 認証したユーザのユーザタイムライン 233 * @throws HatenaHaikuException 234 * @since v1.1.0 235 */ 236 public <T> T getUserTimeline(ReduceOp<Status, T> op, int page, int count, Date since) throws HatenaHaikuException { 237 return _getUserTimeline(op, page, count, since, false); 203 238 } 204 239 … … 213 248 */ 214 249 public List<Status> getHotUserTimeline() throws HatenaHaikuException { 215 return _getUserTimeline(0, 0, null, true);250 return getHotUserTimeline(0, 0, null); 216 251 } 217 252 … … 227 262 */ 228 263 public List<Status> getHotUserTimeline(int page) throws HatenaHaikuException { 229 return _getUserTimeline(page, 0, null, true);264 return getHotUserTimeline(page, 0, null); 230 265 } 231 266 … … 242 277 */ 243 278 public List<Status> getHotUserTimeline(int page, int count) throws HatenaHaikuException { 244 return _getUserTimeline(page, count, null, true);279 return getHotUserTimeline(page, count, null); 245 280 } 246 281 … … 258 293 */ 259 294 public List<Status> getHotUserTimeline(int page, int count, Date since) throws HatenaHaikuException { 260 return _getUserTimeline(page, count, since, true); 261 } 262 295 return getHotUserTimeline(this.<Status>createCollectOp(), page, count, since); 296 } 297 298 /** 299 * 認証したユーザの人気のユーザタイムラインを取得します。<br/> 300 * <i>http://h.hatena.ne.jp/api/statuses/user_timeline.xml</i> 301 * 302 * @see <a href="http://h.hatena.ne.jp/api#statuses-user_timeline">statuses/user_timeline</a> 303 * @param op 集合操作 304 * @param page 取得するページです。最大数は100です。 305 * @param count 取得数を指定します。最大数は 200 です。 306 * @param since その日時よりも新しい投稿のみに絞り込むための日時を指定します。 307 * @return 認証したユーザの人気のユーザタイムライン 308 * @throws HatenaHaikuException 309 * @since v1.1.0 310 */ 311 public <T> T getHotUserTimeline(ReduceOp<Status, T> op, int page, int count, Date since) throws HatenaHaikuException { 312 return _getUserTimeline(op, page, count, since, true); 313 } 314 263 315 /** 264 316 * 認証したユーザのユーザタイムラインを取得します。<br/> … … 266 318 * 267 319 * @see <a href="http://h.hatena.ne.jp/api#statuses-user_timeline">statuses/user_timeline</a> 320 * @param op 集合操作 268 321 * @param page 取得するページです。最大数は100です。 269 322 * @param count 取得数を指定します。最大数は 200 です。 … … 274 327 * @since v1.0.0 275 328 */ 276 private List<Status> _getUserTimeline(int page, int count, Date since, boolean isHot) throws HatenaHaikuException {329 private <T> T _getUserTimeline(ReduceOp<Status, T> op, int page, int count, Date since, boolean isHot) throws HatenaHaikuException { 277 330 try { 278 331 QueryParameter param = new QueryParameter(isHot); … … 281 334 param.setSince(since); 282 335 String resultXml = HttpUtil.doGet(loginUser, URL_USER_TIMELINE_XML, param, isNeedHttpLog()); 283 return toStatusList( XmlUtil.getRootElement(resultXml));336 return toStatusList(op, XmlUtil.getRootElement(resultXml)); 284 337 285 338 } catch (ParserConfigurationException e) { … … 304 357 */ 305 358 public List<Status> getIdTimeline() throws HatenaHaikuException { 306 return get KeywordTimeline(loginUser.getUserIdNotation(),0, 0, null);359 return getIdTimeline(0, 0, null); 307 360 } 308 361 … … 318 371 */ 319 372 public List<Status> getIdTimeline(int page) throws HatenaHaikuException { 320 return get KeywordTimeline(loginUser.getUserIdNotation(),page, 0, null);373 return getIdTimeline(page, 0, null); 321 374 } 322 375 … … 333 386 */ 334 387 public List<Status> getIdTimeline(int page, int count) throws HatenaHaikuException { 335 return get KeywordTimeline(loginUser.getUserIdNotation(),page, count, null);388 return getIdTimeline(page, count, null); 336 389 } 337 390 … … 352 405 } 353 406 407 /** 408 * 認証したユーザのidページのタイムラインを取得します。<br/> 409 * このタイムラインは "id:xxxx" のキーワードタイムラインと同じものです。 410 * 411 * @see HatenaHaikuAPILight#getKeywordTimeline(String, int, int, Date) 412 * @param op 集合操作 413 * @param page 取得するページです。最大数は100です。 414 * @param count 取得数を指定します。最大数は 200 です。 415 * @param since その日時よりも新しい投稿のみに絞り込むための日時を指定します。 416 * @return 認証したユーザのidページのタイムライン 417 * @throws HatenaHaikuException 418 * @since v1.1.0 419 */ 420 public <T> T getIdTimeline(ReduceOp<Status, T> op, int page, int count, Date since) throws HatenaHaikuException { 421 return getKeywordTimeline(op, loginUser.getUserIdNotation(), page, count, since); 422 } 423 354 424 //------------------------------------------------------------- 355 425 // ステータス関係 … … 659 729 */ 660 730 public List<User> getFollowingList(int page) throws HatenaHaikuException { 731 return getFollowingList(this.<User>createCollectOp(), page); 732 } 733 734 /** 735 * 認証したユーザがフォローしているユーザのリストを100件取得します。(指定ページ)<br/> 736 * <i>http://h.hatena.ne.jp/api/statuses/friends.xml&page=<font color="red">ページ</font></i> 737 * 738 * @see <a href="http://h.hatena.ne.jp/api#statuses-friends">statuses/friends</a> 739 * @param op 集合操作 740 * @param page ページ 741 * @return 認証したユーザがフォローしているユーザのリスト(指定ページ) 742 * @throws HatenaHaikuException 743 * @since v1.1.0 744 */ 745 public <T> T getFollowingList(ReduceOp<User, T> op, int page) throws HatenaHaikuException { 661 746 try { 662 747 QueryParameter param = new QueryParameter(); 663 748 param.setPage(page); 664 749 String resultXml = HttpUtil.doGet(loginUser, URL_FOLLOWING_LIST_XML, param, isNeedHttpLog()); 665 return toUserList( XmlUtil.getRootElement(resultXml));750 return toUserList(op, XmlUtil.getRootElement(resultXml)); 666 751 667 752 } catch (ParserConfigurationException e) { … … 687 772 */ 688 773 public List<User> getFollowersList() throws HatenaHaikuException { 774 return getFollowersList(this.<User>createCollectOp()); 775 } 776 777 /** 778 * 認証したユーザをフォローしているユーザのリストを取得します。<br/> 779 * フォロワーはページ指定できず、一気に全員分取得されるようです。<br/> 780 * <i>http://h.hatena.ne.jp/api/statuses/followers.xml</i> 781 * 782 * @see <a href="http://h.hatena.ne.jp/api#statuses-followers">statuses/followers</a> 783 * @param op 集合操作 784 * @return 認証したユーザをフォローしているユーザのリスト 785 * @throws HatenaHaikuException 786 * @since v1.1.0 787 */ 788 public <T> T getFollowersList(ReduceOp<User, T> op) throws HatenaHaikuException { 689 789 try { 690 790 String resultXml = HttpUtil.doGet(loginUser, URL_FOLLOWERS_LIST_XML, null, isNeedHttpLog()); 691 return toUserList( XmlUtil.getRootElement(resultXml));791 return toUserList(op, XmlUtil.getRootElement(resultXml)); 692 792 693 793 } catch (ParserConfigurationException e) { … … 778 878 * 779 879 * @see <a href="http://h.hatena.ne.jp/api#statuses-keywords">statuses/keywords</a> 780 * @return 認証したユーザがフォローしているキーワードリスト880 * @return 認証したユーザがフォローしているキーワードリスト 781 881 * @throws HatenaHaikuException 782 882 * @since v0.0.1 783 883 */ 784 884 public List<Keyword> getFollowingKeywordList() throws HatenaHaikuException { 885 return getFollowingKeywordList(this.<Keyword>createCollectOp()); 886 } 887 888 /** 889 * 認証したユーザがフォローしているキーワードのリストを取得します。<br/> 890 * <i>http://h.hatena.ne.jp/api/statuses/keywords.xml</i> 891 * 892 * @see <a href="http://h.hatena.ne.jp/api#statuses-keywords">statuses/keywords</a> 893 * @param op 集合操作 894 * @return 認証したユーザがフォローしているキーワードリスト 895 * @throws HatenaHaikuException 896 * @since v1.1.0 897 */ 898 public <T> T getFollowingKeywordList(ReduceOp<Keyword, T> op) throws HatenaHaikuException { 785 899 try { 786 900 String resultXml = HttpUtil.doGet(loginUser, URL_FOLLOWING_KEYWORD_LIST_XML, null, isNeedHttpLog()); 787 return toKeywordList( XmlUtil.getRootElement(resultXml));901 return toKeywordList(op, XmlUtil.getRootElement(resultXml)); 788 902 789 903 } catch (ParserConfigurationException e) { -
lang/java/misc/hatenahaiku4j/trunk/src/hatenahaiku4j/HatenaHaikuAPILight.java
r35467 r35648 1 1 package hatenahaiku4j; 2 2 3 import hatenahaiku4j.op.CollectOp; 4 import hatenahaiku4j.op.ReduceOp; 3 5 import hatenahaiku4j.util.DateUtil; 4 6 import hatenahaiku4j.util.HttpUtil; … … 29 31 protected static final String URL_PUBLIC_TIMELINE_XML = "http://h.hatena.ne.jp/api/statuses/public_timeline.xml"; 30 32 /** URL: フレンドタイムライン */ 31 protected static final String URL_FRIENDS_TIMELINE = "http://h.hatena.ne.jp/api/statuses/friends_timeline/";33 protected static final String URL_FRIENDS_TIMELINE = "http://h.hatena.ne.jp/api/statuses/friends_timeline/"; 32 34 /** URL: ユーザタイムライン */ 33 protected static final String URL_USER_TIMELINE = "http://h.hatena.ne.jp/api/statuses/user_timeline/";35 protected static final String URL_USER_TIMELINE = "http://h.hatena.ne.jp/api/statuses/user_timeline/"; 34 36 /** URL: キーワードタイムライン */ 35 protected static final String URL_KEYWORD_TIMELINE = "http://h.hatena.ne.jp/api/statuses/keyword_timeline/";37 protected static final String URL_KEYWORD_TIMELINE = "http://h.hatena.ne.jp/api/statuses/keyword_timeline/"; 36 38 /** URL: アルバムタイムライン(XML) */ 37 39 protected static final String URL_ALBUM_TIMELINE_XML = "http://h.hatena.ne.jp/api/statuses/album.xml"; … … 45 47 protected static final String URL_FOLLOWERS_LIST = "http://h.hatena.ne.jp/api/statuses/followers/"; 46 48 /** URL: ユーザ情報 */ 47 protected static final String URL_USER = "http://h.hatena.ne.jp/api/friendships/show/";49 protected static final String URL_USER = "http://h.hatena.ne.jp/api/friendships/show/"; 48 50 /** URL: ホットキーワードのリスト(XML) */ 49 protected static final String URL_HOT_KEYWORD_LIST_XML = "http://h.hatena.ne.jp/api/keywords/hot.xml";51 protected static final String URL_HOT_KEYWORD_LIST_XML = "http://h.hatena.ne.jp/api/keywords/hot.xml"; 50 52 /** URL: キーワードのリスト(XML) */ 51 protected static final String URL_KEYWORD_LIST_XML = "http://h.hatena.ne.jp/api/keywords/list.xml";53 protected static final String URL_KEYWORD_LIST_XML = "http://h.hatena.ne.jp/api/keywords/list.xml"; 52 54 /** URL: ユーザがフォローしているキーワードのリスト */ 53 55 protected static final String URL_FOLLOWING_KEYWORD_LIST = "http://h.hatena.ne.jp/api/statuses/keywords/"; … … 175 177 */ 176 178 public List<Status> getPublicTimeline(int page, Date since) throws HatenaHaikuException { 179 return getPublicTimeline(this.<Status>createCollectOp(), page, since); 180 } 181 182 /** 183 * パブリックタイムラインを取得します。取得件数は20件です。<br/> 184 * <i>http://h.hatena.ne.jp/api/statuses/public_timeline.xml</i> 185 * 186 * @see <a href="http://h.hatena.ne.jp/">はてなハイク</a> 187 * @see <a href="http://h.hatena.ne.jp/api#statuses-public_timeline">statuses/public_timeline</a> 188 * @param op 集合操作 189 * @param page 取得するページです。最大数は100です。 190 * @param since その日時よりも新しい投稿のみに絞り込むための日時を指定します。 191 * @return パブリックタイムライン 192 * @throws HatenaHaikuException 193 * @since v1.1.0 194 */ 195 public <T> T getPublicTimeline(ReduceOp<Status, T> op, int page, Date since) throws HatenaHaikuException { 177 196 try { 178 197 QueryParameter param = new QueryParameter(); … … 180 199 param.setSince(since); 181 200 String resultXml = HttpUtil.doGet(URL_PUBLIC_TIMELINE_XML, param, isNeedHttpLog()); 182 return toStatusList( XmlUtil.getRootElement(resultXml));201 return toStatusList(op, XmlUtil.getRootElement(resultXml)); 183 202 184 203 } catch (ParserConfigurationException e) { … … 252 271 */ 253 272 public List<Status> getFriendsTimeline(String userId, int page, int count, Date since) throws HatenaHaikuException { 273 return getFriendsTimeline(this.<Status>createCollectOp(), userId, page, count, since); 274 } 275 276 /** 277 * 指定したユーザのフレンドタイムラインを取得します。<br/> 278 * <i>http://h.hatena.ne.jp/api/statuses/friends_timeline/<font color="red">ユーザID</font>.xml</i> 279 * 280 * @see <a href="http://h.hatena.ne.jp/api#statuses-friends_timeline">statuses/friends_timeline</a> 281 * @param op 集合操作 282 * @param userId ユーザID 283 * @param page 取得するページです。最大数は100です。 284 * @param count 取得数を指定します。最大数は 200 です。 285 * @param since その日時よりも新しい投稿のみに絞り込むための日時を指定します。 286 * @return 指定したユーザのフレンドタイムライン 287 * @throws HatenaHaikuException 288 * @since v1.1.0 289 */ 290 public <T> T getFriendsTimeline(ReduceOp<Status, T> op, String userId, int page, int count, Date since) throws HatenaHaikuException { 254 291 try { 255 292 QueryParameter param = new QueryParameter(); … … 258 295 param.setSince(since); 259 296 String resultXml = HttpUtil.doGet(URL_FRIENDS_TIMELINE + userId + Const.EXT_XML, param, isNeedHttpLog()); 260 return toStatusList( XmlUtil.getRootElement(resultXml));297 return toStatusList(op, XmlUtil.getRootElement(resultXml)); 261 298 262 299 } catch (ParserConfigurationException e) { … … 282 319 */ 283 320 public List<Status> getUserTimeline(String userId) throws HatenaHaikuException { 284 return _getUserTimeline(userId, 0, 0, null, false);321 return getUserTimeline(userId, 0, 0, null); 285 322 } 286 323 … … 297 334 */ 298 335 public List<Status> getUserTimeline(String userId, int page) throws HatenaHaikuException { 299 return _getUserTimeline(userId, page, 0, null, false);336 return getUserTimeline(userId, page, 0, null); 300 337 } 301 338 … … 313 350 */ 314 351 public List<Status> getUserTimeline(String userId, int page, int count) throws HatenaHaikuException { 315 return _getUserTimeline(userId, page, count, null, false);352 return getUserTimeline(userId, page, count, null); 316 353 } 317 354 … … 330 367 */ 331 368 public List<Status> getUserTimeline(String userId, int page, int count, Date since) throws HatenaHaikuException { 332 return _getUserTimeline(userId, page, count, since, false); 369 return getUserTimeline(this.<Status>createCollectOp(), userId, page, count, since); 370 } 371 372 /** 373 * 指定したユーザのユーザタイムラインを取得します。<br/> 374 * <i>http://h.hatena.ne.jp/api/statuses/user_timeline/<font color="red">ユーザID</font>.xml</i> 375 * 376 * @see <a href="http://h.hatena.ne.jp/api#statuses-user_timeline">statuses/user_timeline</a> 377 * @param op 集合操作 378 * @param userId ユーザID 379 * @param page 取得するページです。最大数は100です。 380 * @param count 取得数を指定します。最大数は 200 です。 381 * @param since その日時よりも新しい投稿のみに絞り込むための日時を指定します。 382 * @return 指定したユーザのユーザタイムライン 383 * @throws HatenaHaikuException 384 * @since v1.1.0 385 */ 386 public <T> T getUserTimeline(ReduceOp<Status, T> op, String userId, int page, int count, Date since) throws HatenaHaikuException { 387 return _getUserTimeline(op, userId, page, count, since, false); 333 388 } 334 389 … … 344 399 */ 345 400 public List<Status> getHotUserTimeline(String userId) throws HatenaHaikuException { 346 return _getUserTimeline(userId, 0, 0, null, true);401 return getHotUserTimeline(userId, 0, 0, null); 347 402 } 348 403 … … 359 414 */ 360 415 public List<Status> getHotUserTimeline(String userId, int page) throws HatenaHaikuException { 361 return _getUserTimeline(userId, page, 0, null, true);416 return getHotUserTimeline(userId, page, 0, null); 362 417 } 363 418 … … 375 430 */ 376 431 public List<Status> getHotUserTimeline(String userId, int page, int count) throws HatenaHaikuException { 377 return _getUserTimeline(userId, page, count, null, true);432 return getHotUserTimeline(userId, page, count, null); 378 433 } 379 434 … … 392 447 */ 393 448 public List<Status> getHotUserTimeline(String userId, int page, int count, Date since) throws HatenaHaikuException { 394 return _getUserTimeline(userId, page, count, since, true); 395 } 396 449 return getHotUserTimeline(this.<Status>createCollectOp(), userId, page, count, since); 450 } 451 452 /** 453 * 指定したユーザの人気のユーザタイムラインを取得します。<br/> 454 * <i>http://h.hatena.ne.jp/api/statuses/user_timeline/<font color="red">ユーザID</font>.xml</i> 455 * 456 * @see <a href="http://h.hatena.ne.jp/api#statuses-user_timeline">statuses/user_timeline</a> 457 * @param op 集合操作 458 * @param userId ユーザID 459 * @param page 取得するページです。最大数は100です。 460 * @param count 取得数を指定します。最大数は 200 です。 461 * @param since その日時よりも新しい投稿のみに絞り込むための日時を指定します。 462 * @return 指定したユーザの人気のユーザタイムライン 463 * @throws HatenaHaikuException 464 * @since v1.1.0 465 */ 466 public <T> T getHotUserTimeline(ReduceOp<Status, T> op, String userId, int page, int count, Date since) throws HatenaHaikuException { 467 return _getUserTimeline(op, userId, page, count, since, true); 468 } 469 397 470 /** 398 471 * 指定したユーザのユーザタイムラインを取得します。<br/> … … 400 473 * 401 474 * @see <a href="http://h.hatena.ne.jp/api#statuses-user_timeline">statuses/user_timeline</a> 475 * @param op 集合操作 402 476 * @param userId ユーザID 403 477 * @param page 取得するページです。最大数は100です。 … … 409 483 * @since v1.0.0 410 484 */ 411 private List<Status> _getUserTimeline(String userId, int page, int count, Date since, boolean isHot) throws HatenaHaikuException {485 private <T> T _getUserTimeline(ReduceOp<Status, T> op, String userId, int page, int count, Date since, boolean isHot) throws HatenaHaikuException { 412 486 try { 413 487 QueryParameter param = new QueryParameter(isHot); … … 416 490 param.setSince(since); 417 491 String resultXml = HttpUtil.doGet(URL_USER_TIMELINE + userId + Const.EXT_XML, param, isNeedHttpLog()); 418 return toStatusList( XmlUtil.getRootElement(resultXml));492 return toStatusList(op, XmlUtil.getRootElement(resultXml)); 419 493 420 494 } catch (ParserConfigurationException e) { … … 440 514 */ 441 515 public List<Status> getIdTimeline(String userId) throws HatenaHaikuException { 442 return get KeywordTimeline(Const.ID_COLON + userId, 0, 0, null);516 return getIdTimeline(Const.ID_COLON + userId, 0, 0, null); 443 517 } 444 518 … … 455 529 */ 456 530 public List<Status> getIdTimeline(String userId, int page) throws HatenaHaikuException { 457 return get KeywordTimeline(Const.ID_COLON + userId, page, 0, null);531 return getIdTimeline(Const.ID_COLON + userId, page, 0, null); 458 532 } 459 533 … … 471 545 */ 472 546 public List<Status> getIdTimeline(String userId, int page, int count) throws HatenaHaikuException { 473 return get KeywordTimeline(Const.ID_COLON + userId, page, count, null);547 return getIdTimeline(Const.ID_COLON + userId, page, count, null); 474 548 } 475 549 … … 488 562 */ 489 563 public List<Status> getIdTimeline(String userId, int page, int count, Date since) throws HatenaHaikuException { 490 return _getKeywordTimeline(Const.ID_COLON + userId, page, count, since, false); 491 } 492 564 return getIdTimeline(this.<Status>createCollectOp(), Const.ID_COLON + userId, page, count, since); 565 } 566 567 /** 568 * 指定したユーザのidページのタイムラインを取得します。<br/> 569 * このタイムラインは "id:xxxx" のキーワードタイムラインと同じものです。 570 * 571 * @see HatenaHaikuAPILight#getKeywordTimeline(String, int, int, Date) 572 * @param op 集合操作 573 * @param userId ユーザID 574 * @param page 取得するページです。最大数は100です。 575 * @param count 取得数を指定します。最大数は 200 です。 576 * @param since その日時よりも新しい投稿のみに絞り込むための日時を指定します。 577 * @return 指定したユーザのidページのタイムライン 578 * @throws HatenaHaikuException 579 * @since v1.1.0 580 */ 581 public <T> T getIdTimeline(ReduceOp<Status, T> op, String userId, int page, int count, Date since) throws HatenaHaikuException { 582 return getKeywordTimeline(op, Const.ID_COLON + userId, page, count, since); 583 } 584 493 585 /** 494 586 * 指定したキーワードのキーワードタイムラインを取得します。最新ページを20件取得します。<br/> … … 502 594 */ 503 595 public List<Status> getKeywordTimeline(String keyword) throws HatenaHaikuException { 504 return _getKeywordTimeline(keyword, 0, 0, null, false);596 return getKeywordTimeline(keyword, 0, 0, null); 505 597 } 506 598 … … 517 609 */ 518 610 public List<Status> getKeywordTimeline(String keyword, int page) throws HatenaHaikuException { 519 return _getKeywordTimeline(keyword, page, 0, null, false);611 return getKeywordTimeline(keyword, page, 0, null); 520 612 } 521 613 … … 533 625 */ 534 626 public List<Status> getKeywordTimeline(String keyword, int page, int count) throws HatenaHaikuException { 535 return _getKeywordTimeline(keyword, page, count, null, false);627 return getKeywordTimeline(keyword, page, count, null); 536 628 } 537 629 … … 550 642 */ 551 643 public List<Status> getKeywordTimeline(String keyword, int page, int count, Date since) throws HatenaHaikuException { 552 return _getKeywordTimeline(keyword, page, count, since, false); 553 } 554 644 return getKeywordTimeline(this.<Status>createCollectOp(), keyword, page, count, since); 645 } 646 647 /** 648 * 指定したキーワードのキーワードタイムラインを取得します。<br/> 649 * <i>http://h.hatena.ne.jp/api/statuses/keyword_timeline/<font color="red">キーワード</font>.xml</i> 650 * 651 * @see <a href="http://h.hatena.ne.jp/api#statuses-keyword_timeline">statuses/keyword_timeline</a> 652 * @param op 集合操作 653 * @param keyword キーワード 654 * @param page 取得するページです。最大数は100です。 655 * @param count 取得数を指定します。最大数は 200 です。 656 * @param since その日時よりも新しい投稿のみに絞り込むための日時を指定します。 657 * @return 指定したキーワードのキーワードタイムライン 658 * @throws HatenaHaikuException 659 * @since v1.1.0 660 */ 661 public <T> T getKeywordTimeline(ReduceOp<Status, T> op, String keyword, int page, int count, Date since) throws HatenaHaikuException { 662 return _getKeywordTimeline(op, keyword, page, count, since, false); 663 } 664 555 665 /** 556 666 * 指定したキーワードの人気のキーワードタイムラインを取得します。最新ページを20件取得します。<br/> … … 564 674 */ 565 675 public List<Status> getHotKeywordTimeline(String keyword) throws HatenaHaikuException { 566 return _getKeywordTimeline(keyword, 0, 0, null, true);676 return getHotKeywordTimeline(keyword, 0, 0, null); 567 677 } 568 678 … … 579 689 */ 580 690 public List<Status> getHotKeywordTimeline(String keyword, int page) throws HatenaHaikuException { 581 return _getKeywordTimeline(keyword, page, 0, null, true);691 return getHotKeywordTimeline(keyword, page, 0, null); 582 692 } 583 693 … … 595 705 */ 596 706 public List<Status> getHotKeywordTimeline(String keyword, int page, int count) throws HatenaHaikuException { 597 return _getKeywordTimeline(keyword, page, count, null, true);707 return getHotKeywordTimeline(keyword, page, count, null); 598 708 } 599 709 … … 612 722 */ 613 723 public List<Status> getHotKeywordTimeline(String keyword, int page, int count, Date since) throws HatenaHaikuException { 614 return _getKeywordTimeline(keyword, page, count, since, true); 724 return getHotKeywordTimeline(this.<Status>createCollectOp(), keyword, page, count, since); 725 } 726 727 /** 728 * 指定したキーワードの人気のキーワードタイムラインを取得します。<br/> 729 * <i>http://h.hatena.ne.jp/api/statuses/keyword_timeline/<font color="red">キーワード</font>.xml</i> 730 * 731 * @see <a href="http://h.hatena.ne.jp/api#statuses-keyword_timeline">statuses/keyword_timeline</a> 732 * @param op 集合操作 733 * @param keyword キーワード 734 * @param page 取得するページです。最大数は100です。 735 * @param count 取得数を指定します。最大数は 200 です。 736 * @param since その日時よりも新しい投稿のみに絞り込むための日時を指定します。 737 * @return 指定したキーワードの人気のキーワードタイムライン 738 * @throws HatenaHaikuException 739 * @since v1.1.0 740 */ 741 public <T> T getHotKeywordTimeline(ReduceOp<Status, T> op, String keyword, int page, int count, Date since) throws HatenaHaikuException { 742 return _getKeywordTimeline(op, keyword, page, count, since, true); 615 743 } 616 744 … … 620 748 * 621 749 * @see <a href="http://h.hatena.ne.jp/api#statuses-keyword_timeline">statuses/keyword_timeline</a> 750 * @param op 集合操作 622 751 * @param keyword キーワード 623 752 * @param page 取得するページです。最大数は100です。 … … 629 758 * @since v1.0.0 630 759 */ 631 private List<Status> _getKeywordTimeline(String keyword, int page, int count, Date since, boolean isHot) throws HatenaHaikuException {760 private <T> T _getKeywordTimeline(ReduceOp<Status, T> op, String keyword, int page, int count, Date since, boolean isHot) throws HatenaHaikuException { 632 761 try { 633 762 QueryParameter param = new QueryParameter(isHot); … … 636 765 param.setSince(since); 637 766 String resultXml = HttpUtil.doGet(URL_KEYWORD_TIMELINE + StringUtil.encode(keyword) + Const.EXT_XML, param, isNeedHttpLog()); 638 return toStatusList( XmlUtil.getRootElement(resultXml));767 return toStatusList(op, XmlUtil.getRootElement(resultXml)); 639 768 640 769 } catch (ParserConfigurationException e) { … … 704 833 */ 705 834 public List<Status> getAlbumTimeline(int page, int count, Date since) throws HatenaHaikuException { 835 return getAlbumTimeline(this.<Status>createCollectOp(), page, count, since); 836 } 837 838 /** 839 * 画像を含む最新のエントリのパブリックタイムラインを取得します。<br/> 840 * <i>http://h.hatena.ne.jp/api/statuses/album.xml</i> 841 * 842 * @see <a href="http://h.hatena.ne.jp/api#statuses-album">statuses/album</a> 843 * @param op 集合操作 844 * @param page 取得するページです。最大数は100です。 845 * @param count 取得数を指定します。最大数は 200 です。 846 * @param since その日時よりも新しい投稿のみに絞り込むための日時を指定します。 847 * @return 画像を含む最新のエントリのパブリックタイムライン 848 * @throws HatenaHaikuException 849 * @since v1.1.0 850 */ 851 public <T> T getAlbumTimeline(ReduceOp<Status, T> op, int page, int count, Date since) throws HatenaHaikuException { 706 852 try { 707 853 QueryParameter param = new QueryParameter(); … … 710 856 param.setSince(since); 711 857 String resultXml = HttpUtil.doGet(URL_ALBUM_TIMELINE_XML, param, isNeedHttpLog()); 712 return toStatusList( XmlUtil.getRootElement(resultXml));858 return toStatusList(op, XmlUtil.getRootElement(resultXml)); 713 859 714 860 } catch (ParserConfigurationException e) { … … 782 928 */ 783 929 public List<Status> getAlbumKeywordTimeline(String keyword, int page, int count, Date since) throws HatenaHaikuException { 930 return getAlbumKeywordTimeline(this.<Status>createCollectOp(), keyword, page, count, since); 931 } 932 933 /** 934 * 指定したキーワードの画像を含む最新のエントリのキーワードタイムラインを取得します。<br/> 935 * <i>http://h.hatena.ne.jp/api/statuses/album/<font color="red">キーワード</font>.xml</i> 936 * 937 * @see <a href="http://h.hatena.ne.jp/api#statuses-album">statuses/album</a> 938 * @param op 集合操作 939 * @param keyword キーワード 940 * @param page 取得するページです。最大数は100です。 941 * @param count 取得数を指定します。最大数は 200 です。 942 * @param since その日時よりも新しい投稿のみに絞り込むための日時を指定します。 943 * @return 画像を含む最新のエントリのキーワードタイムライン 944 * @throws HatenaHaikuException 945 * @since v1.1.0 946 */ 947 public <T> T getAlbumKeywordTimeline(ReduceOp<Status, T> op, String keyword, int page, int count, Date since) throws HatenaHaikuException { 784 948 try { 785 949 QueryParameter param = new QueryParameter(); … … 788 952 param.setSince(since); 789 953 String resultXml = HttpUtil.doGet(URL_ALBUM_TIMELINE + StringUtil.encode(keyword) + Const.EXT_XML, param, isNeedHttpLog()); 790 return toStatusList( XmlUtil.getRootElement(resultXml));954 return toStatusList(op, XmlUtil.getRootElement(resultXml)); 791 955 792 956 } catch (ParserConfigurationException e) { … … 865 1029 */ 866 1030 public List<User> getFollowingList(String userId, int page) throws HatenaHaikuException { 1031 return getFollowingList(this.<User>createCollectOp(), userId, page); 1032 } 1033 1034 /** 1035 * 指定したユーザがフォローしているユーザのリストを100件取得します。(指定ページ)<br/> 1036 * <i>http://h.hatena.ne.jp/api/statuses/friends/<font color="red">ユーザID</font>.xml&page=<font color="red">ページ</font></i> 1037 * 1038 * @see <a href="http://h.hatena.ne.jp/api#statuses-friends">statuses/friends</a> 1039 * @param op 集合操作 1040 * @param userId ユーザID 1041 * @param page ページ 1042 * @return 指定したユーザがフォローしているユーザのリスト(指定ページ) 1043 * @throws HatenaHaikuException 1044 * @since v1.1.0 1045 */ 1046 public <T> T getFollowingList(ReduceOp<User, T> op, String userId, int page) throws HatenaHaikuException { 867 1047 try { 868 1048 QueryParameter param = new QueryParameter(); 869 1049 param.setPage(page); 870 1050 String resultXml = HttpUtil.doGet(URL_FOLLOWING_LIST + userId + Const.EXT_XML, param, isNeedHttpLog()); 871 return toUserList( XmlUtil.getRootElement(resultXml));1051 return toUserList(op, XmlUtil.getRootElement(resultXml)); 872 1052 873 1053 } catch (ParserConfigurationException e) { … … 894 1074 */ 895 1075 public List<User> getFollowersList(String userId) throws HatenaHaikuException { 1076 return getFollowersList(this.<User>createCollectOp(), userId); 1077 } 1078 1079 /** 1080 * 指定したユーザをフォローしているユーザのリストを取得します。<br/> 1081 * フォロワーはページ指定できず、一気に全員分取得されるようです。<br/> 1082 * <i>http://h.hatena.ne.jp/api/statuses/followers/<font color="red">ユーザID</font>.xml</i> 1083 * 1084 * @see <a href="http://h.hatena.ne.jp/api#statuses-followers">statuses/followers</a> 1085 * @param op 集合操作 1086 * @param userId ユーザID 1087 * @return 指定したユーザをフォローしているユーザのリスト 1088 * @throws HatenaHaikuException 1089 * @since v1.1.0 1090 */ 1091 public <T> T getFollowersList(ReduceOp<User, T> op, String userId) throws HatenaHaikuException { 896 1092 try { 897 1093 String resultXml = HttpUtil.doGet(URL_FOLLOWERS_LIST + userId + Const.EXT_XML, null, isNeedHttpLog()); 898 return toUserList( XmlUtil.getRootElement(resultXml));1094 return toUserList(op, XmlUtil.getRootElement(resultXml)); 899 1095 900 1096 } catch (ParserConfigurationException e) { … … 950 1146 */ 951 1147 public List<Keyword> getHotKeywordList() throws HatenaHaikuException { 1148 return getHotKeywordList(this.<Keyword>createCollectOp()); 1149 } 1150 1151 /** 1152 * ホットキーワードのリストを取得します。<br/> 1153 * <i>http://h.hatena.ne.jp/api/keywords/hot.xml</i> 1154 * 1155 * @see <a href="http://h.hatena.ne.jp/hotkeywords">注目キーワード</a> 1156 * @see <a href="http://h.hatena.ne.jp/api#keywords-hot">keywords/hot</a> 1157 * @param op 集合操作 1158 * @return ホットキーワードのリスト 1159 * @throws HatenaHaikuException 1160 * @since v1.1.0 1161 */ 1162 public <T> T getHotKeywordList(ReduceOp<Keyword, T> op) throws HatenaHaikuException { 952 1163 try { 953 1164 String resultXml = HttpUtil.doGet(URL_HOT_KEYWORD_LIST_XML, null, isNeedHttpLog()); 954 return toKeywordList( XmlUtil.getRootElement(resultXml));1165 return toKeywordList(op, XmlUtil.getRootElement(resultXml)); 955 1166 956 1167 } catch (ParserConfigurationException e) { … … 964 1175 } 965 1176 } 966 1177 967 1178 /** 968 1179 * キーワードリストを取得します。(1ページ目)<br/> … … 985 1196 * @see <a href="http://h.hatena.ne.jp/keywords">キーワードリスト</a> 986 1197 * @see <a href="http://h.hatena.ne.jp/api#keywords-list">keywords/list</a> 987 * @param page ページ 1198 * @param page ページ (最大数は100です) 988 1199 * @return キーワードリスト(指定ページ) 989 1200 * @throws HatenaHaikuException … … 997 1208 * 指定したワードに部分一致するキーワードリストを取得します。(指定ページ)<br/> 998 1209 * パラメータに?word=00, page=1などが使える。<br/> 999 * pageの最大数が100とAPI解説ページに書かれているが、それ以上でも取得できるようである。<br/>1000 1210 * <i>http://h.hatena.ne.jp/api/keywords/list.xml?word=<font color="red">検索ワード</font>&page=<font color="red">ページ</font></i> 1001 1211 * … … 1003 1213 * @see <a href="http://h.hatena.ne.jp/api#keywords-list">keywords/list</a> 1004 1214 * @param searchWord 検索ワード 1005 * @param page ページ 1215 * @param page ページ (最大数は100です) 1006 1216 * @return キーワードリスト(指定ページ) 1007 1217 * @throws HatenaHaikuException … … 1009 1219 */ 1010 1220 public List<Keyword> getKeywordList(String searchWord, int page) throws HatenaHaikuException { 1221 return getKeywordList(this.<Keyword>createCollectOp(), searchWord, page); 1222 } 1223 1224 /** 1225 * 指定したワードに部分一致するキーワードリストを取得します。(指定ページ)<br/> 1226 * パラメータに?word=00, page=1などが使える。<br/> 1227 * <i>http://h.hatena.ne.jp/api/keywords/list.xml?word=<font color="red">検索ワード</font>&page=<font color="red">ページ</font></i> 1228 * 1229 * @see <a href="http://h.hatena.ne.jp/keywords">キーワードリスト</a> 1230 * @see <a href="http://h.hatena.ne.jp/api#keywords-list">keywords/list</a> 1231 * @param op 集合操作 1232 * @param searchWord 検索ワード 1233 * @param page ページ (最大数は100です) 1234 * @return キーワードリスト(指定ページ) 1235 * @throws HatenaHaikuException 1236 * @since v1.1.0 1237 */ 1238 public <T> T getKeywordList(ReduceOp<Keyword, T> op, String searchWord, int page) throws HatenaHaikuException { 1011 1239 try { 1012 1240 QueryParameter param = new QueryParameter(); … … 1014 1242 param.setPage(page); 1015 1243 String resultXml = HttpUtil.doGet(URL_KEYWORD_LIST_XML, param, isNeedHttpLog()); 1016 return toKeywordList( XmlUtil.getRootElement(resultXml));1244 return toKeywordList(op, XmlUtil.getRootElement(resultXml)); 1017 1245 1018 1246 } catch (ParserConfigurationException e) { … … 1038 1266 */ 1039 1267 public List<Keyword> getFollowingKeywordList(String userId) throws HatenaHaikuException { 1268 return getFollowingKeywordList(this.<Keyword>createCollectOp(), userId); 1269 } 1270 1271 /** 1272 * 指定したユーザがフォローしているキーワードのリストを取得します。<br/> 1273 * <i>http://h.hatena.ne.jp/api/statuses/keywords/<font color="red">ユーザID</font>.xml</i> 1274 * 1275 * @see <a href="http://h.hatena.ne.jp/api#statuses-keywords">statuses/keywords</a> 1276 * @param op 集合操作 1277 * @param userId ユーザID 1278 * @return 指定したユーザがフォローしているキーワードリスト 1279 * @throws HatenaHaikuException 1280 * @since v1.1.0 1281 */ 1282 public <T> T getFollowingKeywordList(ReduceOp<Keyword, T> op, String userId) throws HatenaHaikuException { 1040 1283 try { 1041 1284 String resultXml = HttpUtil.doGet(URL_FOLLOWING_KEYWORD_LIST + userId + Const.EXT_XML, null, isNeedHttpLog()); 1042 return toKeywordList( XmlUtil.getRootElement(resultXml));1285 return toKeywordList(op, XmlUtil.getRootElement(resultXml)); 1043 1286 1044 1287 } catch (ParserConfigurationException e) { … … 1167 1410 * ステータスエレメントルートをStatus情報リストに変換します。 1168 1411 * 1412 * @param op 集合操作 1169 1413 * @param elemStatuses ステータスエレメントルート 1170 1414 * @return Status情報リスト 1171 1415 * @since v0.0.1 1172 1416 */ 1173 protected List<Status> toStatusList(Element elemStatuses) throws HatenaHaikuException { 1174 List<Status> statusList = new ArrayList<Status>(); 1417 protected <T> T toStatusList(ReduceOp<Status, T> op, Element elemStatuses) throws HatenaHaikuException { 1175 1418 for (Element elemStatus : XmlUtil.getChildElementsByTagName(elemStatuses, "status")) { 1176 statusList.add(toStatus(elemStatus));1177 } 1178 return statusList;1419 op.add(toStatus(elemStatus)); 1420 } 1421 return op.value(); 1179 1422 } 1180 1423 … … 1206 1449 * ユーザエレメントルートをUser情報リストに変換します。 1207 1450 * 1451 * @param op 集合操作 1208 1452 * @param elemUsers ユーザエレメントルート 1209 1453 * @return User情報リスト 1210 1454 * @since v0.0.1 1211 1455 */ 1212 protected List<User> toUserList(Element elemUsers) throws HatenaHaikuException { 1213 List<User> userList = new ArrayList<User>(); 1456 protected <T> T toUserList(ReduceOp<User, T> op, Element elemUsers) throws HatenaHaikuException { 1214 1457 for (Element elemUser : XmlUtil.getChildElementsByTagName(elemUsers, "user")) { 1215 userList.add(toUser(elemUser));1216 } 1217 return userList;1458 op.add(toUser(elemUser)); 1459 } 1460 return op.value(); 1218 1461 } 1219 1462 … … 1243 1486 * キーワードエレメントルートをKeyword情報リストに変換します。 1244 1487 * 1488 * @param op 集合操作 1245 1489 * @param elemKeywords キーワードエレメントルート 1246 1490 * @return Keyword情報リスト 1247 1491 * @since v0.0.1 1248 1492 */ 1249 protected List<Keyword> toKeywordList(Element elemKeywords) throws HatenaHaikuException { 1250 List<Keyword> keywordList = new ArrayList<Keyword>(); 1493 protected <T> T toKeywordList(ReduceOp<Keyword, T> op, Element elemKeywords) throws HatenaHaikuException { 1251 1494 for (Element elemKeyword : XmlUtil.getChildElementsByTagName(elemKeywords, "keyword")) { 1252 keywordList.add(toKeyword(elemKeyword)); 1253 } 1254 return keywordList; 1255 } 1495 op.add(toKeyword(elemKeyword)); 1496 } 1497 return op.value(); 1498 } 1499 1500 /** 1501 * 標準の集合操作を返却します。<br/> 1502 * {@link java.util.ArrayList}にaddしていく。 1503 * 1504 * @param <E> 集めるEntity 1505 * @return 指定したEntityのArrayListによる集合操作 1506 * @since v1.1.0 1507 */ 1508 protected <E extends Entity<E>> CollectOp<E, List<E>> createCollectOp() { 1509 return new CollectOp<E, List<E>>(new ArrayList<E>()); 1510 } 1511 1256 1512 } -
lang/java/misc/hatenahaiku4j/trunk/src/hatenahaiku4j/Keyword.java
r35467 r35648 11 11 * @author fumokmm 12 12 */ 13 public class Keyword { 13 public class Keyword implements Entity<Keyword> { 14 14 15 /** 投稿数 */ 15 16 private int entryCount; … … 195 196 this.title = title; 196 197 } 198 199 /** 200 * このキーワード情報と指定されたキーワード情報の順序を比較します。<br/> 201 * このキーワード情報が指定されたキーワード情報より小さい場合は負の整数、<br/> 202 * 等しい場合はゼロ、大きい場合は正の整数を返します。<br/> 203 * <br/> 204 * 比較はキーワードタイトルで行います。 205 * 206 * @param keyword 指定されたキーワード情報 207 * @since v1.1.0 208 */ 209 @Override 210 public int compareTo(Keyword keyword) { 211 return this.title.compareTo(keyword.title); 212 } 213 214 /* (non-Javadoc) 215 * @see java.lang.Object#hashCode() 216 */ 217 @Override 218 public int hashCode() { 219 return this.title.hashCode(); 220 } 221 222 /* (non-Javadoc) 223 * @see java.lang.Object#equals(java.lang.Object) 224 */ 225 @Override 226 public boolean equals(Object obj) { 227 if (this == obj) { 228 return true; 229 } 230 if (obj == null) { 231 return false; 232 } 233 if (getClass() != obj.getClass()) { 234 return false; 235 } 236 237 Keyword other = (Keyword) obj; 238 if (this.title == null) { 239 if (other.title != null) { 240 return false; 241 } 242 } else if (!this.title.equals(other.title)) { 243 return false; 244 } 245 return true; 246 } 247 197 248 } 198 249 -
lang/java/misc/hatenahaiku4j/trunk/src/hatenahaiku4j/Status.java
r35467 r35648 12 12 * @author fumokmm 13 13 */ 14 public class Status { 14 public class Status implements Entity<Status> { 15 15 16 /** ステータスID */ 16 17 private String id; … … 410 411 } 411 412 } 413 414 /** 415 * このステータス情報と指定されたステータス情報の順序を比較します。<br/> 416 * このステータス情報が指定されたステータス情報より小さい場合は負の整数、<br/> 417 * 等しい場合はゼロ、大きい場合は正の整数を返します。<br/> 418 * <br/> 419 * 比較はステータスIDで行います。 420 * 421 * @param status 指定されたステータス情報 422 * @since v1.1.0 423 */ 424 @Override 425 public int compareTo(Status status) { 426 return this.id.compareTo(status.id); 427 } 428 429 /* (non-Javadoc) 430 * @see java.lang.Object#hashCode() 431 */ 432 @Override 433 public int hashCode() { 434 return this.id.hashCode(); 435 } 436 437 /* (non-Javadoc) 438 * @see java.lang.Object#equals(java.lang.Object) 439 */ 440 @Override 441 public boolean equals(Object obj) { 442 if (this == obj) { 443 return true; 444 } 445 if (obj == null) { 446 return false; 447 } 448 if (getClass() != obj.getClass()) { 449 return false; 450 } 451 452 Status other = (Status) obj; 453 if (this.id == null) { 454 if (other.id != null) { 455 return false; 456 } 457 } else if (!this.id.equals(other.id)) { 458 return false; 459 } 460 return true; 461 } 462 412 463 } 413 464 -
lang/java/misc/hatenahaiku4j/trunk/src/hatenahaiku4j/User.java
r35467 r35648 7 7 * @author fumokmm 8 8 */ 9 public class User { 9 public class User implements Entity<User> { 10 10 11 /** ユーザ名 */ 11 12 private String name; … … 252 253 } 253 254 255 /** 256 * このユーザ情報と指定されたユーザ情報の順序を比較します。<br/> 257 * このユーザ情報が指定されたユーザ情報より小さい場合は負の整数、<br/> 258 * 等しい場合はゼロ、大きい場合は正の整数を返します。<br/> 259 * <br/> 260 * 比較はユーザIDで行います。 261 * 262 * @param user 指定されたユーザ情報 263 * @since v1.1.0 264 */ 265 @Override 266 public int compareTo(User user) { 267 return this.id.compareTo(user.id); 268 } 269 270 /* (non-Javadoc) 271 * @see java.lang.Object#hashCode() 272 */ 273 @Override 274 public int hashCode() { 275 return this.id.hashCode(); 276 } 277 278 /* (non-Javadoc) 279 * @see java.lang.Object#equals(java.lang.Object) 280 */ 281 @Override 282 public boolean equals(Object obj) { 283 if (this == obj) { 284 return true; 285 } 286 if (obj == null) { 287 return false; 288 } 289 if (getClass() != obj.getClass()) { 290 return false; 291 } 292 293 User other = (User) obj; 294 if (this.id == null) { 295 if (other.id != null) { 296 return false; 297 } 298 } else if (!this.id.equals(other.id)) { 299 return false; 300 } 301 return true; 302 } 303 254 304 } 255 305
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)