Browse files

TFJ-643 add getToUserName() and getFromUserName()

  • Loading branch information...
1 parent cd62a8e commit b36500cae55c6fd9bef28949ab48c9910645ccd5 @yusuke yusuke committed Nov 27, 2011
View
15 twitter4j-core/src/main/java/twitter4j/Tweet.java
@@ -47,13 +47,28 @@
String getToUser();
/**
+ * returns the to_user_name
+ *
+ * @return the to_user_name value or null if to_user is not specified by the tweet
+ */
+ String getToUserName();
+
+ /**
* returns the from_user
*
* @return the from_user
*/
String getFromUser();
/**
+ * returns the from_user_name
+ *
+ * @return the from_user_name
+ * @since Twitter4J 2.2.6
+ */
+ String getFromUserName();
+
+ /**
* returns the status id of the tweet
*
* @return the status id
View
20 twitter4j-core/src/main/java/twitter4j/internal/json/TweetJSONImpl.java
@@ -48,7 +48,9 @@
private String text;
private long toUserId = -1;
private String toUser = null;
- private String fromUser;
+ private String toUserName = null;
+ private String fromUser = null;
+ private String fromUserName = null;
private long id;
private long fromUserId;
private String isoLanguageCode = null;
@@ -69,7 +71,9 @@
text = getUnescapedString("text", tweet);
toUserId = getLong("to_user_id", tweet);
toUser = getRawString("to_user", tweet);
+ toUserName = getRawString("to_user_name", tweet);
fromUser = getRawString("from_user", tweet);
+ fromUserName = getRawString("from_user_name", tweet);
id = getLong("id", tweet);
fromUserId = getLong("from_user_id", tweet);
isoLanguageCode = getRawString("iso_language_code", tweet);
@@ -180,13 +184,27 @@ public String getToUser() {
/**
* {@inheritDoc}
*/
+ public String getToUserName() {
+ return toUserName;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public String getFromUser() {
return fromUser;
}
/**
* {@inheritDoc}
*/
+ public String getFromUserName() {
+ return fromUserName;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public long getId() {
return id;
}
View
1 twitter4j-core/src/test/java/twitter4j/SearchAPITest.java
@@ -78,6 +78,7 @@ public void testSearch() throws Exception {
assertNotNull(tweets.get(0).getText());
assertNotNull(tweets.get(0).getCreatedAt());
assertNotNull("from user", tweets.get(0).getFromUser());
+ assertNotNull("from_user_name", tweets.get(0).getFromUserName());
assertTrue("fromUserId", -1 != tweets.get(0).getFromUserId());
assertTrue(-1 != tweets.get(0).getId());
// assertNotNull(tweets.get(0).getIsoLanguageCode());

0 comments on commit b36500c

Please sign in to comment.