twitter4j
Class RateLimitStatusJSONImpl

java.lang.Object
  extended by twitter4j.RateLimitStatusJSONImpl
All Implemented Interfaces:
java.io.Serializable, RateLimitStatus

final class RateLimitStatusJSONImpl
extends java.lang.Object
implements RateLimitStatus, java.io.Serializable

A data class representing Twitter REST API's rate limit status

Author:
Yusuke Yamamoto - yusuke at mac.com
See Also:
Rate Limiting | dev.twitter.com

Field Summary
private  int hourlyLimit
           
private  int remainingHits
           
private  java.util.Date resetTime
           
private  int resetTimeInSeconds
           
private  int secondsUntilReset
           
private static long serialVersionUID
           
 
Constructor Summary
(package private) RateLimitStatusJSONImpl(twitter4j.internal.http.HttpResponse res)
           
private RateLimitStatusJSONImpl(int hourlyLimit, int remainingHits, int resetTimeInSeconds, java.util.Date resetTime)
           
(package private) RateLimitStatusJSONImpl(twitter4j.internal.org.json.JSONObject json)
           
 
Method Summary
(package private) static RateLimitStatus createFeatureSpecificRateLimitStatusFromResponseHeader(twitter4j.internal.http.HttpResponse res)
           
(package private) static RateLimitStatus createFromResponseHeader(twitter4j.internal.http.HttpResponse res)
           
 boolean equals(java.lang.Object o)
           
 int getHourlyLimit()
          Returns the current limit in effect
This value is identical to the "X-RateLimit-Limit" response header.
 int getRemainingHits()
          Returns the remaining number of API requests available.
This value is identical to the "X-RateLimit-Remaining" response header.
 java.util.Date getResetTime()
          Returns the time the current rate limiting period ends.
This value is a java.util.Date-typed variation of the "X-RateLimit-Reset" response header.
 int getResetTimeInSeconds()
          Returns the seconds the current rate limiting period ends.
This should be a same as getResetTime().getTime()/1000.
 int getSecondsUntilReset()
          Returns the amount of seconds until the current rate limiting period ends.
This is a value provided/calculated only by Twitter4J for handiness and not a part of the twitter API spec.
 int hashCode()
           
(package private)  void init(twitter4j.internal.org.json.JSONObject json)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

remainingHits

private int remainingHits

hourlyLimit

private int hourlyLimit

resetTimeInSeconds

private int resetTimeInSeconds

secondsUntilReset

private int secondsUntilReset

resetTime

private java.util.Date resetTime

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

RateLimitStatusJSONImpl

private RateLimitStatusJSONImpl(int hourlyLimit,
                                int remainingHits,
                                int resetTimeInSeconds,
                                java.util.Date resetTime)

RateLimitStatusJSONImpl

RateLimitStatusJSONImpl(twitter4j.internal.http.HttpResponse res)
                  throws TwitterException
Throws:
TwitterException

RateLimitStatusJSONImpl

RateLimitStatusJSONImpl(twitter4j.internal.org.json.JSONObject json)
                  throws TwitterException
Throws:
TwitterException
Method Detail

init

void init(twitter4j.internal.org.json.JSONObject json)
    throws TwitterException
Throws:
TwitterException

createFromResponseHeader

static RateLimitStatus createFromResponseHeader(twitter4j.internal.http.HttpResponse res)

createFeatureSpecificRateLimitStatusFromResponseHeader

static RateLimitStatus createFeatureSpecificRateLimitStatusFromResponseHeader(twitter4j.internal.http.HttpResponse res)

getRemainingHits

public int getRemainingHits()
Returns the remaining number of API requests available.
This value is identical to the "X-RateLimit-Remaining" response header.

Specified by:
getRemainingHits in interface RateLimitStatus
Returns:
the remaining number of API requests available

getHourlyLimit

public int getHourlyLimit()
Returns the current limit in effect
This value is identical to the "X-RateLimit-Limit" response header.

Specified by:
getHourlyLimit in interface RateLimitStatus
Returns:
the current limit in effect

getResetTimeInSeconds

public int getResetTimeInSeconds()
Returns the seconds the current rate limiting period ends.
This should be a same as getResetTime().getTime()/1000.

Specified by:
getResetTimeInSeconds in interface RateLimitStatus
Returns:
the seconds the current rate limiting period ends

getSecondsUntilReset

public int getSecondsUntilReset()
Returns the amount of seconds until the current rate limiting period ends.
This is a value provided/calculated only by Twitter4J for handiness and not a part of the twitter API spec.

Specified by:
getSecondsUntilReset in interface RateLimitStatus
Returns:
the amount of seconds until next rate limiting period

getResetTime

public java.util.Date getResetTime()
Returns the time the current rate limiting period ends.
This value is a java.util.Date-typed variation of the "X-RateLimit-Reset" response header.

Specified by:
getResetTime in interface RateLimitStatus
Returns:
the time the current rate limiting period ends

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

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

toString

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