twitter4j
Class Query

java.lang.Object
  extended by twitter4j.Query
All Implemented Interfaces:
java.io.Serializable

public final class Query
extends java.lang.Object
implements java.io.Serializable

A data class represents search query.
An instance of this class is NOT thread safe.
Instances can be shared across threads, but should not be mutated while a search is ongoing.

Author:
Yusuke Yamamoto - yusuke at mac.com
See Also:
GET search | dev.twitter.com, Twitter API / Search Operators, Serialized Form

Field Summary
private  java.lang.String geocode
           
static java.lang.String KILOMETERS
           
private  java.lang.String lang
           
private  java.lang.String locale
           
private  long maxId
           
static java.lang.String MILES
           
static java.lang.String MIXED
          mixed: Include both popular and real time results in the response.
private  int page
           
static java.lang.String POPULAR
           
private  java.lang.String query
           
static java.lang.String RECENT
           
private  java.lang.String resultType
           
private  int rpp
           
private static long serialVersionUID
           
private  java.lang.String since
           
private  long sinceId
           
private  java.lang.String until
           
 
Constructor Summary
Query()
           
Query(java.lang.String query)
           
 
Method Summary
private  void appendParameter(java.lang.String name, long value, java.util.List<twitter4j.internal.http.HttpParameter> params)
           
private  void appendParameter(java.lang.String name, java.lang.String value, java.util.List<twitter4j.internal.http.HttpParameter> params)
           
(package private)  twitter4j.internal.http.HttpParameter[] asHttpParameterArray()
           
 boolean equals(java.lang.Object o)
           
 Query geoCode(GeoLocation location, double radius, java.lang.String unit)
          returns tweets by users located within a given radius of the given latitude/longitude, where the user's location is taken from their Twitter profile
 java.lang.String getGeocode()
          Returns the specified geocode
 java.lang.String getLang()
          Returns the lang
 java.lang.String getLocale()
          Returns the language of the query you are sending (only ja is currently effective).
 long getMaxId()
          Returns tweets with status ids less than the given id.
 int getPage()
          Returns the page number (starting at 1) to return, up to a max of roughly 1500 results
 java.lang.String getQuery()
          Returns the specified query
 java.lang.String getResultType()
          Returns resultType
 int getRpp()
          Returns the number of tweets to return per page, up to a max of 100
 java.lang.String getSince()
          Returns tweets with since the given date.
 long getSinceId()
          returns sinceId
 java.lang.String getUntil()
          Returns until
 int hashCode()
           
 Query lang(java.lang.String lang)
          restricts tweets to the given language, given by an ISO 639-1 code
 Query locale(java.lang.String locale)
          Specify the language of the query you are sending (only ja is currently effective).
 Query maxId(long maxId)
          If specified, returns tweets with status ids less than the given id.
 Query page(int page)
          sets the page number (starting at 1) to return, up to a max of roughly 1500 results
 Query query(java.lang.String query)
          Sets the query string
 Query resultType(java.lang.String resultType)
          If specified, returns tweets included popular or real time or both in the responce
 Query rpp(int rpp)
          sets the number of tweets to return per page, up to a max of 100
 void setGeoCode(GeoLocation location, double radius, java.lang.String unit)
          returns tweets by users located within a given radius of the given latitude/longitude, where the user's location is taken from their Twitter profile
 void setLang(java.lang.String lang)
          restricts tweets to the given language, given by an ISO 639-1 code
 void setLocale(java.lang.String locale)
          Specify the language of the query you are sending (only ja is currently effective).
 void setMaxId(long maxId)
          If specified, returns tweets with status ids less than the given id.
 void setPage(int page)
          sets the page number (starting at 1) to return, up to a max of roughly 1500 results
 void setQuery(java.lang.String query)
          Sets the query string
 void setResultType(java.lang.String resultType)
          Default value is Query.MIXED if parameter not specified
 void setRpp(int rpp)
          sets the number of tweets to return per page, up to a max of 100
 void setSince(java.lang.String since)
          If specified, returns tweets with since the given date.
 void setSinceId(long sinceId)
          returns tweets with status ids greater than the given id.
 void setUntil(java.lang.String until)
          If specified, returns tweets with generated before the given date.
 Query since(java.lang.String since)
          If specified, returns tweets with since the given date.
 Query sinceId(long sinceId)
          returns tweets with status ids greater than the given id.
 java.lang.String toString()
           
 Query until(java.lang.String until)
          If specified, returns tweets with generated before the given date.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

query

private java.lang.String query

lang

private java.lang.String lang

locale

private java.lang.String locale

maxId

private long maxId

rpp

private int rpp

page

private int page

since

private java.lang.String since

sinceId

private long sinceId

geocode

private java.lang.String geocode

until

private java.lang.String until

resultType

private java.lang.String resultType

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

MILES

public static final java.lang.String MILES
See Also:
Constant Field Values

KILOMETERS

public static final java.lang.String KILOMETERS
See Also:
Constant Field Values

MIXED

public static final java.lang.String MIXED
mixed: Include both popular and real time results in the response. recent: return only the most recent results in the response popular: return only the most popular results in the response.

See Also:
Constant Field Values

POPULAR

public static final java.lang.String POPULAR
See Also:
Constant Field Values

RECENT

public static final java.lang.String RECENT
See Also:
Constant Field Values
Constructor Detail

Query

public Query()

Query

public Query(java.lang.String query)
Method Detail

getQuery

public java.lang.String getQuery()
Returns the specified query

Returns:
query

setQuery

public void setQuery(java.lang.String query)
Sets the query string

Parameters:
query - the query string
See Also:
GET search | dev.twitter.com, Twitter API / Search Operators

query

public Query query(java.lang.String query)
Sets the query string

Parameters:
query - the query string
Returns:
the instance
Since:
Twitter4J 2.1.0
See Also:
GET search | dev.twitter.com, Twitter API / Search Operators

getLang

public java.lang.String getLang()
Returns the lang

Returns:
lang

setLang

public void setLang(java.lang.String lang)
restricts tweets to the given language, given by an ISO 639-1 code

Parameters:
lang - an ISO 639-1 code

lang

public Query lang(java.lang.String lang)
restricts tweets to the given language, given by an ISO 639-1 code

Parameters:
lang - an ISO 639-1 code
Returns:
the instance
Since:
Twitter4J 2.1.0

getLocale

public java.lang.String getLocale()
Returns the language of the query you are sending (only ja is currently effective). This is intended for language-specific clients and the default should work in the majority of cases.

Returns:
locale
Since:
Twitter4J 2.1.1

setLocale

public void setLocale(java.lang.String locale)
Specify the language of the query you are sending (only ja is currently effective). This is intended for language-specific clients and the default should work in the majority of cases.

Parameters:
locale - the locale
Since:
Twitter4J 2.1.1

locale

public Query locale(java.lang.String locale)
Specify the language of the query you are sending (only ja is currently effective). This is intended for language-specific clients and the default should work in the majority of cases.

Parameters:
locale - the locale
Returns:
the instance
Since:
Twitter4J 2.1.1

getMaxId

public long getMaxId()
Returns tweets with status ids less than the given id.

Returns:
maxId
Since:
Twitter4J 2.1.1

setMaxId

public void setMaxId(long maxId)
If specified, returns tweets with status ids less than the given id.

Parameters:
maxId - maxId
Since:
Twitter4J 2.1.1

maxId

public Query maxId(long maxId)
If specified, returns tweets with status ids less than the given id.

Parameters:
maxId - maxId
Returns:
this instance
Since:
Twitter4J 2.1.1

getRpp

public int getRpp()
Returns the number of tweets to return per page, up to a max of 100

Returns:
rpp

setRpp

public void setRpp(int rpp)
sets the number of tweets to return per page, up to a max of 100

Parameters:
rpp - the number of tweets to return per page

rpp

public Query rpp(int rpp)
sets the number of tweets to return per page, up to a max of 100

Parameters:
rpp - the number of tweets to return per page
Returns:
the instance
Since:
Twitter4J 2.1.0

getPage

public int getPage()
Returns the page number (starting at 1) to return, up to a max of roughly 1500 results

Returns:
the page number (starting at 1) to return

setPage

public void setPage(int page)
sets the page number (starting at 1) to return, up to a max of roughly 1500 results

Parameters:
page - the page number (starting at 1) to return

page

public Query page(int page)
sets the page number (starting at 1) to return, up to a max of roughly 1500 results

Parameters:
page - the page number (starting at 1) to return
Returns:
the instance
Since:
Twitter4J 2.1.0

getSince

public java.lang.String getSince()
Returns tweets with since the given date. Date should be formatted as YYYY-MM-DD

Returns:
since
Since:
Twitter4J 2.1.1

setSince

public void setSince(java.lang.String since)
If specified, returns tweets with since the given date. Date should be formatted as YYYY-MM-DD

Parameters:
since - since
Since:
Twitter4J 2.1.1

since

public Query since(java.lang.String since)
If specified, returns tweets with since the given date. Date should be formatted as YYYY-MM-DD

Parameters:
since - since
Returns:
since
Since:
Twitter4J 2.1.1

getSinceId

public long getSinceId()
returns sinceId

Returns:
sinceId

setSinceId

public void setSinceId(long sinceId)
returns tweets with status ids greater than the given id.

Parameters:
sinceId - returns tweets with status ids greater than the given id

sinceId

public Query sinceId(long sinceId)
returns tweets with status ids greater than the given id.

Parameters:
sinceId - returns tweets with status ids greater than the given id
Returns:
the instance
Since:
Twitter4J 2.1.0

getGeocode

public java.lang.String getGeocode()
Returns the specified geocode

Returns:
geocode

setGeoCode

public void setGeoCode(GeoLocation location,
                       double radius,
                       java.lang.String unit)
returns tweets by users located within a given radius of the given latitude/longitude, where the user's location is taken from their Twitter profile

Parameters:
location - geo location
radius - radius
unit - Query.MILES or Query.KILOMETERS

geoCode

public Query geoCode(GeoLocation location,
                     double radius,
                     java.lang.String unit)
returns tweets by users located within a given radius of the given latitude/longitude, where the user's location is taken from their Twitter profile

Parameters:
location - geo location
radius - radius
unit - Query.MILES or Query.KILOMETERS
Returns:
the instance
Since:
Twitter4J 2.1.0

getUntil

public java.lang.String getUntil()
Returns until

Returns:
until
Since:
Twitter4J 2.1.1

setUntil

public void setUntil(java.lang.String until)
If specified, returns tweets with generated before the given date. Date should be formatted as YYYY-MM-DD

Parameters:
until - until
Since:
Twitter4J 2.1.1

until

public Query until(java.lang.String until)
If specified, returns tweets with generated before the given date. Date should be formatted as YYYY-MM-DD

Parameters:
until - until
Returns:
the instance
Since:
Twitter4J 2.1.1

getResultType

public java.lang.String getResultType()
Returns resultType

Returns:
the resultType
Since:
Twitter4J 2.1.3

setResultType

public void setResultType(java.lang.String resultType)
Default value is Query.MIXED if parameter not specified

Parameters:
resultType - Query.MIXED or Query.POPULAR or Query.RECENT
Since:
Twitter4J 2.1.3

resultType

public Query resultType(java.lang.String resultType)
If specified, returns tweets included popular or real time or both in the responce

Parameters:
resultType - resultType
Returns:
the instance
Since:
Twitter4J 2.1.3

asHttpParameterArray

twitter4j.internal.http.HttpParameter[] asHttpParameterArray()

appendParameter

private void appendParameter(java.lang.String name,
                             java.lang.String value,
                             java.util.List<twitter4j.internal.http.HttpParameter> params)

appendParameter

private void appendParameter(java.lang.String name,
                             long value,
                             java.util.List<twitter4j.internal.http.HttpParameter> params)

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