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.rest
Class FriendshipManager

    java.lang.Object
      com.twitterapime.rest.FriendshipManager

    public final class FriendshipManager

extends java.lang.Object

This class defines the methods responsible for managing friendship (friends and followers).

     Credential c = new Credential(...);
     UserAccountManager uam = UserAccountManager.getInstance(c);

     if (uam.verifyCredential()) {
       FriendshipManager fdr = FriendshipManager.getInstance(uam);
       String[] ids = fdr.getFriendsID(null);
     }

     ...

     FriendshipManager fdr = FriendshipManager.getInstance();
     String[] ids = fdr.getFriendsID(new UserAccount("twapime"), null);

Since:
  1.4
Version:
  1.0
Author:
  Ernandes Mourao Junior (ernandes@gmail.com)

Field Summary
`static java.lang.String` | `TWITTER_API_URL_SERVICE_BLOCKS_CREATE` Key for Twitter API URL service blocks create.
`static java.lang.String` | `TWITTER_API_URL_SERVICE_BLOCKS_DESTROY` Key for Twitter API URL service blocks destroy.
`static java.lang.String` | `TWITTER_API_URL_SERVICE_BLOCKS_EXISTS` Key for Twitter API URL service friendships exists.
`static java.lang.String` | `TWITTER_API_URL_SERVICE_FOLLOWERS_ID` Key for Twitter API URL service followers id.
`static java.lang.String` | `TWITTER_API_URL_SERVICE_FRIENDS_ID` Key for Twitter API URL service friends id.
`static java.lang.String` | `TWITTER_API_URL_SERVICE_FRIENDSHIPS_CREATE` Key for Twitter API URL service friendships create.
`static java.lang.String` | `TWITTER_API_URL_SERVICE_FRIENDSHIPS_DESTROY` Key for Twitter API URL service friendships destroy.
`static java.lang.String` | `TWITTER_API_URL_SERVICE_FRIENDSHIPS_EXISTS` Key for Twitter API URL service friendships exists.

Method Summary
`UserAccount` | `block(UserAccount ua)` Allows the authenticating user to block the user specified in the given UserAccount object.
`UserAccount` | `follow(UserAccount ua)` Allows the authenticating user to follow the user specified in the given UserAccount object.
`java.lang.String[]` | `getFollowersID(Query query)` Get the followers ID list of verified user.
`java.lang.String[]` | `getFollowersID(UserAccount user, Query query)` Get the followers ID list of a given user.
`java.lang.String[]` | `getFriendsID(Query query)` Get the friends ID list of verified user.
`java.lang.String[]` | `getFriendsID(UserAccount user, Query query)` Get the friends ID list of a given user.
`static FriendshipManager` | `getInstance()` Get a single instance of FriendshipManager class, which is NOT associated to any user account.
`static FriendshipManager` | `getInstance(UserAccountManager uam)` Get an instance of FriendshipManager class and associate it to a given user account.
`boolean` | `isBlocking(UserAccount ua)` Verify whether the authenticating user is blocking the user specified in the given UserAccount object.
`boolean` | `isFollowing(UserAccount ua)` Verify whether the authenticating user is following the user specified in the given UserAccount object.
`void` | `setServiceURL(java.lang.String serviceKey, java.lang.String url)` Set a new URL to a given Twitter API service.
`UserAccount` | `unblock(UserAccount ua)` Allows the authenticating user to unblock the user specified in the given UserAccount object.
`UserAccount` | `unfollow(UserAccount ua)` Allows the authenticating user to unfollow the user specified in the given UserAccount object.

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

Field Detail

### TWITTER_API_URL_SERVICE_FRIENDS_ID

    public static final java.lang.String TWITTER_API_URL_SERVICE_FRIENDS_ID

  Key for Twitter API URL service friends id.

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

### TWITTER_API_URL_SERVICE_FOLLOWERS_ID

    public static final java.lang.String TWITTER_API_URL_SERVICE_FOLLOWERS_ID

  Key for Twitter API URL service followers id.

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

### TWITTER_API_URL_SERVICE_FRIENDSHIPS_CREATE

    public static final java.lang.String TWITTER_API_URL_SERVICE_FRIENDSHIPS_CREATE

  Key for Twitter API URL service friendships create.

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

### TWITTER_API_URL_SERVICE_FRIENDSHIPS_DESTROY

    public static final java.lang.String TWITTER_API_URL_SERVICE_FRIENDSHIPS_DESTROY

  Key for Twitter API URL service friendships destroy.

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

### TWITTER_API_URL_SERVICE_FRIENDSHIPS_EXISTS

    public static final java.lang.String TWITTER_API_URL_SERVICE_FRIENDSHIPS_EXISTS

  Key for Twitter API URL service friendships exists.

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

### TWITTER_API_URL_SERVICE_BLOCKS_CREATE

    public static final java.lang.String TWITTER_API_URL_SERVICE_BLOCKS_CREATE

  Key for Twitter API URL service blocks create.

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

### TWITTER_API_URL_SERVICE_BLOCKS_DESTROY

    public static final java.lang.String TWITTER_API_URL_SERVICE_BLOCKS_DESTROY

  Key for Twitter API URL service blocks destroy.

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

### TWITTER_API_URL_SERVICE_BLOCKS_EXISTS

    public static final java.lang.String TWITTER_API_URL_SERVICE_BLOCKS_EXISTS

  Key for Twitter API URL service friendships exists.

  See Also:
    `setServiceURL(String, String)`, `isBlocking(UserAccount)`, 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_FRIENDS_ID`, `TWITTER_API_URL_SERVICE_FOLLOWERS_ID`, `TWITTER_API_URL_SERVICE_BLOCKS_CREATE`, `TWITTER_API_URL_SERVICE_BLOCKS_DESTROY`, `TWITTER_API_URL_SERVICE_BLOCKS_EXISTS`, `TWITTER_API_URL_SERVICE_FRIENDSHIPS_CREATE`, `TWITTER_API_URL_SERVICE_FRIENDSHIPS_DESTROY`, `TWITTER_API_URL_SERVICE_FRIENDSHIPS_EXISTS`

### getInstance

    public static FriendshipManager getInstance(UserAccountManager uam)

  Get an instance of FriendshipManager class and associate it to a given user account.

  Parameters:
    `uam` - User account manager.
  Returns:
    FriendshipManager instance.
  Throws:
    `java.lang.IllegalArgumentException` - If UserAccountManager is null.
    `java.lang.SecurityException` - If UserAccountManager is not verified.

### getInstance

    public static FriendshipManager getInstance()

  Get a single instance of FriendshipManager class, which is NOT associated to any user account.

  Returns:
    FriendshipManager single instance.

### getFriendsID

    public java.lang.String[] getFriendsID(Query query)
                                    throws java.io.IOException,
                                           LimitExceededException

  Get the friends ID list of verified user.

  As the number of friends of a given user can be very large, you have to specify a max count. Passing `null` will return all of them. But be aware it may take a little awhile and consume a lot of memory.

  Parameters:
    `query` - Max count of IDs to be returned. Use `QueryComposer.count(int)` only.
  Returns:
    Friends id.
  Throws:
    `java.io.IOException` - If an I/O error occurs.
    `LimitExceededException` - If the limit of access is exceeded.
    `java.lang.SecurityException` - If user account manager is not informed.
  See Also:
    `UserAccountManager.getUserAccount(UserAccount)`

### getFriendsID

    public java.lang.String[] getFriendsID(UserAccount user,
                                           Query query)
                                    throws java.io.IOException,
                                           LimitExceededException

  Get the friends ID list of a given user.

  As the number of friends of a given user can be very large, you have to specify a max count. Passing `null` will return all of them. But be aware it may take a little awhile and consume a lot of memory.

  Parameters:
    `user` - User.
    `query` - Max count of IDs to be returned. Use `QueryComposer.count(int)` only.
  Returns:
    Friends id.
  Throws:
    `java.io.IOException` - If an I/O error occurs.
    `LimitExceededException` - If the limit of access is exceeded.
    `java.lang.IllegalArgumentException` - If user is not informed.
    `java.lang.SecurityException` - Given user is protected.
  See Also:
    `UserAccountManager.getUserAccount(UserAccount)`

### getFollowersID

    public java.lang.String[] getFollowersID(Query query)
                                      throws java.io.IOException,
                                             LimitExceededException

  Get the followers ID list of verified user.

  As the number of followers of a given user can be very large, you have to specify a max count. Passing `null` will return all of them. But be aware it may take a little awhile and consume a lot of memory.

  Parameters:
    `query` - Max count of IDs to be returned. Use `QueryComposer.count(int)` only.
  Returns:
    Friends id.
  Throws:
    `java.io.IOException` - If an I/O error occurs.
    `LimitExceededException` - If the limit of access is exceeded.
    `java.lang.SecurityException` - If user account manager is not informed.
  See Also:
    `UserAccountManager.getUserAccount(UserAccount)`

### getFollowersID

    public java.lang.String[] getFollowersID(UserAccount user,
                                             Query query)
                                      throws java.io.IOException,
                                             LimitExceededException

  Get the followers ID list of a given user.

  As the number of followers of a given user can be very large, you have to specify a max count. Passing `null` will return all of them. But be aware it may take a little awhile and consume a lot of memory.

  Parameters:
    `user` - User.
    `query` - Max count of IDs to be returned. Use `QueryComposer.count(int)` only.
  Returns:
    Friends id.
  Throws:
    `java.io.IOException` - If an I/O error occurs.
    `LimitExceededException` - If the limit of access is exceeded.
    `java.lang.IllegalArgumentException` - If user is not informed.
    `java.lang.SecurityException` - Given user is protected.
  See Also:
    `UserAccountManager.getUserAccount(UserAccount)`

### follow

    public UserAccount follow(UserAccount ua)
                       throws java.io.IOException,
                              LimitExceededException

  Allows the authenticating user to follow the user specified in the given UserAccount object.

  Parameters:
    `ua` - UserAccount object containing the user name or ID.
  Returns:
    Info from followed user.
  Throws:
    `java.io.IOException` - If an I/O error occurs.
    `InvalidQueryException` - User already followed or does not exist.
    `java.lang.SecurityException` - If it is not authenticated.
    `LimitExceededException` - If limit has been hit.

### unfollow

    public UserAccount unfollow(UserAccount ua)
                         throws java.io.IOException,
                                LimitExceededException

  Allows the authenticating user to unfollow the user specified in the given UserAccount object.

  Parameters:
    `ua` - UserAccount object containing the user name or ID.
  Returns:
    Info from unfollowed user.
  Throws:
    `java.io.IOException` - If an I/O error occurs.
    `InvalidQueryException` - User already unfollowed or does not exist.
    `java.lang.SecurityException` - If it is not authenticated.
    `LimitExceededException` - If limit has been hit.

### isFollowing

    public boolean isFollowing(UserAccount ua)
                        throws java.io.IOException,
                               LimitExceededException

  Verify whether the authenticating user is following the user specified in the given UserAccount object.

  Parameters:
    `ua` - UserAccount object containing the user name or ID.
  Returns:
    Following (true).
  Throws:
    `java.io.IOException` - If an I/O error occurs.
    `LimitExceededException` - If limit has been hit.
    `InvalidQueryException` - If user does not exist or is protected.
    `java.lang.SecurityException` - If it is not authenticated.

### block

    public UserAccount block(UserAccount ua)
                      throws java.io.IOException,
                             LimitExceededException

  Allows the authenticating user to block the user specified in the given UserAccount object.

  Parameters:
    `ua` - UserAccount object containing the user name or ID.
  Returns:
    Info from blocked user.
  Throws:
    `java.io.IOException` - If an I/O error occurs.
    `InvalidQueryException` - User does not exist.
    `java.lang.SecurityException` - If it is not authenticated.
    `LimitExceededException` - If limit has been hit.

### unblock

    public UserAccount unblock(UserAccount ua)
                        throws java.io.IOException,
                               LimitExceededException

  Allows the authenticating user to unblock the user specified in the given UserAccount object.

  Parameters:
    `ua` - UserAccount object containing the user name or ID.
  Returns:
    Info from unblocked user.
  Throws:
    `java.io.IOException` - If an I/O error occurs.
    `InvalidQueryException` - User does not exist.
    `java.lang.SecurityException` - If it is not authenticated.
    `LimitExceededException` - If limit has been hit.

### isBlocking

    public boolean isBlocking(UserAccount ua)
                       throws java.io.IOException,
                              LimitExceededException

  Verify whether the authenticating user is blocking the user specified in the given UserAccount object.

  Parameters:
    `ua` - UserAccount object containing the user name or ID.
  Returns:
    Blocking (true).
  Throws:
    `java.io.IOException` - If an I/O error occurs.
    `LimitExceededException` - If limit has been hit.
    `InvalidQueryException` - If user does not exist or is protected.
    `java.lang.SecurityException` - If it is not authenticated.

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.