List of usage examples for java.util Locale ROOT
Locale ROOT
To view the source code for java.util Locale ROOT.
Click Source Link
From source file:com.puppycrawl.tools.checkstyle.internal.AllChecksTest.java
@Test public void testAllCheckstyleModulesHaveXdocDocumentation() throws Exception { final Set<String> checkstyleModulesNames = getSimpleNames(CheckUtil.getCheckstyleModules()); final Set<String> modulesNamesWhichHaveXdocs = XDocUtil.getModulesNamesWhichHaveXdoc(); for (String moduleName : checkstyleModulesNames) { if (!modulesNamesWhichHaveXdocs.contains(moduleName)) { final String missingModuleMessage = String.format(Locale.ROOT, "Module %s does not have xdoc documentation.", moduleName); Assert.fail(missingModuleMessage); }/* www . j a va 2 s. co m*/ } }
From source file:com.xpn.xwiki.doc.XWikiDeletedDocument.java
/** * @return {@link XWikiDocument#getLocale()} * @since 8.0M1/*from w w w . j av a 2 s . c o m*/ */ public Locale getLocale() { return this.locale != null ? this.locale : Locale.ROOT; }
From source file:com.grayfox.server.dao.RecommendationDaoTest.java
@Test @Transactional/*from www . j a v a2 s . c o m*/ public void testFetchNearestByCategoriesLikedByFriends() { loadMockDataFetchNearestByCategoriesLikedByFriends(); Category c1 = new Category(); c1.setFoursquareId("1"); c1.setIconUrl("url1"); c1.setName("CAT_1"); Category c2 = new Category(); c2.setFoursquareId("2"); c2.setIconUrl("url2"); c2.setName("CAT_2"); Poi p1 = new Poi(); p1.setFoursquareId("1"); p1.setFoursquareRating(9.2); p1.setLocation(Location.parse("19.044,-98.197753")); p1.setName("POI_1"); p1.setCategories(new HashSet<>(Arrays.asList(c1))); Poi p3 = new Poi(); p3.setFoursquareId("3"); p3.setFoursquareRating(9d); p3.setLocation(Location.parse("19.04329,-98.197432")); p3.setName("POI_3"); p3.setCategories(new HashSet<>(Arrays.asList(c2))); Recommendation r1 = new Recommendation(); r1.setPoi(p1); r1.setType(Recommendation.Type.SOCIAL); r1.setReason(Messages.get("recommendation.social.reason", "John2 Doe2", c1.getName())); Recommendation r2 = new Recommendation(); r2.setPoi(p3); r2.setType(Recommendation.Type.SOCIAL); r2.setReason(Messages.get("recommendation.social.reason", "John3 Doe3", c2.getName())); List<Recommendation> expectedRecommendations = Arrays.asList(r1, r2); List<Recommendation> actualRecommendations = recommendationDao.findNearestByCategoriesLikedByFriends( "fakeToken", Location.parse("19.043635,-98.197947"), 100, Locale.ROOT); assertThat(actualRecommendations).isNotNull().isNotEmpty().doesNotContainNull() .hasSameSizeAs(expectedRecommendations).containsExactlyElementsOf(expectedRecommendations); }
From source file:com.gargoylesoftware.htmlunit.DefaultPageCreator.java
/** * Tries to determine the content type.//from w w w.j ava 2 s.c om * TODO: implement a content type sniffer based on the * <a href="http://tools.ietf.org/html/draft-abarth-mime-sniff-05">Content-Type Processing Model</a> * @param contentType the contentType header if any * @param contentAsStream stream allowing to read the downloaded content * @return the sniffed mime type * @exception IOException if an IO problem occurs */ protected String determineContentType(final String contentType, final InputStream contentAsStream) throws IOException { final byte[] markerUTF8 = { (byte) 0xef, (byte) 0xbb, (byte) 0xbf }; final byte[] markerUTF16BE = { (byte) 0xfe, (byte) 0xff }; final byte[] markerUTF16LE = { (byte) 0xff, (byte) 0xfe }; try { if (!StringUtils.isEmpty(contentType)) { return contentType; } final byte[] bytes = read(contentAsStream, 500); if (bytes.length == 0) { return "text/plain"; } final String asAsciiString = new String(bytes, "ASCII").toUpperCase(Locale.ROOT); if (asAsciiString.contains("<HTML")) { return "text/html"; } else if (startsWith(bytes, markerUTF8) || startsWith(bytes, markerUTF16BE) || startsWith(bytes, markerUTF16LE)) { return "text/plain"; } else if (isBinary(bytes)) { return "application/octet-stream"; } } finally { IOUtils.closeQuietly(contentAsStream); } return "text/plain"; }
From source file:com.puppycrawl.tools.checkstyle.api.AutomaticBean.java
/** * Recheck property and try to copy it.//ww w . ja v a 2 s. com * @param moduleName name of the module/class * @param key key of value * @param value value * @param recheck whether to check for property existence before copy * @throws CheckstyleException then property defined incorrectly */ private void tryCopyProperty(String moduleName, String key, Object value, boolean recheck) throws CheckstyleException { final BeanUtilsBean beanUtils = createBeanUtilsBean(); try { if (recheck) { // BeanUtilsBean.copyProperties silently ignores missing setters // for key, so we have to go through great lengths here to // figure out if the bean property really exists. final PropertyDescriptor descriptor = PropertyUtils.getPropertyDescriptor(this, key); if (descriptor == null) { final String message = String.format(Locale.ROOT, "Property '%s' in module %s " + "does not exist, please check the documentation", key, moduleName); throw new CheckstyleException(message); } } // finally we can set the bean property beanUtils.copyProperty(this, key, value); } catch (final InvocationTargetException | IllegalAccessException | NoSuchMethodException e) { // There is no way to catch IllegalAccessException | NoSuchMethodException // as we do PropertyUtils.getPropertyDescriptor before beanUtils.copyProperty // so we have to join these exceptions with InvocationTargetException // to satisfy UTs coverage final String message = String.format(Locale.ROOT, "Cannot set property '%s' to '%s' in module %s", key, value, moduleName); throw new CheckstyleException(message, e); } catch (final IllegalArgumentException | ConversionException e) { final String message = String.format(Locale.ROOT, "illegal value '%s' for property " + "'%s' of module %s", value, key, moduleName); throw new CheckstyleException(message, e); } }
From source file:com.xpn.xwiki.doc.XWikiDeletedDocument.java
/** * @param locale - {@link XWikiDocument#getLanguage()} to set * @deprecated since 8.0M1/*from w ww.j a v a 2 s . c o m*/ */ @Deprecated protected void setLanguage(String locale) { this.locale = LocaleUtils.toLocale(Util.normalizeLanguage(locale), Locale.ROOT); }
From source file:com.gargoylesoftware.htmlunit.javascript.host.event.EventListenersContainer.java
/** * Removes event listener.//w w w . java 2s .c o m * @param eventType the type * @param listener the listener * @param useCapture to use capture or not */ public void removeEventListener(final String eventType, final Scriptable listener, final boolean useCapture) { if (null == listener) { return; } final Handlers handlers = eventHandlers_.get(eventType.toLowerCase(Locale.ROOT)); if (handlers != null) { handlers.removeListener(listener, useCapture); } }
From source file:com.netflix.discovery.shared.Applications.java
/** * Gets the list of <em>instances</em> associated to a virtual host name. * * @param virtualHostName/*from ww w . j a v a 2 s .c om*/ * the virtual hostname for which the instances need to be * returned. * @return list of <em>instances</em>. */ public List<InstanceInfo> getInstancesByVirtualHostName(String virtualHostName) { AtomicReference<List<InstanceInfo>> ref = this.shuffleVirtualHostNameMap .get(virtualHostName.toUpperCase(Locale.ROOT)); if (ref == null || ref.get() == null) { return new ArrayList<InstanceInfo>(); } else { return ref.get(); } }
From source file:net.sf.yal10n.analyzer.ExploratoryEncodingTest.java
/** * Test to load a resource bundle from a BOM encoded file that starts with a comment. * @throws Exception any error/*from www. java 2 s .c o m*/ */ @Test public void testResourceBundleWithBOMandComment() throws Exception { ResourceBundle bundle = PropertyResourceBundle.getBundle("UTF8BOMwithComment", Locale.ROOT); Assert.assertEquals(4, bundle.keySet().size()); Assert.assertEquals("", bundle.getString("\u00ef\u00bb\u00bf#abc")); Assert.assertEquals("first key", bundle.getString("testkey1")); Assert.assertEquals("second key", bundle.getString("testkey2")); // note: utf-8 read as iso-8859-1 Assert.assertEquals("This file is encoded as UTF-8 with BOM \u00c3\u00a4.", bundle.getString("description")); }
From source file:eu.trentorise.opendata.commons.test.jackson.TodCommonsModuleTest.java
/** * Shows that contrary to Jackson we deserialize "" into {@link Locale#ROOT} * instead of nasty null./*from www . j ava 2s. c o m*/ * * @since 1.1.0 */ @Test public void testEmptyLocaleDeser() throws JsonProcessingException, IOException { RootLocale rootLocale = new RootLocale(); rootLocale.locale = Locale.ROOT; String json = objectMapper.writeValueAsString(rootLocale); LOG.log(Level.FINE, "json = {0}", json); RootLocale res = objectMapper.readValue(json, RootLocale.class); assertNotNull(res.locale); assertEquals(Locale.ROOT, res.locale); }