abstract class TwitterBaseImpl extends java.lang.Object implements TwitterBase, java.io.Serializable, OAuthSupport, OAuth2Support
Modifier and Type | Field and Description |
---|---|
(package private) Authorization |
auth |
(package private) Configuration |
conf |
(package private) ObjectFactory |
factory |
(package private) HttpClient |
http |
private long |
id |
private java.util.List<RateLimitStatusListener> |
rateLimitStatusListeners |
private java.lang.String |
screenName |
private static long |
serialVersionUID |
private static java.lang.String |
WWW_DETAILS |
Constructor and Description |
---|
TwitterBaseImpl(Configuration conf,
Authorization auth) |
Modifier and Type | Method and Description |
---|---|
void |
addRateLimitStatusListener(RateLimitStatusListener listener)
Registers a RateLimitStatusListener for account associated rate limits
|
(package private) void |
ensureAuthorizationEnabled() |
(package private) void |
ensureOAuthEnabled() |
boolean |
equals(java.lang.Object o) |
(package private) User |
fillInIDAndScreenName() |
(package private) User |
fillInIDAndScreenName(HttpParameter[] parameters) |
Authorization |
getAuthorization()
Returns the authorization scheme for this instance.
The returned type will be either of BasicAuthorization, OAuthAuthorization, or NullAuthorization |
Configuration |
getConfiguration()
Returns the configuration associated with this instance
|
long |
getId()
Returns authenticating user's user id.
This method may internally call verifyCredentials() on the first invocation if - this instance is authenticated by Basic and email address is supplied instead of screen name, or - this instance is authenticated by OAuth. |
private OAuthSupport |
getOAuth() |
private OAuth2Support |
getOAuth2() |
OAuth2Token |
getOAuth2Token()
Obtains an OAuth 2 Bearer token.
|
AccessToken |
getOAuthAccessToken()
Returns an access token associated with this instance.
If no access token is associated with this instance, this will retrieve a new access token. |
AccessToken |
getOAuthAccessToken(RequestToken requestToken)
Retrieves an access token associated with the supplied request token and sets userId.
|
AccessToken |
getOAuthAccessToken(RequestToken requestToken,
java.lang.String oauthVerifier)
Retrieves an access token associated with the supplied request token and sets userId.
|
AccessToken |
getOAuthAccessToken(java.lang.String oauthVerifier)
Retrieves an access token.
|
AccessToken |
getOAuthAccessToken(java.lang.String screenName,
java.lang.String password)
Retrieves an access token associated with the supplied screen name and password using xAuth.
In order to get access acquire AccessToken using xAuth, you must apply by sending an email to api@twitter.com — all other applications will receive an HTTP 401 error. |
RequestToken |
getOAuthRequestToken()
Retrieves a request token
|
RequestToken |
getOAuthRequestToken(java.lang.String callbackUrl)
Retrieves a request token
|
RequestToken |
getOAuthRequestToken(java.lang.String callbackUrl,
java.lang.String xAuthAccessType)
Retrieves a request token
|
RequestToken |
getOAuthRequestToken(java.lang.String callbackUrl,
java.lang.String xAuthAccessType,
java.lang.String xAuthMode)
Retrieves a request token
|
java.lang.String |
getScreenName()
Returns authenticating user's screen name.
This method may internally call verifyCredentials() on the first invocation if - this instance is authenticated by Basic and email address is supplied instead of screen name, or - this instance is authenticated by OAuth. Note that this method returns a transiently cached (will be lost upon serialization) screen name while it is possible to change a user's screen name. |
int |
hashCode() |
void |
httpResponseReceived(HttpResponseEvent event) |
private void |
init() |
void |
invalidateOAuth2Token()
Revokes an issued OAuth 2 Bearer Token.
|
void |
onRateLimitReached(Consumer<RateLimitStatusEvent> action)
Registers a RateLimitStatusListener for account associated rate limits
|
void |
onRateLimitStatus(Consumer<RateLimitStatusEvent> action)
Registers a lambda action for account associated rate limits
|
private void |
readObject(java.io.ObjectInputStream stream) |
(package private) void |
setFactory() |
void |
setOAuth2Token(OAuth2Token oauth2Token)
Sets the OAuth 2 Bearer token.
|
void |
setOAuthAccessToken(AccessToken accessToken)
Sets the access token
|
void |
setOAuthConsumer(java.lang.String consumerKey,
java.lang.String consumerSecret)
sets the OAuth consumer key and consumer secret
|
java.lang.String |
toString() |
private void |
writeObject(java.io.ObjectOutputStream out) |
private static final java.lang.String WWW_DETAILS
private static final long serialVersionUID
Configuration conf
private transient java.lang.String screenName
private transient long id
transient HttpClient http
private java.util.List<RateLimitStatusListener> rateLimitStatusListeners
ObjectFactory factory
Authorization auth
TwitterBaseImpl(Configuration conf, Authorization auth)
private void init()
void setFactory()
public java.lang.String getScreenName() throws TwitterException, java.lang.IllegalStateException
TwitterBase
getScreenName
in interface TwitterBase
TwitterException
- when verifyCredentials threw an exception.java.lang.IllegalStateException
- if no credentials are supplied. i.e.) this is an anonymous Twitter instancepublic long getId() throws TwitterException, java.lang.IllegalStateException
TwitterBase
getId
in interface TwitterBase
TwitterException
- when verifyCredentials threw an exception.java.lang.IllegalStateException
- if no credentials are supplied. i.e.) this is an anonymous Twitter instanceUser fillInIDAndScreenName() throws TwitterException
TwitterException
User fillInIDAndScreenName(HttpParameter[] parameters) throws TwitterException
TwitterException
public void addRateLimitStatusListener(RateLimitStatusListener listener)
TwitterBase
addRateLimitStatusListener
in interface TwitterBase
listener
- the listener to be addedpublic void onRateLimitStatus(Consumer<RateLimitStatusEvent> action)
TwitterBase
onRateLimitStatus
in interface TwitterBase
action
- the action to be addedpublic void onRateLimitReached(Consumer<RateLimitStatusEvent> action)
TwitterBase
onRateLimitReached
in interface TwitterBase
action
- the action to be addedpublic void httpResponseReceived(HttpResponseEvent event)
public final Authorization getAuthorization()
TwitterBase
getAuthorization
in interface TwitterBase
public Configuration getConfiguration()
TwitterBase
getConfiguration
in interface TwitterBase
final void ensureAuthorizationEnabled()
final void ensureOAuthEnabled()
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException
java.io.IOException
private void readObject(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundException
public void setOAuthConsumer(java.lang.String consumerKey, java.lang.String consumerSecret)
OAuthSupport
setOAuthConsumer
in interface OAuth2Support
setOAuthConsumer
in interface OAuthSupport
consumerKey
- OAuth consumer keyconsumerSecret
- OAuth consumer secretpublic RequestToken getOAuthRequestToken() throws TwitterException
OAuthSupport
getOAuthRequestToken
in interface OAuthSupport
TwitterException
- when Twitter service or network is unavailablepublic RequestToken getOAuthRequestToken(java.lang.String callbackUrl) throws TwitterException
OAuthSupport
getOAuthRequestToken
in interface OAuthSupport
callbackUrl
- callback URLTwitterException
- when Twitter service or network is unavailablepublic RequestToken getOAuthRequestToken(java.lang.String callbackUrl, java.lang.String xAuthAccessType) throws TwitterException
OAuthSupport
getOAuthRequestToken
in interface OAuthSupport
callbackUrl
- callback URLxAuthAccessType
- Overrides the access level an application requests to a users account. Supported values are read or write. This parameter is intended to allow a developer to register a read/write application but also request read only access when appropriate.TwitterException
- when Twitter service or network is unavailablepublic RequestToken getOAuthRequestToken(java.lang.String callbackUrl, java.lang.String xAuthAccessType, java.lang.String xAuthMode) throws TwitterException
OAuthSupport
getOAuthRequestToken
in interface OAuthSupport
callbackUrl
- callback URLxAuthAccessType
- Overrides the access level an application requests to a users account. Supported values are read or write. This parameter is intended to allow a developer to register a read/write application but also request read only access when appropriate.xAuthMode
- Set to reverse_auth to obtain a special request token to be used in the reverse auth process.TwitterException
- when Twitter service or network is unavailablepublic AccessToken getOAuthAccessToken() throws TwitterException
getOAuthAccessToken
in interface OAuthSupport
TwitterException
- When Twitter service or network is unavailable, when the user has not authorized, or when the client application is not permitted to use xAuthpublic AccessToken getOAuthAccessToken(java.lang.String oauthVerifier) throws TwitterException
OAuthSupport
getOAuthAccessToken
in interface OAuthSupport
oauthVerifier
- OAuth verifier. AKA pin.TwitterException
- when Twitter service or network is unavailable, or the user has not authorizedpublic AccessToken getOAuthAccessToken(RequestToken requestToken) throws TwitterException
OAuthSupport
getOAuthAccessToken
in interface OAuthSupport
requestToken
- the request tokenTwitterException
- when Twitter service or network is unavailable, or the user has not authorizedpublic AccessToken getOAuthAccessToken(RequestToken requestToken, java.lang.String oauthVerifier) throws TwitterException
OAuthSupport
getOAuthAccessToken
in interface OAuthSupport
requestToken
- the request tokenoauthVerifier
- OAuth verifier. AKA pin.TwitterException
- when Twitter service or network is unavailable, or the user has not authorizedpublic void setOAuthAccessToken(AccessToken accessToken)
OAuthSupport
setOAuthAccessToken
in interface OAuthSupport
accessToken
- accessTokenpublic AccessToken getOAuthAccessToken(java.lang.String screenName, java.lang.String password) throws TwitterException
OAuthSupport
getOAuthAccessToken
in interface OAuthSupport
screenName
- the screen namepassword
- the passwordTwitterException
- when Twitter service or network is unavailable, or the user has not authorizedprivate OAuthSupport getOAuth()
public OAuth2Token getOAuth2Token() throws TwitterException
OAuth2Support
getOAuth2Token
in interface OAuth2Support
TwitterException
- when Twitter service or network is unavailable, or connecting non-SSL endpoints.public void setOAuth2Token(OAuth2Token oauth2Token)
OAuth2Support
setOAuth2Token
in interface OAuth2Support
oauth2Token
- OAuth 2 Bearer tokenpublic void invalidateOAuth2Token() throws TwitterException
OAuth2Support
invalidateOAuth2Token
in interface OAuth2Support
TwitterException
- when Twitter service or network is unavailable, or connecting non-SSL endpoints.private OAuth2Support getOAuth2()
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object