List of usage examples for java.util Locale Locale
public Locale(String language)
From source file:jp.terasoluna.fw.beans.jxpath.DynamicPropertyPointerExTest.java
/** * testGetLength01()// w w w . j ava 2 s . c o m * <br><br> * * () * <br> * A * <br><br> * () getBaseValue():null<br> * * <br> * () -:1<br> * * <br> * ???null???? * <br> * * @throws Exception ????? */ @Test @SuppressWarnings("unchecked") public void testGetLength01() throws Exception { // ?? QName qName = new QName("name"); @SuppressWarnings("rawtypes") Map map = new HashMap(); map.put("key", null); DynamicPropertyHandler handler = new MapDynamicPropertyHandler(); Locale locale = new Locale("ja"); NodePointer nodePointer = NodePointer.newNodePointer(qName, map, locale); DynamicPropertyPointerEx pointer = new DynamicPropertyPointerEx(nodePointer, handler); pointer.setPropertyName("key"); // assertEquals(1, pointer.getLength()); }
From source file:org.darwinathome.server.email.EmailSender.java
private Template getTemplate(String name, Reader reader) throws IOException { Configuration configuration = new Configuration(); configuration.setLocale(new Locale("nl")); configuration.setObjectWrapper(new DefaultObjectWrapper()); return new Template(name, reader, configuration); }
From source file:com.nkapps.billing.configs.MvcConfig.java
@Bean public LocaleResolver localeResolver() { CookieLocaleResolver clr = new CookieLocaleResolver(); clr.setDefaultLocale(new Locale("ru")); return clr;/*w ww .ja v a 2s. c om*/ }
From source file:org.osiam.addons.administration.mail.EmailSender.java
public void sendDeactivateMail(User user) { sendDeactivateMail(user, new Locale(user.getLocale())); }
From source file:com.seajas.search.utilities.spring.security.CrowdSSOLanguageAuthenticationProcessingFilter.java
/** * Set the user details, where we explicitly set the user language, if provided. * //from w ww. j a va2 s . c o m * @param request * @param authRequest */ @Override protected void setDetails(HttpServletRequest request, UsernamePasswordAuthenticationToken authRequest) { super.setDetails(request, authRequest); if (!StringUtils.isEmpty(request .getParameter(UsernamePasswordLanguageAuthenticationFilter.SPRING_SECURITY_FORM_LANGUAGE_KEY))) { if (logger.isDebugEnabled()) logger.debug("Requested login session language is '" + request.getParameter( UsernamePasswordLanguageAuthenticationFilter.SPRING_SECURITY_FORM_LANGUAGE_KEY) + "'"); WebUtils.setSessionAttribute(request, AcceptHeaderSessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME, new Locale(request.getParameter( UsernamePasswordLanguageAuthenticationFilter.SPRING_SECURITY_FORM_LANGUAGE_KEY))); } }
From source file:fi.helsinki.opintoni.integration.unisport.UnisportRestClientTest.java
@Test public void thatUserReservationsAreReturned() { unisportServer.expectUserReservations(); UnisportUserReservations userReservations = unisportRestClient.getUserReservations(UNISPORT_USER_ID, new Locale("fi")); assertThat(userReservations.reservations.get(1).events.get(1).name).isEqualTo(UNISPORT_EVENT_NAME); }
From source file:jp.terasoluna.fw.beans.jxpath.DynamicPointerExTest.java
/** * testDynamicPointerExQname01() <br> * <br>/*from w ww . ja va 2 s . c o m*/ * () <br> * A <br> * <br> * () name:not null<br> * () bean:new Object()<br> * () handler:not null<br> * () locale:Locale("ja")<br> * () this.handler:null<br> * <br> * () this.handler:???<br> * <br> * ?? <br> * @throws Exception ????? */ @Test public void testDynamicPointerExQname01() throws Exception { // ?? QName qName = new QName("name"); Object bean = new Object(); DynamicPropertyHandler handler = new MapDynamicPropertyHandler(); Locale locale = new Locale("ja"); // DynamicPointerEx result = new DynamicPointerEx(qName, bean, handler, locale); // Field field = DynamicPointerEx.class.getDeclaredField("handler"); field.setAccessible(true); Object resultHandler = field.get(result); assertSame(handler, resultHandler); }
From source file:jp.terasoluna.fw.beans.jxpath.BeanPointerExTest.java
/** * testBeanPointerExQname01() <br> * <br>//from w w w . j a va 2s .c om * () <br> * A <br> * <br> * () name:not null<br> * () bean:new Object()<br> * () beanInfo:not null<br> * () locale:Locale("ja")<br> * () this.beanInfo:null<br> * <br> * () this.beanInfo:???<br> * <br> * ?? <br> * @throws Exception ????? */ @Test public void testBeanPointerExQname01() throws Exception { // ?? QName qName = new QName("name"); Object bean = new Object(); JXPathBeanInfo beanInfo = new JXPathBasicBeanInfo(bean.getClass()); Locale locale = new Locale("ja"); // BeanPointerEx result = new BeanPointerEx(qName, bean, beanInfo, locale); // assertEquals(beanInfo, ReflectionTestUtils.getField(result, "beanInfo")); }
From source file:com.uimirror.auth.conf.DispatcherConfig.java
@Bean(name = "localeResolver") public LocaleResolver sessionLocaleResolver() { CookieLocaleResolver localeResolver = new CookieLocaleResolver(); localeResolver.setDefaultLocale(new Locale("en")); localeResolver.setCookieName("uim_locale"); localeResolver.setCookieMaxAge(36000); return localeResolver; }
From source file:at.alladin.rmbt.controlServer.NewsResource.java
@Post("json") public String request(final String entity) { addAllowOrigin();/*from w w w .j a va 2 s . c o m*/ JSONObject request = null; final ErrorList errorList = new ErrorList(); final JSONObject answer = new JSONObject(); String answerString; System.out.println(MessageFormat.format(labels.getString("NEW_NEWS"), getIP())); if (entity != null && !entity.isEmpty()) // try parse the string to a JSON object try { request = new JSONObject(entity); String lang = request.optString("language"); // Load Language Files for Client final List<String> langs = Arrays .asList(settings.getString("RMBT_SUPPORTED_LANGUAGES").split(",\\s*")); if (langs.contains(lang)) { errorList.setLanguage(lang); labels = ResourceManager.getSysMsgBundle(new Locale(lang)); } else lang = settings.getString("RMBT_DEFAULT_LANGUAGE"); String sqlLang = lang; if (!sqlLang.equals("de")) sqlLang = "en"; if (conn != null) { final long lastNewsUid = request.optLong("lastNewsUid"); final String plattform = request.optString("plattform"); final int softwareVersionCode = request.optInt("softwareVersionCode", -1); String uuid = request.optString("uuid"); final JSONArray newsList = new JSONArray(); try { final PreparedStatement st = conn.prepareStatement("SELECT uid,title_" + sqlLang + " AS title, text_" + sqlLang + " AS text FROM news " + " WHERE" + " (uid > ? OR force = true)" + " AND active = true" + " AND (plattform IS NULL OR plattform = ?)" + " AND (max_software_version_code IS NULL OR ? <= max_software_version_code)" + " AND (min_software_version_code IS NULL OR ? >= min_software_version_code)" + " AND (uuid IS NULL OR uuid::TEXT = ?)" + //convert to text so that empty uuid-strings are tolerated " ORDER BY time ASC"); st.setLong(1, lastNewsUid); st.setString(2, plattform); st.setInt(3, softwareVersionCode); st.setInt(4, softwareVersionCode); st.setString(5, uuid); final ResultSet rs = st.executeQuery(); while (rs.next()) { final JSONObject jsonItem = new JSONObject(); jsonItem.put("uid", rs.getInt("uid")); jsonItem.put("title", rs.getString("title")); jsonItem.put("text", rs.getString("text")); newsList.put(jsonItem); } rs.close(); st.close(); } catch (final SQLException e) { e.printStackTrace(); errorList.addError("ERROR_DB_GET_NEWS_SQL"); } // } answer.put("news", newsList); } else errorList.addError("ERROR_DB_CONNECTION"); } catch (final JSONException e) { errorList.addError("ERROR_REQUEST_JSON"); System.out.println("Error parsing JSON Data " + e.toString()); } else errorList.addErrorString("Expected request is missing."); try { answer.putOpt("error", errorList.getList()); } catch (final JSONException e) { System.out.println("Error saving ErrorList: " + e.toString()); } answerString = answer.toString(); return answerString; }