Permalink
Browse files

TFJ-645 add getInReplyToId to Tweet interface

introduced super intaface of twitter4j.Status/Tweet - twitter4j.Twt
  • Loading branch information...
yusuke committed Dec 4, 2011
1 parent b36500c commit 61d6ee7774d7349d26a1612462ef8bbb02a01a7d
@@ -24,14 +24,13 @@
* @author Yusuke Yamamoto - yusuke at mac.com
*/
public interface Status extends Comparable<Status>, TwitterResponse,
- EntitySupport, java.io.Serializable {
+ EntitySupport, Twt, java.io.Serializable {
/**
* Return the created_at
*
* @return created_at
* @since Twitter4J 1.1.0
*/
-
Date getCreatedAt();
/**
@@ -23,7 +23,7 @@
*
* @author Yusuke Yamamoto - yusuke at mac.com
*/
-public interface Tweet extends Comparable<Tweet>, EntitySupport,
+public interface Tweet extends Comparable<Tweet>, EntitySupport, Twt,
java.io.Serializable {
/**
* returns the text
@@ -98,6 +98,14 @@
*/
String getSource();
+ /**
+ * Returns the in_reply_tostatus_id
+ *
+ * @return the in_reply_tostatus_id
+ * @since Twitter4J 2.2.6
+ */
+ long getInReplyToStatusId();
+
/**
* returns the profile_image_url
*
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2007 Yusuke Yamamoto
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package twitter4j;
+
+import java.util.Date;
+
+/**
+ * @author Yusuke Yamamoto - yusuke at mac.com
+ * @since Twitter4J 2.2.6
+ */
+public interface Twt {
+ /**
+ * returns the created_at
+ *
+ * @return the created_at
+ */
+ Date getCreatedAt();
+
+ /**
+ * returns the status id of the tweet
+ *
+ * @return the status id
+ */
+ long getId();
+
+ /**
+ * returns the text
+ *
+ * @return the text
+ */
+ String getText();
+
+ /**
+ * returns the source of the tweet
+ *
+ * @return the source of the tweet
+ */
+ String getSource();
+
+ /**
+ * Returns the in_reply_tostatus_id
+ *
+ * @return the in_reply_tostatus_id
+ */
+ long getInReplyToStatusId();
+
+ /**
+ * Returns the place associated with the Tweet.
+ *
+ * @return The place associated with the Tweet
+ */
+ Place getPlace();
+
+ /**
+ * Returns The location that this tweet refers to if available.
+ *
+ * @return returns The location that this tweet refers to if available (can be null)
+ */
+ GeoLocation getGeoLocation();
+}
@@ -55,6 +55,7 @@
private long fromUserId;
private String isoLanguageCode = null;
private String source;
+ private long inReplyToStatusId = -1;
private String profileImageUrl;
private Date createdAt;
private String location;
@@ -78,6 +79,7 @@
fromUserId = getLong("from_user_id", tweet);
isoLanguageCode = getRawString("iso_language_code", tweet);
source = getUnescapedString("source", tweet);
+ inReplyToStatusId = getLong("in_reply_to_status_id", tweet);
profileImageUrl = getUnescapedString("profile_image_url", tweet);
createdAt = getDate("created_at", tweet, "EEE, dd MMM yyyy HH:mm:ss z");
location = getRawString("location", tweet);
@@ -230,6 +232,13 @@ public String getSource() {
return source;
}
+ /**
+ * {@inheritDoc}
+ */
+ public long getInReplyToStatusId() {
+ return inReplyToStatusId;
+ }
+
/**
* {@inheritDoc}
*/
@@ -317,11 +326,14 @@ public int hashCode() {
int result = text != null ? text.hashCode() : 0;
result = 31 * result + (int) (toUserId ^ (toUserId >>> 32));
result = 31 * result + (toUser != null ? toUser.hashCode() : 0);
+ result = 31 * result + (toUserName != null ? toUserName.hashCode() : 0);
result = 31 * result + (fromUser != null ? fromUser.hashCode() : 0);
+ result = 31 * result + (fromUserName != null ? fromUserName.hashCode() : 0);
result = 31 * result + (int) (id ^ (id >>> 32));
result = 31 * result + (int) (fromUserId ^ (fromUserId >>> 32));
result = 31 * result + (isoLanguageCode != null ? isoLanguageCode.hashCode() : 0);
result = 31 * result + (source != null ? source.hashCode() : 0);
+ result = 31 * result + (int) (inReplyToStatusId ^ (inReplyToStatusId >>> 32));
result = 31 * result + (profileImageUrl != null ? profileImageUrl.hashCode() : 0);
result = 31 * result + (createdAt != null ? createdAt.hashCode() : 0);
result = 31 * result + (location != null ? location.hashCode() : 0);
@@ -341,11 +353,14 @@ public String toString() {
"text='" + text + '\'' +
", toUserId=" + toUserId +
", toUser='" + toUser + '\'' +
+ ", toUserName='" + toUserName + '\'' +
", fromUser='" + fromUser + '\'' +
+ ", fromUserName='" + fromUserName + '\'' +
", id=" + id +
", fromUserId=" + fromUserId +
", isoLanguageCode='" + isoLanguageCode + '\'' +
", source='" + source + '\'' +
+ ", inReplyToStatusId=" + inReplyToStatusId +
", profileImageUrl='" + profileImageUrl + '\'' +
", createdAt=" + createdAt +
", location='" + location + '\'' +
@@ -121,10 +121,11 @@ public void testSearch() throws Exception {
query = new Query("\\u5e30%u5e30 <%}& foobar").rpp(100).page(1);
QueryResult result = twitter1.search(query);
- query = new Query("#sendro").rpp(1).page(1);
+ query = new Query("#sendro to:yusukey").rpp(1).page(1);
result = twitter1.search(query);
- System.out.println(result.getTweets().get(0));
assertNotNull(result.getTweets().get(0).getHashtagEntities());
+ assertNotNull(result.getTweets().get(0).getUserMentionEntities());
+ assertNotNull(result.getTweets().get(0).getURLEntities());
}
public void testTrends() throws Exception {

0 comments on commit 61d6ee7

Please sign in to comment.