twitter4j

## Class Query

- java.lang.Object
- - twitter4j.Query

All Implemented Interfaces:
  Serializable

    public final class Query
    extends Object
    implements 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 | Twitter Developers, Twitter API / Search Operators, Serialized Form

### Nested Class Summary

Nested Classes
`static class` `Query.ResultType`
`static class` `Query.Unit`

### Field Summary

Fields
`static Query.Unit` `KILOMETERS`
`static Query.Unit` `MILES`
`static Query.ResultType` `MIXED` mixed: Include both popular and real time results in the response.
`static Query.ResultType` `POPULAR` popular: return only the most popular results in the response.
`static Query.ResultType` `RECENT` recent: return only the most recent results in the response

### Constructor Summary

Constructors
Constructor and Description
`Query()`
`Query(String query)`

### Method Summary

All Methods Instance Methods Concrete Methods Deprecated Methods
`Query` `count(int count)` sets the number of tweets to return per page, up to a max of 100
`boolean` `equals(Object o)`
`Query` `geoCode(GeoLocation location, double radius, Query.Unit 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
`Query` `geoCode(GeoLocation location, double radius, String unit)` Deprecated. use `geoCode(GeoLocation, double, twitter4j.Query.Unit)` instead
`int` `getCount()` Returns the number of tweets to return per page, up to a max of 100
`String` `getGeocode()` Returns the specified geocode
`String` `getLang()` Returns the 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.
`String` `getQuery()` Returns the specified query
`Query.ResultType` `getResultType()` Returns resultType
`String` `getSince()` Returns tweets with since the given date.
`long` `getSinceId()` returns sinceId
`String` `getUntil()` Returns until
`int` `hashCode()`
`Query` `lang(String lang)` restricts tweets to the given language, given by an ISO 639-1 code
`Query` `locale(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` `query(String query)` Sets the query string
`Query` `resultType(Query.ResultType resultType)` If specified, returns tweets included popular or real time or both in the response
`void` `setCount(int count)` sets the number of tweets to return per page, up to a max of 100
`void` `setGeoCode(GeoLocation location, double radius, Query.Unit 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` `setGeoCode(GeoLocation location, double radius, String unit)` Deprecated. use `setGeoCode(GeoLocation, double, twitter4j.Query.Unit)` instead
`void` `setLang(String lang)` restricts tweets to the given language, given by an ISO 639-1 code
`void` `setLocale(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` `setQuery(String query)` Sets the query string
`void` `setResultType(Query.ResultType resultType)` Default value is Query.MIXED if parameter not specified
`void` `setSince(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(String until)` If specified, returns tweets with generated before the given date.
`Query` `since(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.
`String` `toString()`
`Query` `until(String until)` If specified, returns tweets with generated before the given date.

### Methods inherited from class java.lang.Object

`getClass, notify, notifyAll, wait, wait, wait`

### Field Detail

#### MILES

    public static final Query.Unit MILES

#### KILOMETERS

    public static final Query.Unit KILOMETERS

#### MIXED

    public static final Query.ResultType MIXED

mixed: Include both popular and real time results in the response.

#### POPULAR

    public static final Query.ResultType POPULAR

popular: return only the most popular results in the response.

#### RECENT

    public static final Query.ResultType RECENT

recent: return only the most recent results in the response

### Constructor Detail

#### Query

    public Query()

#### Query

    public Query(String query)

### Method Detail

#### getQuery

    public String getQuery()

Returns the specified query

Returns:
  query

#### setQuery

    public void setQuery(String query)

Sets the query string

Parameters:
  `query` - the query string
See Also:
  GET search | Twitter Developers, Twitter API / Search Operators

#### query

    public Query query(String query)

Sets the query string

Parameters:
  `query` - the query string
Returns:
  the instance
Since:
  Twitter4J 2.1.0
See Also:
  GET search | Twitter Developers, Twitter API / Search Operators

#### getLang

    public String getLang()

Returns the lang

Returns:
  lang

#### setLang

    public void setLang(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(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 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(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(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

#### getCount

    public int getCount()

Returns the number of tweets to return per page, up to a max of 100

Returns:
  count

#### setCount

    public void setCount(int count)

sets the number of tweets to return per page, up to a max of 100

Parameters:
  `count` - the number of tweets to return per page

#### count

    public Query count(int count)

sets the number of tweets to return per page, up to a max of 100

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

#### getSince

    public 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(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(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 String getGeocode()

Returns the specified geocode

Returns:
  geocode

#### setGeoCode

    public void setGeoCode(GeoLocation location,
                           double radius,
                           Query.Unit 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
Since:
  Twitter4J 4.0.1

#### setGeoCode

    public void setGeoCode(GeoLocation location,
                           double radius,
                           String unit)

Deprecated. use `setGeoCode(GeoLocation, double, twitter4j.Query.Unit)` instead
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` - Use "mi" for miles or "km" for kilometers

#### geoCode

    public Query geoCode(GeoLocation location,
                         double radius,
                         Query.Unit 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 4.0.7

#### geoCode

    public Query geoCode(GeoLocation location,
                         double radius,
                         String unit)

Deprecated. use `geoCode(GeoLocation, double, twitter4j.Query.Unit)` instead
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` - Use "mi" for miles or "km" for kilometers
Returns:
  the instance
Since:
  Twitter4J 2.1.0

#### getUntil

    public String getUntil()

Returns until

Returns:
  until
Since:
  Twitter4J 2.1.1

#### setUntil

    public void setUntil(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(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 Query.ResultType getResultType()

Returns resultType

Returns:
  the resultType
Since:
  Twitter4J 2.1.3

#### setResultType

    public void setResultType(Query.ResultType 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(Query.ResultType resultType)

If specified, returns tweets included popular or real time or both in the response

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

#### equals

    public boolean equals(Object o)

Overrides:
  `equals` in class `Object`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`