My favorites | Sign in
Project Logo
                
Changes to /trunk/ajn-web/src/main/java/com/appspot/ajnweb/model/Tweet.java
r7 vs. r14   Edit
  Compare: vs.   Format:
Revision r14
Go to: 
Project members, sign in to write a code review
/trunk/ajn-web/src/main/java/com/appspot/ajnweb/model/Tweet.java   r7 /trunk/ajn-web/src/main/java/com/appspot/ajnweb/model/Tweet.java   r14
1 package com.appspot.ajnweb.model; 1 package com.appspot.ajnweb.model;
2 2
3 import java.io.Serializable; 3 import java.io.Serializable;
4 import java.util.Date; 4 import java.util.Date;
5 5
6 import org.slim3.datastore.Attribute; 6 import org.slim3.datastore.Attribute;
7 import org.slim3.datastore.Model; 7 import org.slim3.datastore.Model;
8 8
9 import com.google.appengine.api.datastore.Key; 9 import com.google.appengine.api.datastore.Key;
10 import com.google.appengine.api.datastore.KeyFactory; 10 import com.google.appengine.api.datastore.KeyFactory;
11 11
12 /** 12 /**
13 * TwitterのStatus. 13 * TwitterのStatus.
14 * <p>Userの情報を少し展開した状態。</p> 14 * <p>Userの情報を少し展開した状態。</p>
15 * @author shin1ogawa 15 * @author shin1ogawa
16 * @see twitter4j.Status 16 * @see twitter4j.Status
17 * @see twitter4j.Tweet 17 * @see twitter4j.Tweet
18 */ 18 */
19 @Model 19 @Model
20 public class Tweet implements Serializable { 20 public class Tweet implements Serializable {
21 21
22 private static final long serialVersionUID = 82952814930599860L; 22 private static final long serialVersionUID = 82952814930599860L;
23 23
24 /** スキーマのバージョン。構造が変わったら更新する事! */ 24 /** スキーマのバージョン。構造が変わったら更新する事! */
25 private int schemaVersion = 1; 25 private int schemaVersion = 2;
26 26
27 @Attribute(primaryKey = true) 27 @Attribute(primaryKey = true)
28 private Key key; 28 private Key key;
29 29
30 private Date createdAt; 30 private Date createdAt;
31 31
32 private Long inReplyToStatusId; 32 private Long inReplyToStatusId;
33 33
34 private Integer inReplyToUserId; 34 private Integer inReplyToUserId;
35 35
36 private Integer userId; 36 private Integer userId;
37 37
38 private String userName; 38 private String userName;
39 39
40 private String screenName;
41
40 @Attribute(lob = true) 42 @Attribute(lob = true)
41 private String text; 43 private String text;
42 44
43 private String userProfileImageUrl; 45 private String userProfileImageUrl;
44 46
45 47
46 /** 48 /**
47 * {@link twitter4j.Status}の値をコピーしてインスタンスを作成する。 49 * {@link twitter4j.Status}の値をコピーしてインスタンスを作成する。
48 * @param status 50 * @param status
49 * @return 新しく作成したインスタンス 51 * @return 新しく作成したインスタンス
50 */ 52 */
51 public static Tweet newInstance(twitter4j.Status status) { 53 public static Tweet newInstance(twitter4j.Status status) {
52 Tweet instance = new Tweet(); 54 Tweet instance = new Tweet();
53 instance.setKey(KeyFactory.createKey(Tweet.class.getSimpleName(), status.getId())); 55 instance.setKey(KeyFactory.createKey(Tweet.class.getSimpleName(), status.getId()));
54 instance.setCreatedAt(status.getCreatedAt()); 56 instance.setCreatedAt(status.getCreatedAt());
55 instance.setInReplyToStatusId(status.getInReplyToStatusId()); 57 instance.setInReplyToStatusId(status.getInReplyToStatusId());
56 instance.setInReplyToUserId(status.getInReplyToUserId()); 58 instance.setInReplyToUserId(status.getInReplyToUserId());
57 instance.setText(status.getText()); 59 instance.setText(status.getText());
58 instance.setUserId(status.getUser().getId()); 60 instance.setUserId(status.getUser().getId());
61 instance.setScreenName(status.getUser().getScreenName());
59 instance.setUserName(status.getUser().getName()); 62 instance.setUserName(status.getUser().getName());
60 instance.setUserProfileImageUrl(status.getUser().getProfileImageURL().toString()); 63 instance.setUserProfileImageUrl(status.getUser().getProfileImageURL().toString());
61 return instance; 64 return instance;
62 } 65 }
63 66
64 /** 67 /**
65 * @return the schemaVersion 68 * @return the schemaVersion
66 * @category accessor 69 * @category accessor
67 */ 70 */
68 public int getSchemaVersion() { 71 public int getSchemaVersion() {
69 return schemaVersion; 72 return schemaVersion;
70 } 73 }
71 74
72 /** 75 /**
73 * @param schemaVersion the schemaVersion to set 76 * @param schemaVersion the schemaVersion to set
74 * @category accessor 77 * @category accessor
75 */ 78 */
76 public void setSchemaVersion(int schemaVersion) { 79 public void setSchemaVersion(int schemaVersion) {
77 this.schemaVersion = schemaVersion; 80 this.schemaVersion = schemaVersion;
78 } 81 }
79 82
80 /** 83 /**
81 * @return the key 84 * @return the key
82 * @category accessor 85 * @category accessor
83 */ 86 */
84 public Key getKey() { 87 public Key getKey() {
85 return key; 88 return key;
86 } 89 }
87 90
88 /** 91 /**
89 * @param key the key to set 92 * @param key the key to set
90 * @category accessor 93 * @category accessor
91 */ 94 */
92 public void setKey(Key key) { 95 public void setKey(Key key) {
93 this.key = key; 96 this.key = key;
94 } 97 }
95 98
96 /** 99 /**
97 * @return the createdAt 100 * @return the createdAt
98 * @category accessor 101 * @category accessor
99 */ 102 */
100 public Date getCreatedAt() { 103 public Date getCreatedAt() {
101 return createdAt; 104 return createdAt;
102 } 105 }
103 106
104 /** 107 /**
105 * @param createdAt the createdAt to set 108 * @param createdAt the createdAt to set
106 * @category accessor 109 * @category accessor
107 */ 110 */
108 public void setCreatedAt(Date createdAt) { 111 public void setCreatedAt(Date createdAt) {
109 this.createdAt = createdAt; 112 this.createdAt = createdAt;
110 } 113 }
111 114
112 /** 115 /**
113 * @return the inReplyToStatusId 116 * @return the inReplyToStatusId
114 * @category accessor 117 * @category accessor
115 */ 118 */
116 public Long getInReplyToStatusId() { 119 public Long getInReplyToStatusId() {
117 return inReplyToStatusId; 120 return inReplyToStatusId;
118 } 121 }
119 122
120 /** 123 /**
121 * @param inReplyToStatusId the inReplyToStatusId to set 124 * @param inReplyToStatusId the inReplyToStatusId to set
122 * @category accessor 125 * @category accessor
123 */ 126 */
124 public void setInReplyToStatusId(Long inReplyToStatusId) { 127 public void setInReplyToStatusId(Long inReplyToStatusId) {
125 this.inReplyToStatusId = inReplyToStatusId; 128 this.inReplyToStatusId = inReplyToStatusId;
126 } 129 }
127 130
128 /** 131 /**
129 * @return the inReplyToUserId 132 * @return the inReplyToUserId
130 * @category accessor 133 * @category accessor
131 */ 134 */
132 public Integer getInReplyToUserId() { 135 public Integer getInReplyToUserId() {
133 return inReplyToUserId; 136 return inReplyToUserId;
134 } 137 }
135 138
136 /** 139 /**
137 * @param inReplyToUserId the inReplyToUserId to set 140 * @param inReplyToUserId the inReplyToUserId to set
138 * @category accessor 141 * @category accessor
139 */ 142 */
140 public void setInReplyToUserId(Integer inReplyToUserId) { 143 public void setInReplyToUserId(Integer inReplyToUserId) {
141 this.inReplyToUserId = inReplyToUserId; 144 this.inReplyToUserId = inReplyToUserId;
142 } 145 }
143 146
144 /** 147 /**
145 * @return the userId 148 * @return the userId
146 * @category accessor 149 * @category accessor
147 */ 150 */
148 public Integer getUserId() { 151 public Integer getUserId() {
149 return userId; 152 return userId;
150 } 153 }
151 154
152 /** 155 /**
153 * @param userId the userId to set 156 * @param userId the userId to set
154 * @category accessor 157 * @category accessor
155 */ 158 */
156 public void setUserId(Integer userId) { 159 public void setUserId(Integer userId) {
157 this.userId = userId; 160 this.userId = userId;
158 } 161 }
159 162
160 /** 163 /**
161 * @return the userName 164 * @return the userName
162 * @category accessor 165 * @category accessor
163 */ 166 */
164 public String getUserName() { 167 public String getUserName() {
165 return userName; 168 return userName;
166 } 169 }
167 170
168 /** 171 /**
169 * @param userName the userName to set 172 * @param userName the userName to set
170 * @category accessor 173 * @category accessor
171 */ 174 */
172 public void setUserName(String userName) { 175 public void setUserName(String userName) {
173 this.userName = userName; 176 this.userName = userName;
174 } 177 }
175 178
176 /** 179 /**
177 * @return the text 180 * @return the text
178 * @category accessor 181 * @category accessor
179 */ 182 */
180 public String getText() { 183 public String getText() {
181 return text; 184 return text;
182 } 185 }
183 186
184 /** 187 /**
185 * @param text the text to set 188 * @param text the text to set
186 * @category accessor 189 * @category accessor
187 */ 190 */
188 public void setText(String text) { 191 public void setText(String text) {
189 this.text = text; 192 this.text = text;
190 } 193 }
191 194
192 /** 195 /**
193 * @return the userProfileImageUrl 196 * @return the userProfileImageUrl
194 * @category accessor 197 * @category accessor
195 */ 198 */
196 public String getUserProfileImageUrl() { 199 public String getUserProfileImageUrl() {
197 return userProfileImageUrl; 200 return userProfileImageUrl;
198 } 201 }
199 202
200 /** 203 /**
201 * @param userProfileImageUrl the userProfileImageUrl to set 204 * @param userProfileImageUrl the userProfileImageUrl to set
202 * @category accessor 205 * @category accessor
203 */ 206 */
204 public void setUserProfileImageUrl(String userProfileImageUrl) { 207 public void setUserProfileImageUrl(String userProfileImageUrl) {
205 this.userProfileImageUrl = userProfileImageUrl; 208 this.userProfileImageUrl = userProfileImageUrl;
206 } 209 }
207 } 210
211 /**
212 * @param screenName the screenName to set
213 * @category accessor
214 */
215 public void setScreenName(String screenName) {
216 this.screenName = screenName;
217 }
218
219 /**
220 * @return the screenName
221 * @category accessor
222 */
223 public String getScreenName() {
224 return screenName;
225 }
226 }
Hosted by Google Code