winterwell.jtwitter
Class Message

java.lang.Object
  extended by winterwell.jtwitter.Message
All Implemented Interfaces:
java.io.Serializable, Twitter.ITweet

public final class Message
extends java.lang.Object
implements Twitter.ITweet

A Twitter direct message. Fields are null if unset. TODO are there more fields now? check the raw json

See Also:
Serialized Form

Field Summary
 java.lang.Number inReplyToMessageId
          Equivalent to Status.inReplyToStatusId *but null by default*.
 java.lang.String text
           
 
Method Summary
 boolean equals(java.lang.Object obj)
          Tests by class=Message and tweet id number
 java.util.Date getCreatedAt()
           
 java.lang.String getDisplayText()
           
 java.lang.Long getId()
          Twitter IDs are numbers - but they can exceed the range of Java's signed long.
 java.lang.String getLocation()
           
 java.util.List<java.lang.String> getMentions()
           
 Place getPlace()
           
 User getRecipient()
           
 User getSender()
           
 java.lang.String getText()
          The actual status text.
 java.util.List<Twitter.TweetEntity> getTweetEntities(Twitter.KEntityType type)
          Twitter wrap urls with their own url-shortener (as a defence against malicious tweets).
 User getUser()
          This is equivalent to getSender()
 int hashCode()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

inReplyToMessageId

public java.lang.Number inReplyToMessageId
Equivalent to Status.inReplyToStatusId *but null by default*. If you want to use this, you must set it yourself. The field is just a convenient storage place. Strangely Twitter don't report the previous ID for messages.


text

public final java.lang.String text
Method Detail

getDisplayText

public java.lang.String getDisplayText()
Specified by:
getDisplayText in interface Twitter.ITweet
Returns:
text, with the t.co urls replaced. Use-case: for filtering based on text contents, when we want to match against the full url. Note: this does NOT resolve short urls from bit.ly etc.

equals

public boolean equals(java.lang.Object obj)
Tests by class=Message and tweet id number

Overrides:
equals in class java.lang.Object

getCreatedAt

public java.util.Date getCreatedAt()
Specified by:
getCreatedAt in interface Twitter.ITweet

getId

public java.lang.Long getId()
Description copied from interface: Twitter.ITweet
Twitter IDs are numbers - but they can exceed the range of Java's signed long.

Specified by:
getId in interface Twitter.ITweet
Returns:
The Twitter id for this post. This is used by some API methods.

Note: this may switch to BigInteger in the future, if Twitter change their id numbering scheme. Use Number (which is a super-class for both Long and BigInteger) if you wish to future-proof your code.


getLocation

public java.lang.String getLocation()
Specified by:
getLocation in interface Twitter.ITweet
Returns:
the location of this tweet. Can be null, never blank. This can come from geo-tagging or the user's location. This may be a place name, or in the form "latitude,longitude" if it came from a geo-tagged source.

Note: This will be set if Twitter supply any geo-information. We extract a location from geo and place objects.


getMentions

public java.util.List<java.lang.String> getMentions()
Specified by:
getMentions in interface Twitter.ITweet
Returns:
list of screen-names this message is to. May be empty, never null. For Statuses, this is anyone mentioned in the message. For DMs, this is a wrapper round getRecipient().

Notes: This method is in ITweet as a convenience to allow the same code to process both Statuses and Messages where possible. It would be better named "getRecipients()", but for historical reasons it isn't.


getPlace

public Place getPlace()
Specified by:
getPlace in interface Twitter.ITweet
Returns:
more information on the location of this tweet. This is usually null!

getRecipient

public User getRecipient()
Returns:
the recipient (for messages sent by the authenticating user)

getSender

public User getSender()

getText

public java.lang.String getText()
Description copied from interface: Twitter.ITweet
The actual status text. This is also returned by Twitter.toString()

Specified by:
getText in interface Twitter.ITweet

getTweetEntities

public java.util.List<Twitter.TweetEntity> getTweetEntities(Twitter.KEntityType type)
Description copied from interface: Twitter.ITweet
Twitter wrap urls with their own url-shortener (as a defence against malicious tweets). You are recommended to direct people to the Twitter-url, but use the original url for display.

Entity support is off by default. Request entity support by setting Twitter.setIncludeTweetEntities(boolean). Twitter do NOT support entities for search :(

Specified by:
getTweetEntities in interface Twitter.ITweet
Parameters:
type - urls, user_mentions, or hashtags
Returns:
the text entities in this tweet, or null if the info was not supplied.

getUser

public User getUser()
This is equivalent to getSender()

Specified by:
getUser in interface Twitter.ITweet

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object