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:fr.free.nrw.commons.mwapi.OkHttpJsonApiClient.java
public Observable<List<Place>> getNearbyPlaces(LatLng cur, String lang, double radius) throws IOException { String wikidataQuery = FileUtils.readFromResource("/queries/nearby_query.rq"); String query = wikidataQuery.replace("${RAD}", String.format(Locale.ROOT, "%.2f", radius)) .replace("${LAT}", String.format(Locale.ROOT, "%.4f", cur.getLatitude())) .replace("${LONG}", String.format(Locale.ROOT, "%.4f", cur.getLongitude())) .replace("${LANG}", lang); HttpUrl.Builder urlBuilder = HttpUrl.parse(sparqlQueryUrl).newBuilder().addQueryParameter("query", query) .addQueryParameter("format", "json"); Request request = new Request.Builder().url(urlBuilder.build()).build(); return Observable.fromCallable(() -> { Response response = okHttpClient.newCall(request).execute(); if (response != null && response.body() != null && response.isSuccessful()) { String json = response.body().string(); if (json == null) { return new ArrayList<>(); }/*from w ww . j a v a 2s . co m*/ NearbyResponse nearbyResponse = gson.fromJson(json, NearbyResponse.class); List<NearbyResultItem> bindings = nearbyResponse.getResults().getBindings(); List<Place> places = new ArrayList<>(); for (NearbyResultItem item : bindings) { places.add(Place.from(item)); } return places; } return new ArrayList<>(); }); }
From source file:com.gargoylesoftware.htmlunit.CodeStyleTest.java
/** * Checks the year in the source.// w w w .j a v a 2 s . c om */ private void year(final List<String> lines, final String path) { final int year = Calendar.getInstance(Locale.ROOT).get(Calendar.YEAR); if (lines.size() < 2 || !lines.get(1).contains("Copyright (c) 2002-" + year)) { addFailure("Incorrect year in " + path); } }
From source file:ch.cyberduck.core.s3.S3UrlProvider.java
/** * Properly URI encode and prepend the bucket name. * * @param scheme Protocol/*ww w. jav a 2 s. c o m*/ * @return URL to be displayed in browser */ protected DescriptiveUrl toUrl(final Path file, final Scheme scheme) { final StringBuilder url = new StringBuilder(scheme.name()); url.append("://"); if (file.isRoot()) { url.append(session.getHost().getHostname()); } else { final String hostname = this.getHostnameForContainer(containerService.getContainer(file)); if (hostname.startsWith(containerService.getContainer(file).getName())) { url.append(hostname); if (!containerService.isContainer(file)) { url.append(Path.DELIMITER); url.append(URIEncoder.encode(containerService.getKey(file))); } } else { url.append(session.getHost().getHostname()); url.append(URIEncoder.encode(file.getAbsolute())); } } return new DescriptiveUrl(URI.create(url.toString()), DescriptiveUrl.Type.http, MessageFormat .format(LocaleFactory.localizedString("{0} URL"), scheme.name().toUpperCase(Locale.ROOT))); }
From source file:org.elasticsearch.client.RequestTests.java
private static void getAndExistsTest(Function<GetRequest, Request> requestConverter, String method) { String index = randomAsciiOfLengthBetween(3, 10); String type = randomAsciiOfLengthBetween(3, 10); String id = randomAsciiOfLengthBetween(3, 10); GetRequest getRequest = new GetRequest(index, type, id); Map<String, String> expectedParams = new HashMap<>(); if (randomBoolean()) { if (randomBoolean()) { String preference = randomAsciiOfLengthBetween(3, 10); getRequest.preference(preference); expectedParams.put("preference", preference); }/*from w w w. j a v a 2 s . c o m*/ if (randomBoolean()) { String routing = randomAsciiOfLengthBetween(3, 10); getRequest.routing(routing); expectedParams.put("routing", routing); } if (randomBoolean()) { boolean realtime = randomBoolean(); getRequest.realtime(realtime); if (realtime == false) { expectedParams.put("realtime", "false"); } } if (randomBoolean()) { boolean refresh = randomBoolean(); getRequest.refresh(refresh); if (refresh) { expectedParams.put("refresh", "true"); } } if (randomBoolean()) { long version = randomLong(); getRequest.version(version); if (version != Versions.MATCH_ANY) { expectedParams.put("version", Long.toString(version)); } } if (randomBoolean()) { VersionType versionType = randomFrom(VersionType.values()); getRequest.versionType(versionType); if (versionType != VersionType.INTERNAL) { expectedParams.put("version_type", versionType.name().toLowerCase(Locale.ROOT)); } } if (randomBoolean()) { int numStoredFields = randomIntBetween(1, 10); String[] storedFields = new String[numStoredFields]; StringBuilder storedFieldsParam = new StringBuilder(); for (int i = 0; i < numStoredFields; i++) { String storedField = randomAsciiOfLengthBetween(3, 10); storedFields[i] = storedField; storedFieldsParam.append(storedField); if (i < numStoredFields - 1) { storedFieldsParam.append(","); } } getRequest.storedFields(storedFields); expectedParams.put("stored_fields", storedFieldsParam.toString()); } if (randomBoolean()) { randomizeFetchSourceContextParams(getRequest::fetchSourceContext, expectedParams); } } Request request = requestConverter.apply(getRequest); assertEquals("/" + index + "/" + type + "/" + id, request.endpoint); assertEquals(expectedParams, request.params); assertNull(request.entity); assertEquals(method, request.method); }
From source file:business.security.control.OwmClient.java
/** * Find current weather within a bounding box * * @param northLat is the latitude of the geographic top left point of the * bounding box/*from w ww . j a v a 2s . c o m*/ * @param westLon is the longitude of the geographic top left point of the * bounding box * @param southLat is the latitude of the geographic bottom right point of * the bounding box * @param eastLon is the longitude of the geographic bottom right point of * the bounding box * @throws JSONException if the response from the OWM server can't be parsed * @throws IOException if there's some network error or the OWM server * replies with a error. */ public WeatherStatusResponse currentWeatherInBoundingBox(float northLat, float westLon, float southLat, float eastLon) throws IOException, JSONException { //, boolean cluster, OwmClient.Lang lang) { String subUrl = String.format(Locale.ROOT, "find/station?bbox=%f,%f,%f,%f&cluster=yes", Float.valueOf(northLat), Float.valueOf(westLon), Float.valueOf(southLat), Float.valueOf(eastLon)); JSONObject response = doQuery(subUrl); return new WeatherStatusResponse(response); }
From source file:org.apache.solr.cloud.TestPullReplica.java
@Repeat(iterations = 2) // 2 times to make sure cleanup is complete and we can create the same collection public void testCreateDelete() throws Exception { try {//from w w w.j av a2 s .co m switch (random().nextInt(3)) { case 0: // Sometimes use SolrJ CollectionAdminRequest.createCollection(collectionName, "conf", 2, 1, 0, 3).setMaxShardsPerNode(100) .process(cluster.getSolrClient()); break; case 1: // Sometimes use v1 API String url = String.format(Locale.ROOT, "%s/admin/collections?action=CREATE&name=%s&collection.configName=%s&numShards=%s&pullReplicas=%s&maxShardsPerNode=%s", cluster.getRandomJetty(random()).getBaseUrl(), collectionName, "conf", 2, // numShards 3, // pullReplicas 100); // maxShardsPerNode url = url + pickRandom("", "&nrtReplicas=1", "&replicationFactor=1"); // These options should all mean the same HttpGet createCollectionGet = new HttpGet(url); cluster.getSolrClient().getHttpClient().execute(createCollectionGet); break; case 2: // Sometimes use V2 API url = cluster.getRandomJetty(random()).getBaseUrl().toString() + "/____v2/c"; String requestBody = String.format(Locale.ROOT, "{create:{name:%s, config:%s, numShards:%s, pullReplicas:%s, maxShardsPerNode:%s %s}}", collectionName, "conf", 2, // numShards 3, // pullReplicas 100, // maxShardsPerNode pickRandom("", ", nrtReplicas:1", ", replicationFactor:1")); // These options should all mean the same HttpPost createCollectionPost = new HttpPost(url); createCollectionPost.setHeader("Content-type", "application/json"); createCollectionPost.setEntity(new StringEntity(requestBody)); HttpResponse httpResponse = cluster.getSolrClient().getHttpClient().execute(createCollectionPost); assertEquals(200, httpResponse.getStatusLine().getStatusCode()); break; } boolean reloaded = false; while (true) { DocCollection docCollection = getCollectionState(collectionName); assertNotNull(docCollection); assertEquals("Expecting 4 relpicas per shard", 8, docCollection.getReplicas().size()); assertEquals("Expecting 6 pull replicas, 3 per shard", 6, docCollection.getReplicas(EnumSet.of(Replica.Type.PULL)).size()); assertEquals("Expecting 2 writer replicas, one per shard", 2, docCollection.getReplicas(EnumSet.of(Replica.Type.NRT)).size()); for (Slice s : docCollection.getSlices()) { // read-only replicas can never become leaders assertFalse(s.getLeader().getType() == Replica.Type.PULL); List<String> shardElectionNodes = cluster.getZkClient().getChildren( ZkStateReader.getShardLeadersElectPath(collectionName, s.getName()), null, true); assertEquals("Unexpected election nodes for Shard: " + s.getName() + ": " + Arrays.toString(shardElectionNodes.toArray()), 1, shardElectionNodes.size()); } assertUlogPresence(docCollection); if (reloaded) { break; } else { // reload CollectionAdminResponse response = CollectionAdminRequest.reloadCollection(collectionName) .process(cluster.getSolrClient()); assertEquals(0, response.getStatus()); reloaded = true; } } } finally { zkClient().printLayoutToStdOut(); } }
From source file:android.net.ProxyInfo.java
private void setExclusionList(String exclusionList) { mExclusionList = exclusionList;/*from w w w . j av a 2 s .c o m*/ if (mExclusionList == null) { mParsedExclusionList = new String[0]; } else { mParsedExclusionList = exclusionList.toLowerCase(Locale.ROOT).split(","); } }
From source file:com.puppycrawl.tools.checkstyle.MainTest.java
@Test public void testNonExistingOutputFormat() throws Exception { exit.expectSystemExitWithStatus(-1); exit.checkAssertionAfterwards(new Assertion() { @Override/*from ww w . j a v a 2 s . co m*/ public void checkAssertion() { assertEquals( String.format(Locale.ROOT, "Invalid output format. " + "Found 'xmlp' but expected 'plain' or 'xml'.%n"), systemOut.getLog()); assertEquals("", systemErr.getLog()); } }); Main.main("-c", "/google_checks.xml", "-f", "xmlp", "src/test/resources/com/puppycrawl/tools/checkstyle/InputMain.java"); }
From source file:net.sf.yal10n.analyzer.ExploratoryEncodingTest.java
/** * Test to load a resource bundle from a BOM encoded file that starts with a blank line. * @throws Exception any error//from w ww .jav a 2s . com */ @Test public void testResourceBundleWithBOMandBlankLine() throws Exception { ResourceBundle bundle = PropertyResourceBundle.getBundle("UTF8BOMwithBlankLine", Locale.ROOT); Assert.assertEquals(4, bundle.keySet().size()); 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:fi.ilmoeuro.membertrack.membership.MembershipsPageModel.java
@Override public void loadState(Function<String, @Nullable String> getValue) { setCurrentPage(NumberUtils.toInt(getValue.apply("page"), 1)); refresh();//from w w w .java 2s. c o m String selected = getValue.apply("selected"); String editor = getValue.apply("editor"); String search = getValue.apply("search"); if (selected != null) { for (Membership ms : membershipBrowser.getMemberships()) { if (ms.getPerson().getEmail().equals(selected)) { setMembership(ms); } } } if (editor != null) { try { Editor enumValue = Editor.valueOf(editor.toUpperCase(Locale.ROOT)); setCurrentEditor(enumValue); } catch (IllegalArgumentException ex) { log.error("Invalid Editor enum value: {}", editor); } } if (search != null) { membershipBrowser.setSearchString(search); membershipBrowser.refresh(); } }