Example usage for java.util Locale ROOT

List of usage examples for java.util Locale ROOT

Introduction

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

Prototype

Locale ROOT

To view the source code for java.util Locale ROOT.

Click Source Link

Document

Useful constant for the root locale.

Usage

From source file:com.gargoylesoftware.htmlunit.activex.javascript.msxml.MSXMLActiveXObjectFactory.java

/**
 * Indicates whether the ActiveX name is one flavor of XMLHTTPRequest.
 * @param name the ActiveX name/* ww  w.j  av a 2s .co  m*/
 * @return {@code true} if this is an XMLHTTPRequest
 */
static boolean isXMLHTTPRequest(String name) {
    if (name == null) {
        return false;
    }
    name = name.toLowerCase(Locale.ROOT);
    return "microsoft.xmlhttp".equals(name) || name.startsWith("msxml2.xmlhttp");
}

From source file:org.apache.calcite.adapter.elasticsearch.ElasticSearchAdapterTest.java

/**
 * Used to create {@code zips} index and insert zip data in bulk.
 * @throws Exception when instance setup failed
 *//*from w  ww  .  ja v  a  2 s .  c  om*/
@BeforeClass
public static void setupInstance() throws Exception {
    // hardcoded mapping definition
    final String mapping = String.format(Locale.ROOT,
            "{'mappings':{'%s':{'properties':"
                    + "{'city':{'type':'keyword'},'state':{'type':'keyword'},'pop':{'type':'long'}}" + "}}}",
            ZIPS).replace('\'', '"');

    // create index and mapping
    final HttpEntity entity = new StringEntity(mapping, ContentType.APPLICATION_JSON);
    NODE.restClient().performRequest("PUT", "/" + ZIPS, Collections.emptyMap(), entity);

    // load records from file
    final List<String> bulk = new ArrayList<>();
    Resources.readLines(ElasticSearchAdapterTest.class.getResource("/zips-mini.json"), StandardCharsets.UTF_8,
            new LineProcessor<Void>() {
                @Override
                public boolean processLine(String line) throws IOException {
                    bulk.add("{\"index\": {} }"); // index/type will be derived from _bulk URI
                    line = line.replaceAll("_id", "id"); // _id is a reserved attribute in ES
                    bulk.add(line);
                    return true;
                }

                @Override
                public Void getResult() {
                    return null;
                }
            });

    if (bulk.isEmpty()) {
        throw new IllegalStateException("No records to index. Empty file ?");
    }

    final String uri = String.format(Locale.ROOT, "/%s/%s/_bulk?refresh", ZIPS, ZIPS);
    Response response = NODE.restClient().performRequest("POST", uri, Collections.emptyMap(),
            new StringEntity(String.join("\n", bulk) + "\n", ContentType.APPLICATION_JSON));

    if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
        final String error = EntityUtils.toString(response.getEntity());
        final String message = String.format(Locale.ROOT,
                "Couldn't bulk insert %d elements into %s (%s/%s). Error was %s\n%s\n", bulk.size(), ZIPS,
                response.getHost(), response.getRequestLine(), response.getStatusLine(), error);

        throw new IllegalStateException(message);
    }

}

From source file:com.zuoxiaolong.niubi.job.persistent.hibernate.HibernateNamingStrategy.java

private static String addUnderscores(String name) {
    StringBuilder buf = new StringBuilder(name.replace('.', '_'));
    for (int i = 1; i < buf.length() - 1; i++) {
        if (Character.isLowerCase(buf.charAt(i - 1)) && Character.isUpperCase(buf.charAt(i))
                && Character.isLowerCase(buf.charAt(i + 1))) {
            buf.insert(i++, '_');
        }/* w ww  .  j  ava 2 s.  co m*/
    }
    return buf.toString().toLowerCase(Locale.ROOT);
}

From source file:org.elasticsearch.integration.AbstractPrivilegeTestCase.java

protected void assertAccessIsAllowed(String user, String method, String uri, String body,
        Map<String, String> params) throws IOException {
    Response response = getRestClient().performRequest(method, uri, params, entityOrNull(body), new BasicHeader(
            UsernamePasswordToken.BASIC_AUTH_HEADER,
            UsernamePasswordToken.basicAuthHeaderValue(user, new SecureString("passwd".toCharArray()))));
    StatusLine statusLine = response.getStatusLine();
    String message = String.format(Locale.ROOT, "%s %s: Expected no error got %s %s with body %s", method, uri,
            statusLine.getStatusCode(), statusLine.getReasonPhrase(),
            EntityUtils.toString(response.getEntity()));
    assertThat(message, statusLine.getStatusCode(), is(not(greaterThanOrEqualTo(400))));
}

From source file:eu.trentorise.opendata.commons.TodUtils.java

/**
 * Converts a language code to Java Locale. On null input returns
 * {@link Locale#ROOT}/*from ww w .j  a  v  a 2 s  .  com*/
 * 
 * Notice Java 7 introduced {@link Locale#forLanguageTag(String)}, but that
 * method throws null pointer exception on null string, which unfortunately
 * can happen quite often, so we use this method instead.
 * 
 * @see Locale#forLanguageTag(String)
 * @see #localeToLanguageTag(Locale) localeToLanguageTag(Locale) for the inverse operation
 */
public static Locale languageTagToLocale(@Nullable String languageTag) {

    if (languageTag == null) {
        LOG.warning("Found null locale, returning Locale.ROOT");
        return Locale.ROOT;
    }
    return Locale.forLanguageTag(languageTag);
}

From source file:rbcp.PropertiesResourceBundleControl.java

@Override
public List<Locale> getCandidateLocales(String baseName, Locale locale) {
    if (baseName == null)
        throw new NullPointerException();
    if (locale.equals(new Locale("zh", "HK"))) {
        return Arrays.asList(locale, Locale.TAIWAN,
                // no Locale.CHINESE here
                Locale.ROOT);
    } else if (locale.equals(Locale.TAIWAN)) {
        return Arrays.asList(locale,
                // no Locale.CHINESE here
                Locale.ROOT);//from w ww.j  a v a 2s  .com
    }
    return super.getCandidateLocales(baseName, locale);
}

From source file:com.assignmentone.Asta4DSampleServlet.java

@Override
public void init(ServletConfig config) throws ServletException {
    // for a international application, we use root as default locale
    Locale.setDefault(Locale.ROOT);
    super.init(config);
}

From source file:com.grayfox.server.dao.CategoryDaoTest.java

@Test
@Transactional//from www.  j a v  a 2  s.co  m
public void testFetchLikeName() {
    Category c1 = new Category();
    c1.setFoursquareId("4bf58dd8d48988d188941735");
    c1.setIconUrl("https://ss3.4sqi.net/img/categories_v2/arts_entertainment/default_88.png");
    c1.setName("Estadio de ftbol");

    Category c2 = new Category();
    c2.setFoursquareId("4bf58dd8d48988d18c941735");
    c2.setIconUrl("https://ss3.4sqi.net/img/categories_v2/arts_entertainment/default_88.png");
    c2.setName("Estadio de bisbol");

    List<Category> expectedCategories = Arrays.asList(c1, c2);

    assertThat(categoryDao.findByPartialName("estadio", Locale.ROOT)).isNotNull().isNotEmpty()
            .usingElementComparatorIgnoringFields("id").containsOnlyElementsOf(expectedCategories);
}

From source file:Main.java

private static String doFormatDate(Calendar calendar) {
    return String.format(Locale.ROOT, "%04d-%02d-%02dT%02d:%02d:%02dZ", calendar.get(Calendar.YEAR),
            calendar.get(Calendar.MONTH) + 1, calendar.get(Calendar.DAY_OF_MONTH),
            calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), calendar.get(Calendar.SECOND));
}

From source file:communication.WeatherService.java

/** Find current weather at the given geographic point.
 * /* w w w.  j ava2 s.  com*/
 * @param lat
 * @param lon
 * @return
 * @throws IOException
 * @throws JSONException
 */
public Weather currentWeatherAtCoords(float lat, float lon) {
    try {
        String subUrl = String.format(Locale.ROOT, "weather?lat=%f&lon=%f", Float.valueOf(lat),
                Float.valueOf(lon));
        JSONObject response = doQuery(subUrl);
        return new Weather(response);
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}