Example usage for java.util Locale toString

List of usage examples for java.util Locale toString

Introduction

In this page you can find the example usage for java.util Locale toString.

Prototype

@Override
public final String toString() 

Source Link

Document

Returns a string representation of this Locale object, consisting of language, country, variant, script, and extensions as below:
language + "_" + country + "_" + (variant + "_#" | "#") + script + "_" + extensions
Language is always lower case, country is always upper case, script is always title case, and extensions are always lower case.

Usage

From source file:illab.nabal.proxy.FacebookProxy.java

/**
 * Get albums owned by given owner identifier.
 * //from w w  w  . java2  s .c om
 * @param ownerIdentifier
 * @param limit
 * @param after
 * @param before
 * @param locale
 * @return list of FacebookAlbum objects
 * @throws Exception
 */
private List<FacebookAlbum> getAlbums(String ownerIdentifier, int limit, String after, String before,
        Locale locale) throws Exception {

    // throw an exception if owner identifier is invalid
    if (StringHelper.isEmpty(ownerIdentifier) == true) {
        throw new SystemException("Invalid owner identifier.");
    }

    String apiUri = "/" + ownerIdentifier + "/albums";

    // set system locale if none given
    Locale localeParam = locale;
    if (localeParam == null)
        localeParam = Util.getSystemLocale();

    List<NameValuePair> params = ParameterHelper.addAllParams(
            new BasicNameValuePair("access_token", mFacebookContext.getAccessToken()),
            new BasicNameValuePair("locale", localeParam.toString()));

    // set page parameters
    setPageCursorParams(params, limit, after, before);

    return populateAlbumList(localeParam, getResponseJson(getHttpGet(apiUri, params)));
}

From source file:illab.nabal.proxy.FacebookProxy.java

/**
 * Get notes owned by given user identifier.
 * //from  ww w.  j a  va  2 s . c  o m
 * @param userIdentifier
 * @param limit
 * @param after
 * @param before
 * @param locale
 * @return list of FacebookNote objects
 * @throws Exception
 */
private List<FacebookNote> getNotes(String userIdentifier, int limit, String after, String before,
        Locale locale) throws Exception {

    // throw an exception if user identifier is invalid
    if (StringHelper.isEmpty(userIdentifier) == true) {
        throw new SystemException("Invalid user identifier.");
    }

    String apiUri = "/" + userIdentifier + "/notes";

    // set system locale if none given
    Locale localeParam = locale;
    if (localeParam == null)
        localeParam = Util.getSystemLocale();

    List<NameValuePair> params = ParameterHelper.addAllParams(
            new BasicNameValuePair("access_token", mFacebookContext.getAccessToken()),
            new BasicNameValuePair("locale", localeParam.toString()));

    // set page parameters
    setPageCursorParams(params, limit, after, before);

    return populateNoteList(localeParam, getResponseJson(getHttpGet(apiUri, params)));
}

From source file:illab.nabal.proxy.FacebookProxy.java

/**
 * Get comments attached to a post corresponding to given parent post ID.
 * /*www  .jav a  2s  . co  m*/
 * @param parentPostId
 * @param limit
 * @param after
 * @param before
 * @param locale
 * @return list of FacebookPost objects
 * @throws Exception
 */
private List<FacebookPost> getComments(String parentPostId, int limit, String after, String before,
        Locale locale) throws Exception {

    // throw an exception if parent post ID is invalid
    if (StringHelper.isEmpty(parentPostId) == true) {
        throw new SystemException("Invalid parent post ID.");
    }

    String apiUri = "/" + parentPostId + "/comments";

    // set system locale if none given
    Locale localeParam = locale;
    if (localeParam == null)
        localeParam = Util.getSystemLocale();

    List<NameValuePair> params = ParameterHelper.addAllParams(
            new BasicNameValuePair("access_token", mFacebookContext.getAccessToken()),
            new BasicNameValuePair("locale", localeParam.toString()));

    // set page parameters
    setPageCursorParams(params, limit, after, before);

    return populatePostList(parentPostId, localeParam, getResponseJson(getHttpGet(apiUri, params)));
}

From source file:illab.nabal.proxy.FacebookProxy.java

/**
 * Get photos from given owner identifier.
 * //from w  w  w  .  j  a v  a  2s.com
 * @param ownerIdentifier
 * @param since
 * @param until
 * @param limit
 * @param after
 * @param before
 * @param locale
 * @param isUnixTime
 * @return list of FacebookPhoto objects
 * @throws Exception
 */
private List<FacebookPhoto> getPhotos(String ownerIdentifier, long since, long until, int limit, String after,
        String before, Locale locale, boolean isUnixTime) throws Exception {

    // throw an exception if owner identifier is invalid
    if (StringHelper.isEmpty(ownerIdentifier) == true) {
        throw new SystemException("Invalid owner identifier.");
    }

    String apiUri = "/" + ownerIdentifier + "/photos";

    // set system locale if none given
    Locale localeParam = locale;
    if (localeParam == null)
        localeParam = Util.getSystemLocale();

    List<NameValuePair> params = ParameterHelper.addAllParams(
            new BasicNameValuePair("access_token", mFacebookContext.getAccessToken()),
            new BasicNameValuePair("locale", localeParam.toString()));

    // set cursor page parameters if needed
    setPageCursorParams(params, limit, after, before);

    // set time-based page parameters if needed
    setTimeBasedPageParams(params, since, until, limit, isUnixTime);

    return populatePhotoList(localeParam, getResponseJson(getHttpGet(apiUri, params)));
}

From source file:illab.nabal.proxy.FacebookProxy.java

/**
 * Get timeline owned by given owner indentifier.
 * /*from   ww  w  . ja  va 2  s .c o m*/
 * @param ownerIdentifier
 * @param since
 * @param until
 * @param limit
 * @param textOnly
 * @param locale
 * @return list of FacebookPost objects
 * @throws Exception
 */
private List<FacebookPost> getTimeline(String ownerIdentifier, long since, long until, int limit,
        boolean textOnly, Locale locale, boolean isUnixTime) throws Exception {

    // throw an exception if owner identifier is invalid
    if (StringHelper.isEmpty(ownerIdentifier) == true) {
        throw new SystemException("Invalid owner identifier.");
    }

    String uriEndpoint = "feed";

    // get text status updates only if set so
    if (textOnly == true) {
        uriEndpoint = "statuses";
    }

    String apiUri = "/" + ownerIdentifier + "/" + uriEndpoint;

    // set system locale if none given
    Locale localeParam = locale;
    if (localeParam == null)
        localeParam = Util.getSystemLocale();

    List<NameValuePair> params = ParameterHelper.addAllParams(
            new BasicNameValuePair("access_token", mFacebookContext.getAccessToken()),
            new BasicNameValuePair("locale", localeParam.toString()));

    // set page parameters
    setTimeBasedPageParams(params, since, until, limit, isUnixTime);

    return populatePostList(localeParam, getResponseJson(getHttpGet(apiUri, params)));
}

From source file:illab.nabal.proxy.FacebookProxy.java

/**
 * Get 30 messages from message thread corresponding to given message thread ID.
 * // w w w.ja v  a 2  s  .  c o  m
 * @param messageThreadId
 * @param since
 * @param until
 * @param limit
 * @param locale
 * @param isUnixTime
 * @return list of FacebookMessage objects
 * @throws Exception
 */
private List<FacebookMessage> getMessages(String messageThreadId, long since, long until, int limit,
        Locale locale, boolean isUnixTime) throws Exception {

    // throw an exception if message threaad ID is invalid
    if (StringHelper.isEmpty(messageThreadId) == true) {
        throw new SystemException("Invalid message thread ID.");
    }

    String apiUri = "/" + messageThreadId + "/comments";

    // validate limit
    int messageLimit = limit;
    if (messageLimit < 1) {
        messageLimit = 1;
    } else if (messageLimit > 30) {
        messageLimit = 30;
    }

    // set system locale if none given
    Locale localeParam = locale;
    if (localeParam == null)
        localeParam = Util.getSystemLocale();

    List<NameValuePair> params = ParameterHelper.addAllParams(
            new BasicNameValuePair("access_token", mFacebookContext.getAccessToken()),
            new BasicNameValuePair("locale", localeParam.toString()));

    // set page parameters
    setTimeBasedPageParams(params, since, until, messageLimit, isUnixTime);

    return populateMessageList(localeParam, getResponseJson(getHttpGet(apiUri, params)));
}

From source file:illab.nabal.proxy.FacebookProxy.java

/**
 * Get users who liked the post/comment corresponding to given post ID.
 * //w w  w .j a v  a  2  s .c o  m
 * @param postId
 * @param limit
 * @param after
 * @param before
 * @param locale
 * @return list of FacebookProfile objects
 * @throws Exception
 */
private List<FacebookProfile> getLikes(String postId, int limit, String after, String before, Locale locale)
        throws Exception {

    // throw an exception if post ID is invalid
    if (StringHelper.isEmpty(postId) == true) {
        throw new SystemException("Invalid post ID.");
    }

    String apiUri = "/" + postId + "/likes";

    // set system locale if none given
    Locale localeParam = locale;
    if (localeParam == null)
        localeParam = Util.getSystemLocale();

    List<NameValuePair> params = ParameterHelper.addAllParams(
            new BasicNameValuePair("access_token", mFacebookContext.getAccessToken()),
            new BasicNameValuePair("fields", "id,username,name"),
            new BasicNameValuePair("locale", localeParam.toString()));

    // set page parameters
    setPageCursorParams(params, limit, after, before);

    return populateProfileList(localeParam, getResponseJson(getHttpGet(apiUri, params)));
}

From source file:illab.nabal.proxy.FacebookProxy.java

/**
 * Get user profiles that the owner of the current access token subscribed to. 
 * //from  w w w.j av a 2 s  .c  o m
 * @param userIdentifier
 * @param limit
 * @param after
 * @param before
 * @param locale
 * @return list of FacebookProfile
 * @throws Exception
 */
private List<FacebookProfile> getSubscribedTo(String userIdentifier, int limit, String after, String before,
        Locale locale) throws Exception {

    // throw an exception if user identifier is invalid
    if (StringHelper.isEmpty(userIdentifier) == true) {
        throw new SystemException("Invalid user identifier.");
    }

    String apiUri = "/" + userIdentifier + "/subscribedto";

    // set system locale if none given
    Locale localeParam = locale;
    if (localeParam == null)
        localeParam = Util.getSystemLocale();

    List<NameValuePair> params = ParameterHelper.addAllParams(
            new BasicNameValuePair("access_token", mFacebookContext.getAccessToken()),
            new BasicNameValuePair("fields", getProfileFields(null)),
            new BasicNameValuePair("locale", localeParam.toString()));

    // set page parameters
    setPageCursorParams(params, limit, after, before);

    return populateProfileList(localeParam, getResponseJson(getHttpGet(apiUri, params)));
}

From source file:illab.nabal.proxy.FacebookProxy.java

/**
 * Get user profiles that subscribed to the timeline owned by the owner of 
 * the current access token.//from ww w  .j  a va 2  s  .  c o m
 * 
 * @param userIdentifier
 * @param limit
 * @param after
 * @param before
 * @param locale
 * @return list of FacebookProfile
 * @throws Exception
 */
private List<FacebookProfile> getSubscribers(String userIdentifier, int limit, String after, String before,
        Locale locale) throws Exception {

    // throw an exception if user identifier is invalid
    if (StringHelper.isEmpty(userIdentifier) == true) {
        throw new SystemException("Invalid user identifier.");
    }

    String apiUri = "/" + userIdentifier + "/subscribers";

    // set system locale if none given
    Locale localeParam = locale;
    if (localeParam == null)
        localeParam = Util.getSystemLocale();

    List<NameValuePair> params = ParameterHelper.addAllParams(
            new BasicNameValuePair("access_token", mFacebookContext.getAccessToken()),
            new BasicNameValuePair("fields", getProfileFields(null)),
            new BasicNameValuePair("locale", localeParam.toString()));

    // set page parameters
    setPageCursorParams(params, limit, after, before);

    return populateProfileList(localeParam, getResponseJson(getHttpGet(apiUri, params)));
}

From source file:illab.nabal.proxy.FacebookProxy.java

/**
 * Get friend requests for the owner of the current access token.
 * /*from w w w  .  jav a2 s  .c  o m*/
 * @param getOnlyUnread
 * @param limit
 * @param offset
 * @param locale
 * @return list of FacebookProfile
 * @throws Exception
 */
private List<FacebookProfile> getFriendRequestsForMe(boolean getOnlyUnread, int limit, int offset,
        Locale locale) throws Exception {

    String apiUri = "/me/friendrequests";

    // fields parameters - expand from field to get details 
    String[] fields = { "to", "from.fields(" + getProfileFields(null) + ")", "message", "unread",
            "created_time" };

    // set system locale if none given
    Locale localeParam = locale;
    if (localeParam == null)
        localeParam = Util.getSystemLocale();

    List<NameValuePair> params = ParameterHelper.addAllParams(
            new BasicNameValuePair("access_token", mFacebookContext.getAccessToken()),
            new BasicNameValuePair("fields", TextUtils.join(",", fields)),
            new BasicNameValuePair("locale", localeParam.toString()));

    // set page parameters
    setPageOffsetParams(params, limit, offset);

    return populateProfileList(null, getOnlyUnread, localeParam, getResponseJson(getHttpGet(apiUri, params)));
}