add weibo src
[freespace.git] / src / weibo4android / Paging.java
blob26d16a09186973bef85ced28880ed4b4079151ce
1 /*
2 Copyright (c) 2007-2009, Yusuke Yamamoto
3 All rights reserved.
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in the
11 documentation and/or other materials provided with the distribution.
12 * Neither the name of the Yusuke Yamamoto nor the
13 names of its contributors may be used to endorse or promote products
14 derived from this software without specific prior written permission.
16 THIS SOFTWARE IS PROVIDED BY Yusuke Yamamoto ``AS IS'' AND ANY
17 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL Yusuke Yamamoto BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 package weibo4android;
29 /**
30 * Controlls pagination
32 * @author Yusuke Yamamoto - yusuke at mac.com
34 public class Paging implements java.io.Serializable {
35 private int page = -1;
36 private int count = -1;
37 private long sinceId = -1;
38 private long maxId = -1;
39 private static final long serialVersionUID = -3285857427993796670L;
41 public Paging() {
44 public Paging(int page) {
45 setPage(page);
48 public Paging(long sinceId) {
49 setSinceId(sinceId);
52 public Paging(int page, int count) {
53 this(page);
54 setCount(count);
56 public Paging(int page, long sinceId) {
57 this(page);
58 setSinceId(sinceId);
61 public Paging(int page, int count, long sinceId) {
62 this(page, count);
63 setSinceId(sinceId);
66 public Paging(int page, int count, long sinceId, long maxId) {
67 this(page, count, sinceId);
68 setMaxId(maxId);
71 public int getPage() {
72 return page;
75 public void setPage(int page) {
76 if (page < 1) {
77 throw new IllegalArgumentException("page should be positive integer. passed:" + page);
79 this.page = page;
82 public int getCount() {
83 return count;
86 public void setCount(int count) {
87 if (count < 1) {
88 throw new IllegalArgumentException("count should be positive integer. passed:" + count);
90 this.count = count;
93 public Paging count(int count) {
94 setCount(count);
95 return this;
98 public long getSinceId() {
99 return sinceId;
102 public void setSinceId(int sinceId) {
103 if (sinceId < 1) {
104 throw new IllegalArgumentException("since_id should be positive integer. passed:" + sinceId);
106 this.sinceId = sinceId;
109 public Paging sinceId(int sinceId) {
110 setSinceId(sinceId);
111 return this;
114 public void setSinceId(long sinceId) {
115 if (sinceId < 1) {
116 throw new IllegalArgumentException("since_id should be positive integer. passed:" + sinceId);
118 this.sinceId = sinceId;
121 public Paging sinceId(long sinceId) {
122 setSinceId(sinceId);
123 return this;
126 public long getMaxId() {
127 return maxId;
130 public void setMaxId(long maxId) {
131 if (maxId < 1) {
132 throw new IllegalArgumentException("max_id should be positive integer. passed:" + maxId);
134 this.maxId = maxId;
137 public Paging maxId(long maxId) {
138 setMaxId(maxId);
139 return this;