Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.twitterapime.search
Class SearchDevice

    java.lang.Object
      com.twitterapime.search.SearchDevice

    public final class SearchDevice

extends java.lang.Object

This class is the entry point of Search API, which defines the methods responsible for submitting a query to Twitter Search API.

     SearchDevice sd = SearchDevice.getInstance();
     Query q1 = QueryComposer.from("twitteruser");
     Query q2 = QueryComposer.containAny("search api");
     Query q = QueryComposer.append(q1, q2);
     Tweet[] ts = sd.searchTweets(q);
     for (int i = 0; i < ts.length; i++) {
       list.append(ts[i].getString(MetadataSet.TWEET_CONTENT), null);
     }

Since:
  1.0
Version:
  1.3
Author:
  Ernandes Mourao Junior (ernandes@gmail.com)
See Also:
  `SearchDeviceListener`, `QueryComposer`

Field Summary
`static java.lang.String` | `TWITTER_API_URL_SERVICE_ACCOUNT_RATE_LIMIT_STATUS` Key for Twitter API URL service account rate limit status.
`static java.lang.String` | `TWITTER_API_URL_SERVICE_SEARCH` Key for Twitter API URL service search.

Method Summary
`int` | `getAPICallsCount()` Get the calls count submitted to Twitter Search API since the API was loaded by class loader.
`static SearchDevice` | `getInstance()` Get an instance of SearchDevice class.
`long` | `getLastAPICallTime()` Get the time at which the last call was submitted to Twitter Search API.
`RateLimitStatus` | `getRateLimitStatus()` Return a set of info about the number of API requests available to the requesting IP address before the REST API limit is reached for the current hour.
`Tweet[]` | `searchTweets(Query query)` Search for tweets that match the given query.
`Tweet[]` | `searchTweets(java.lang.String queryString)` Search for tweets that match the given query string.
`void` | `setServiceURL(java.lang.String serviceKey, java.lang.String url)` Set a new URL to a given Twitter API service.
`void` | `startSearchTweets(Query query, SearchDeviceListener listener)` Search for tweets that match the given query.
`void` | `startSearchTweets(java.lang.String queryString, SearchDeviceListener listener)` Search for tweets that match the given query string.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### TWITTER_API_URL_SERVICE_SEARCH

    public static final java.lang.String TWITTER_API_URL_SERVICE_SEARCH

  Key for Twitter API URL service search.

  See Also:
    `setServiceURL(String, String)`, `searchTweets(Query)`, `searchTweets(String)`, `startSearchTweets(Query, SearchDeviceListener)`, `startSearchTweets(String, SearchDeviceListener)`, Constant Field Values

### TWITTER_API_URL_SERVICE_ACCOUNT_RATE_LIMIT_STATUS

    public static final java.lang.String TWITTER_API_URL_SERVICE_ACCOUNT_RATE_LIMIT_STATUS

  Key for Twitter API URL service account rate limit status.

  See Also:
    `setServiceURL(String, String)`, `getRateLimitStatus()`, Constant Field Values

Method Detail

### setServiceURL

    public void setServiceURL(java.lang.String serviceKey,
                              java.lang.String url)

  Set a new URL to a given Twitter API service. This method is very useful in case Twitter API decides to change a service's URL. So there is no need to wait for a new version of this API to get it working back.

  Be careful about using this method, since it can cause unexpected results, case you enter an invalid URL.

  Parameters:
    `serviceKey` - Service key.
    `url` - New URL.
  See Also:
    `TWITTER_API_URL_SERVICE_SEARCH`, `TWITTER_API_URL_SERVICE_ACCOUNT_RATE_LIMIT_STATUS`

### getInstance

    public static SearchDevice getInstance()

  Get an instance of SearchDevice class.

  Returns:
    A SearchDevice object.

### searchTweets

    public Tweet[] searchTweets(Query query)
                         throws java.io.IOException,
                                LimitExceededException

  Search for tweets that match the given query. This method gets blocked until the search is completed or an exception is thrown.

  Parameters:
    `query` - The query.
  Returns:
    The result.
  Throws:
    `java.io.IOException` - If an I/O error occurs.
    `LimitExceededException` - If the limit of access is exceeded.
    `java.lang.IllegalArgumentException` - If query is null.

### searchTweets

    public Tweet[] searchTweets(java.lang.String queryString)
                         throws java.io.IOException,
                                LimitExceededException

  Search for tweets that match the given query string. This method gets blocked until the search is completed or an exception is thrown.

  Parameters:
    `queryString` - The query string.
  Returns:
    The result.
  Throws:
    `java.io.IOException` - If an I/O error occurs.
    `LimitExceededException` - If the limit of access is exceeded.
    `java.lang.IllegalArgumentException` - If queryString is null/empty.

### startSearchTweets

    public void startSearchTweets(Query query,
                                  SearchDeviceListener listener)

  Search for tweets that match the given query. This method does not wait for the search process is completed to return. To have access to this search's result, a SearchDeviceListener object must be registered.

  Parameters:
    `query` - The query.
    `listener` - Listener object to be notified about the search's result.
  Throws:
    `java.lang.IllegalArgumentException` - If query is null.

### startSearchTweets

    public void startSearchTweets(java.lang.String queryString,
                                  SearchDeviceListener listener)

  Search for tweets that match the given query string. This method does not wait for the search process is completed to return. To have access to this search's result, a SearchDeviceListener object must be registered.

  Parameters:
    `queryString` - The query string.
    `listener` - Listener object to be notified about the search's result.
  Throws:
    `java.lang.IllegalArgumentException` - If queryString is null/empty.

### getRateLimitStatus

    public RateLimitStatus getRateLimitStatus()
                                       throws java.io.IOException,
                                              LimitExceededException

  Return a set of info about the number of API requests available to the requesting IP address before the REST API limit is reached for the current hour.

  Stay aware of these limits, since it can impact the usage of some methods of this API.

  Returns:
    Rate limiting status info.
  Throws:
    `java.io.IOException` - If an I/O error occurs.
    `LimitExceededException` - If limit has been hit.
  See Also:
    `getAPICallsCount()`

### getAPICallsCount

    public int getAPICallsCount()

  Get the calls count submitted to Twitter Search API since the API was loaded by class loader. So this number is reseted when the API is unloaded.

  Returns:
    Call count.
  See Also:
    `getRateLimitStatus()`

### getLastAPICallTime

    public long getLastAPICallTime()

  Get the time at which the last call was submitted to Twitter Search API.

  Returns:
    Time of last call.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2010 Twitter API ME Team. All Rights Reserved.