List of usage examples for java.util Locale toString
@Override public final String toString()
Locale
object, consisting of language, country, variant, script, and extensions as below: language + "_" + country + "_" + (variant + "_#" | "#") + script + "_" + extensionsLanguage is always lower case, country is always upper case, script is always title case, and extensions are always lower case.
From source file:illab.nabal.proxy.FacebookProxy.java
/** * Get a message thread with last 30 messages in it. * //w w w.ja v a2 s. c o m * @param messageThreadId * @param locale * @param isUnixTime * @return FacebookMessageThread * @throws Exception */ private FacebookMessageThread getMessageThread(String messageThreadId, 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; // fields parameters String[] fields = { "id", "to", "unread", "unseen", "updated_time", "comments.limit(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("fields", TextUtils.join(",", fields)), new BasicNameValuePair("locale", localeParam.toString())); // set date format parameter setDateFormatParam(params, isUnixTime); return populateMessageThreadBean(localeParam, getResponseJson(getHttpGet(apiUri, params))); }
From source file:illab.nabal.proxy.FacebookProxy.java
/** * Get a Facebook profile corresponding to given user name. * /*from ww w. jav a 2 s . co m*/ * @param userIdentifier * @param additionalFields * @return FacebookProfile * @throws Exception */ private FacebookProfile getProfile(String userIdentifier, String[] additionalFields, 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; // 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(additionalFields)), new BasicNameValuePair("locale", localeParam.toString())); return populateProfileBean(additionalFields, localeParam, getResponseJson(getHttpGet(apiUri, params))); }
From source file:illab.nabal.proxy.FacebookProxy.java
/** * Get friend list from an user who authorized this Facebook app. * /*w ww .j ava 2s.c o m*/ * @param userIdentifier * @param limit * @param offset * @param additionalFields * @param locale * @return list of FacebookProfile objects * @throws Exception */ private List<FacebookProfile> getFriendList(String userIdentifier, int limit, int offset, String[] additionalFields, 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 + "/friends"; // 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(additionalFields)), new BasicNameValuePair("locale", localeParam.toString())); // set page parameters setPageOffsetParams(params, limit, offset); return populateProfileList(additionalFields, localeParam, getResponseJson(getHttpGet(apiUri, params))); }
From source file:illab.nabal.proxy.FacebookProxy.java
/** * Get mutual friends between the owner of the current access token and * given user identifier.// w w w . j av a 2 s. c o m * * @param userIdentifier * @param limit * @param offset * @param additionalFields * @param locale * @return list of FacebookProfile objects * @throws Exception */ private List<FacebookProfile> getMutualFriendList(String userIdentifier, int limit, int offset, String[] additionalFields, 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 = "/me/mutualfriends/" + userIdentifier; // 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(additionalFields)), new BasicNameValuePair("locale", localeParam.toString())); // set page parameters setPageOffsetParams(params, limit, offset); return populateProfileList(additionalFields, localeParam, getResponseJson(getHttpGet(apiUri, params))); }
From source file:illab.nabal.proxy.FacebookProxy.java
/** * Get my message threads./*from ww w . j av a 2s . c om*/ * * @param howManyMessages * @param since * @param until * @param limit * @param locale * @param isUnixTime * @return list of FacebookMessageThread objects * @throws Exception */ private List<FacebookMessageThread> getMyMessageThreads(int howManyMessages, long since, long until, int limit, Locale locale, boolean isUnixTime) throws Exception { String apiUri = "/me/inbox"; // validate how many messages per thread int messageLimit = howManyMessages; if (messageLimit < 1) { messageLimit = 1; } else if (messageLimit > 30) { messageLimit = 30; } // fields parameters String[] fields = { "id", "to", "unread", "unseen", "updated_time", "comments.limit(" + messageLimit + ")" }; // 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 setTimeBasedPageParams(params, since, until, limit, isUnixTime); return populateMessageThreadList(localeParam, getResponseJson(getHttpGet(apiUri, params))); }
From source file:illab.nabal.proxy.FacebookProxy.java
/** * Get events./*from w ww. j a v a 2 s . c om*/ * * @param ownerIdentifier * @param filter * @param limit * @param offset * @param locale * @return list of FacebookEvent objects * @throws Exception */ private List<FacebookEvent> getEvents(String ownerIdentifier, FacebookEvent.Filter filter, int limit, int offset, Locale locale) throws Exception { // throw an exception if owner identifier is invalid if (StringHelper.isEmpty(ownerIdentifier) == true) { throw new SystemException("Invalid owner identifier."); } String uriEndpoint = ""; // set filter if needed if (filter != null) { uriEndpoint = "/" + filter.getFilterString(); } String apiUri = "/" + ownerIdentifier + "/events" + uriEndpoint; String[] fields = { "id", "owner", "name", "description", "cover", "start_time", "end_time", "timezone", "location,venue", "privacy", "updated_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 populateEventList(localeParam, getResponseJson(getHttpGet(apiUri, params))); }
From source file:illab.nabal.proxy.FacebookProxy.java
/** * Get participants of the event corresponding to given event ID. * //from ww w. j a v a 2 s . co m * @param eventId * @param participantStatus * @param limit * @param offset * @param locale * @return list of FacebookProfile objects * @throws Exception */ private List<FacebookProfile> getEventParticipants(String eventId, FacebookEvent.ParticipantStatus participantStatus, int limit, int offset, Locale locale) throws Exception { // throw an exception if event ID is invalid if (StringHelper.isEmpty(eventId) == true) { throw new SystemException("Invalid event ID."); } String uriEndpoint = FacebookEvent.ParticipantStatus.INVITED.getUriEndpointString(); // set participant status if needed if (participantStatus != null) { uriEndpoint = participantStatus.getUriEndpointString(); } String apiUri = "/" + eventId + "/" + 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("fields", getProfileFields(null) + "," + RSVP_STATUS), new BasicNameValuePair("locale", localeParam.toString())); // set page parameters setPageOffsetParams(params, limit, offset); return populateProfileList(localeParam, getResponseJson(getHttpGet(apiUri, params))); }
From source file:illab.nabal.proxy.FacebookProxy.java
/** * Get Facebook objects that are liked by given owner identifier. * /*from ww w . ja v a 2 s. co m*/ * @param ownerIdentifier * @param limit * @param offset * @param locale * @return list of FacebookLikableObject objects * @throws Exception */ private List<FacebookLikableObject> getLikedObjects(String ownerIdentifier, int limit, int offset, Locale locale) throws Exception { String apiUri = "/" + ownerIdentifier + "/likes"; // fields parameters String[] fields = { "id", "category", "name", "description", "link", "can_post", "talking_about_count", "website", "cover", "created_time" }; // set system locale if none given Locale localeParam = locale; if (localeParam == null) localeParam = Util.getSystemLocale(); // check locale and set to system default if null 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 populateLikableList(localeParam, getResponseJson(getHttpGet(apiUri, params))); }
From source file:illab.nabal.proxy.FacebookProxy.java
/** * Create an event./*from ww w. j a v a 2s . c o m*/ * * @param ownerIdentifier * @param name * @param description * @param startTime * @param endTime * @param locale * @return FacebookEvent * @throws Exception */ private FacebookEvent createEvent(String ownerIdentifier, String name, String description, String startTime, String endTime, String locationName, String placeId, FacebookEvent.Privacy privacy, Locale locale) throws Exception { // throw an exception if owner identifier is invalid if (StringHelper.isEmpty(ownerIdentifier) == true) { throw new SystemException("Invalid owner identifier."); } // check name if (StringHelper.isEmpty(name) == true) { throw new SystemException("Invalid event name."); } // check description if (StringHelper.isEmpty(description) == true) { throw new SystemException("Invalid event description."); } // check start time if (StringHelper.isEmpty(startTime) == true) { throw new SystemException("Invalid event start time."); } String apiUri = "/" + ownerIdentifier + "/events"; List<NameValuePair> params = ParameterHelper.addAllParams( new BasicNameValuePair("access_token", mFacebookContext.getAccessToken()), new BasicNameValuePair("name", name), new BasicNameValuePair("description", description), new BasicNameValuePair("start_time", startTime), new BasicNameValuePair("end_time", endTime)); // set end time if needed if (StringHelper.isEmpty(endTime) == false) { params.add(new BasicNameValuePair("end_time", endTime)); } // set location name if needed if (StringHelper.isEmpty(locationName) == false) { params.add(new BasicNameValuePair("location", locationName)); } // set palce ID if needed if (StringHelper.isEmpty(placeId) == false) { params.add(new BasicNameValuePair("location_id", placeId)); } // set privacy if needed if (privacy != null) { params.add(new BasicNameValuePair("privacy_type", privacy.getPrivacyString())); } // execute post JSONObject responseJson = getResponseJson(getHttpPost(apiUri, params)); // check returned JSON if (responseJson.has("id") == false) { NetworkException ne = new NetworkException("Invalid response."); ne.setResponseJson(responseJson); throw ne; } // set system locale if none given Locale localeParam = locale; if (localeParam == null) localeParam = Util.getSystemLocale(); // reset URI and parameters to fetch the event object that just has been created apiUri = "/" + responseJson.getString("id"); params = ParameterHelper.addAllParams( new BasicNameValuePair("access_token", mFacebookContext.getAccessToken()), new BasicNameValuePair("locale", localeParam.toString())); return populateEventBean(localeParam, getResponseJson(getHttpGet(apiUri, params))); }
From source file:org.jahia.services.content.JCRNodeWrapperImpl.java
@Override public Node getOrCreateI18N(final Locale locale) throws RepositoryException { try {//from w ww .j a v a2 s . c o m return getI18N(locale, false); } catch (RepositoryException e) { Node t = objectNode.addNode(getTranslationNodeName(locale), Constants.JAHIANT_TRANSLATION); t.setProperty("jcr:language", locale.toString()); i18NobjectNodes.put(locale, t); return t; } }