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.html.HtmlArea.java

/**
 * Indicates if this area contains the specified point.
 * @param x the x coordinate of the point
 * @param y the y coordinate of the point
 * @return {@code true} if the point is contained in this area
 *///  www  . j ava  2  s .com
boolean containsPoint(final int x, final int y) {
    final String shape = StringUtils.defaultIfEmpty(getShapeAttribute(), "rect").toLowerCase(Locale.ROOT);

    if ("default".equals(shape) && getCoordsAttribute() != null) {
        return true;
    }

    if ("rect".equals(shape) && getCoordsAttribute() != null) {
        final Rectangle2D rectangle = parseRect();
        return rectangle.contains(x, y);
    }

    if ("circle".equals(shape) && getCoordsAttribute() != null) {
        final Ellipse2D ellipse = parseCircle();
        return ellipse.contains(x, y);
    }

    if ("poly".equals(shape) && getCoordsAttribute() != null) {
        final GeneralPath path = parsePoly();
        return path.contains(x, y);
    }

    return false;
}

From source file:org.elasticsearch.xpack.security.transport.ssl.SslIntegrationTests.java

private String getNodeUrl() {
    TransportAddress transportAddress = randomFrom(
            internalCluster().getInstance(HttpServerTransport.class).boundAddress().boundAddresses());
    final InetSocketAddress inetSocketAddress = transportAddress.address();
    return String.format(Locale.ROOT, "https://%s/", NetworkAddress.format(inetSocketAddress));
}

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./*ww  w  . ja v  a 2s . c o m*/
 *
 * Expects error because super nasty Jackson doesn't even call the
 * {@link eu.trentorise.opendata.commons.jackson.TodCommonsModule.LocaleDeserializer}
 * Sic...
 *
 * @since 1.1.0
 */
@Test(expected = AssertionError.class)
public void testNullLocaleDeser() throws JsonProcessingException, IOException {
    RootLocale rootLocale = new RootLocale();
    rootLocale.locale = null;
    String json = objectMapper.writeValueAsString(rootLocale);
    LOG.log(Level.FINE, "json = {0}", json);
    RootLocale res = objectMapper.readValue(json, RootLocale.class);
    assertEquals(Locale.ROOT, res.locale);
}

From source file:com.gargoylesoftware.htmlunit.xml.XmlUtil.java

private static DomNode createFrom(final SgmlPage page, final Node source, final boolean handleXHTMLAsHTML) {
    if (source.getNodeType() == Node.TEXT_NODE) {
        return new DomText(page, source.getNodeValue());
    }//from  w  w  w.j a  v  a 2 s.c  o m
    if (source.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) {
        return new DomProcessingInstruction(page, source.getNodeName(), source.getNodeValue());
    }
    if (source.getNodeType() == Node.COMMENT_NODE) {
        return new DomComment(page, source.getNodeValue());
    }
    if (source.getNodeType() == Node.DOCUMENT_TYPE_NODE) {
        final DocumentType documentType = (DocumentType) source;
        return new DomDocumentType(page, documentType.getName(), documentType.getPublicId(),
                documentType.getSystemId());
    }
    final String ns = source.getNamespaceURI();
    String localName = source.getLocalName();
    if (handleXHTMLAsHTML && HTMLParser.XHTML_NAMESPACE.equals(ns)) {
        final ElementFactory factory = HTMLParser.getFactory(localName);
        return factory.createElementNS(page, ns, localName,
                namedNodeMapToSaxAttributes(source.getAttributes()));
    }
    final NamedNodeMap nodeAttributes = source.getAttributes();
    if (page != null && page.isHtmlPage()) {
        localName = localName.toUpperCase(Locale.ROOT);
    }
    final String qualifiedName;
    if (source.getPrefix() == null) {
        qualifiedName = localName;
    } else {
        qualifiedName = source.getPrefix() + ':' + localName;
    }

    final String namespaceURI = source.getNamespaceURI();
    if (HTMLParser.SVG_NAMESPACE.equals(namespaceURI)) {
        return HTMLParser.SVG_FACTORY.createElementNS(page, namespaceURI, qualifiedName,
                namedNodeMapToSaxAttributes(nodeAttributes));
    }

    final Map<String, DomAttr> attributes = new LinkedHashMap<>();
    for (int i = 0; i < nodeAttributes.getLength(); i++) {
        final Attr attribute = (Attr) nodeAttributes.item(i);
        final String attributeNamespaceURI = attribute.getNamespaceURI();
        final String attributeQualifiedName;
        if (attribute.getPrefix() != null) {
            attributeQualifiedName = attribute.getPrefix() + ':' + attribute.getLocalName();
        } else {
            attributeQualifiedName = attribute.getLocalName();
        }
        final String value = attribute.getNodeValue();
        final boolean specified = attribute.getSpecified();
        final DomAttr xmlAttribute = new DomAttr(page, attributeNamespaceURI, attributeQualifiedName, value,
                specified);
        attributes.put(attribute.getNodeName(), xmlAttribute);
    }
    return new DomElement(namespaceURI, qualifiedName, page, attributes);
}

From source file:net.sf.yal10n.analyzer.ExploratoryEncodingTest.java

/**
 * Test to load a resource bundle via Spring's message source when the file is
 * encoded with a BOM.//from   w w w  . jav  a 2 s. c  o  m
 * @throws Exception any error
 */
@Test
public void testSpringMessageSourceBOMDefault() throws Exception {
    ReloadableResourceBundleMessageSource source = new ReloadableResourceBundleMessageSource();
    source.setBasename("UTF8BOM");
    source.setDefaultEncoding("UTF-8");
    source.setFallbackToSystemLocale(false);

    // Assert.assertEquals("first key", source.getMessage("testkey1", null, Locale.ROOT));
    // note: utf-8 bom read as first character
    Assert.assertEquals("first key", source.getMessage("\ufefftestkey1", null, Locale.ROOT));
    Assert.assertEquals("second key", source.getMessage("testkey2", null, Locale.ROOT));
    Assert.assertEquals("This file is encoded as UTF-8 with BOM .",
            source.getMessage("description", null, Locale.ROOT));
}

From source file:ch.cyberduck.core.ftp.FTPClient.java

/**
 * Query the server for a supported feature, and returns its values (if any).
 * Caches the parsed response to avoid resending the command repeatedly.
 *
 * @return if the feature is present, returns the feature values (empty array if none)
 * Returns {@code null} if the feature is not found or the command failed.
 * Check {@link #getReplyCode()} or {@link #getReplyString()} if so.
 * @throws IOException// www .  j a  v  a2  s. c o  m
 * @since 3.0
 */
public String[] featureValues(String feature) throws IOException {
    if (!initFeatureMap()) {
        return null;
    }
    Set<String> entries = features.get(feature.toUpperCase(Locale.ROOT));
    if (entries != null) {
        return entries.toArray(new String[entries.size()]);
    }
    return null;
}

From source file:business.security.control.OwmClient.java

/**
 * Find current weather within a circle// w ww  .j  a  v  a 2  s .c om
 *
 * @param lat is the latitude of the geographic center of the circle
 * (North/South coordinate)
 * @param lon is the longitude of the geographic center of the circle
 * (East/West coordinate)
 * @param radius is the radius of the circle (in kilometres)
 * @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 currentWeatherInCircle(float lat, float lon, float radius)
        throws IOException, JSONException { //, boolean cluster, OwmClient.Lang lang) {
    String subUrl = String.format(Locale.ROOT, "find/station?lat=%f&lon=%f&radius=%f&cluster=yes",
            Float.valueOf(lat), Float.valueOf(lon), Float.valueOf(radius));
    JSONObject response = doQuery(subUrl);
    return new WeatherStatusResponse(response);
}

From source file:com.gargoylesoftware.htmlunit.javascript.host.html.HTMLImageElement.java

/**
 * Sets the value of the {@code align} property.
 * @param align the value of the {@code align} property
 *//*from  w ww.j  a  va2 s  . c o  m*/
@JsxSetter
public void setAlign(final String align) {
    final boolean acceptArbitraryValues = getBrowserVersion().hasFeature(JS_ALIGN_ACCEPTS_ARBITRARY_VALUES);
    if (acceptArbitraryValues) {
        getDomNodeOrDie().setAttribute("align", align);
        return;
    }

    final String normalizedValue = NORMALIZED_ALIGN_VALUES.get(align.toLowerCase(Locale.ROOT));
    if (null != normalizedValue) {
        getDomNodeOrDie().setAttribute("align", normalizedValue);
        return;
    }

    throw Context.reportRuntimeError("Cannot set the align property to invalid value: '" + align + "'");
}

From source file:com.puppycrawl.tools.checkstyle.TreeWalkerTest.java

@Test
public void testCacheFileChangeInConfig() throws Exception {
    final DefaultConfiguration checkConfig = createCheckConfig(HiddenFieldCheck.class);

    final DefaultConfiguration treeWalkerConfig = createCheckConfig(TreeWalker.class);
    treeWalkerConfig.addAttribute("cacheFile", temporaryFolder.newFile().getPath());
    treeWalkerConfig.addChild(checkConfig);

    final DefaultConfiguration checkerConfig = new DefaultConfiguration("configuration");
    checkerConfig.addAttribute("charset", "UTF-8");
    checkerConfig.addChild(treeWalkerConfig);

    Checker checker = new Checker();
    final Locale locale = Locale.ROOT;
    checker.setLocaleCountry(locale.getCountry());
    checker.setLocaleLanguage(locale.getLanguage());
    checker.setModuleClassLoader(Thread.currentThread().getContextClassLoader());
    checker.configure(checkerConfig);/*ww  w  .j a v  a 2  s . c o  m*/
    checker.addListener(new BriefLogger(stream));

    final String pathToEmptyFile = temporaryFolder.newFile("file.java").getPath();
    final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY;

    verify(checker, pathToEmptyFile, pathToEmptyFile, expected);

    // update Checker config
    //checker.destroy();
    //checker.configure(checkerConfig);

    Checker otherChecker = new Checker();
    otherChecker.setLocaleCountry(locale.getCountry());
    otherChecker.setLocaleLanguage(locale.getLanguage());
    otherChecker.setModuleClassLoader(Thread.currentThread().getContextClassLoader());
    otherChecker.configure(checkerConfig);
    otherChecker.addListener(new BriefLogger(stream));
    // here is diff with previous checker
    checkerConfig.addAttribute("fileExtensions", "java,javax");

    // one more time on updated config
    verify(otherChecker, pathToEmptyFile, pathToEmptyFile, expected);
}

From source file:net.pms.util.BasicThreadFactory.java

@Override
public Thread newThread(Runnable runnable) {
    String threadName;/*from  w  w  w  . ja va2 s  .c o  m*/
    switch (numVariables) {
    case 0:
        threadName = namePattern;
        break;
    case 1:
        threadName = String.format(Locale.ROOT, namePattern, threadNumber.getAndIncrement());
        break;
    default:
        threadName = String.format(Locale.ROOT, namePattern, instancePoolNumber,
                threadNumber.getAndIncrement());
    }
    Thread thread = new Thread(group, runnable, threadName, 0);
    if (thread.isDaemon()) {
        thread.setDaemon(false);
    }
    if (thread.getPriority() != threadPriority) {
        thread.setPriority(threadPriority);
    }
    return thread;
}