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.puppycrawl.tools.checkstyle.MainTest.java

@Test
public void testExistingTargetFilePlainOutput() throws Exception {

    exit.checkAssertionAfterwards(new Assertion() {
        @Override/* w w  w .  jav  a  2s.  c o  m*/
        public void checkAssertion() {
            assertEquals(String.format(Locale.ROOT, "Starting audit...%n" + "Audit done.%n"),
                    systemOut.getLog());
            assertEquals("", systemErr.getLog());
        }
    });
    Main.main("-c", "src/test/resources/com/puppycrawl/tools/checkstyle/config-classname.xml", "-f", "plain",
            "src/test/resources/com/puppycrawl/tools/checkstyle/InputMain.java");
}

From source file:org.apache.solr.util.SolrCLI.java

public static Tool findTool(String[] args) throws Exception {
    String toolType = args[0].trim().toLowerCase(Locale.ROOT);
    return newTool(toolType);
}

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

/**
 * The "facts" for a file in a reply to a MLSx command consist of
 * information about that file.  The facts are a series of keyword=value
 * pairs each followed by semi-colon (";") characters.  An individual
 * fact may not contain a semi-colon in its name or value.  The complete
 * series of facts may not contain the space character.  See the
 * definition or "RCHAR" in section 2.1 for a list of the characters
 * that can occur in a fact value.  Not all are applicable to all facts.
 * <p/>/* w  ww . j a va 2 s  .co  m*/
 * A sample of a typical series of facts would be: (spread over two
 * lines for presentation here only)
 * <p/>
 * size=4161;lang=en-US;modify=19970214165800;create=19961001124534;
 * type=file;x.myfact=foo,bar;
 * <p/>
 * This document defines a standard set of facts as follows:
 * <p/>
 * size       -- Size in octets
 * modify     -- Last modification time
 * create     -- Creation time
 * type       -- Entry type
 * unique     -- Unique id of file/directory
 * perm       -- File permissions, whether read, write, execute is
 * allowed for the login id.
 * lang       -- Language of the file name per IANA [11] registry.
 * media-type -- MIME media-type of file contents per IANA registry.
 * charset    -- Character set per IANA registry (if not UTF-8)
 *
 * @param line The "facts" for a file in a reply to a MLSx command
 * @return Parsed keys and values
 */
protected Map<String, Map<String, String>> parseFacts(final String line) {
    final Pattern p = Pattern.compile("\\s?(\\S+\\=\\S+;)*\\s(.*)");
    final Matcher result = p.matcher(line);
    final Map<String, Map<String, String>> file = new HashMap<String, Map<String, String>>();
    if (result.matches()) {
        final String filename = result.group(2);
        final Map<String, String> facts = new HashMap<String, String>();
        for (String fact : result.group(1).split(";")) {
            String key = StringUtils.substringBefore(fact, "=");
            if (StringUtils.isBlank(key)) {
                continue;
            }
            String value = StringUtils.substringAfter(fact, "=");
            if (StringUtils.isBlank(value)) {
                continue;
            }
            facts.put(key.toLowerCase(Locale.ROOT), value);
        }
        file.put(filename, facts);
        return file;
    }
    log.warn(String.format("No match for %s", line));
    return null;
}

From source file:com.android.talkback.labeling.LabelProvider.java

/**
 * Joins a selection clause with a where clause to form a larger selection
 * clause that represents the AND of the two clauses.
 *
 * @param selection The selection clause.
 * @param where The where clause./* w ww. j  a  v a 2  s .co  m*/
 * @return The joined clause.
 */
private String combineSelectionAndWhere(String selection, final String where) {
    if (TextUtils.isEmpty(where)) {
        return selection;
    } else if (TextUtils.isEmpty(selection)) {
        return where;
    }

    return String.format(Locale.ROOT, "(%s) AND (%s)", where, selection);
}

From source file:org.openscience.cdk.app.DepictController.java

/**
 * Restful entry point.//from ww  w  . ja v  a  2  s . com
 *
 * @param smi      SMILES to depict
 * @param fmt      output format
 * @param style    preset style COW (Color-on-white), COB, BOW, COW
 * @param anon     rendering anonymised graphs
 * @param zoom     zoom factor (1=100%=none)
 * @param annotate annotations to add
 * @param w        width of the image
 * @param h        height of the image
 * @param sma      highlight SMARTS pattern
 * @return the depicted structure
 * @throws CDKException something not okay with input
 * @throws IOException  problem reading/writing request
 */
@RequestMapping("depict/{style}/{fmt}")
public HttpEntity<?> depict(@RequestParam("smi") String smi, @PathVariable("fmt") String fmt,
        @PathVariable("style") String style,
        @RequestParam(value = "suppressh", defaultValue = "true") String suppressh,
        @RequestParam(value = "hdisp", defaultValue = "bridgehead") String hDisplayParam,
        @RequestParam(value = "anon", defaultValue = "off") String anon,
        @RequestParam(value = "zoom", defaultValue = "1.3") double zoom,
        @RequestParam(value = "annotate", defaultValue = "none") String annotate,
        @RequestParam(value = "w", defaultValue = "-1") int w,
        @RequestParam(value = "h", defaultValue = "-1") int h,
        @RequestParam(value = "abbr", defaultValue = "reagents") String abbr,
        @RequestParam(value = "sma", defaultValue = "") String sma,
        @RequestParam(value = "showtitle", defaultValue = "false") boolean showTitle,
        @RequestParam(value = "smalim", defaultValue = "100") int smaLimit,
        @RequestParam(value = "alignrxnmap", defaultValue = "true") boolean alignRxnMap,
        @RequestParam Map<String, String> params) throws CDKException, IOException {

    // backwards compatibility
    HydrogenDisplayType hDisplayType = HydrogenDisplayType.Minimal;
    if ("false".equalsIgnoreCase(suppressh) || "f".equalsIgnoreCase(suppressh)) {
        hDisplayType = HydrogenDisplayType.Provided;
    } else {
        if (hDisplayParam != null) {
            switch (hDisplayParam.toLowerCase()) {
            case "suppressed":
                hDisplayType = HydrogenDisplayType.Minimal;
                break;
            case "provided":
                hDisplayType = HydrogenDisplayType.Provided;
                break;
            case "stereo":
                hDisplayType = HydrogenDisplayType.StereoOnly;
                break;
            case "bridgeheadtetrahedral":
            case "bridgehead":
            case "default":
            case "smart":
                hDisplayType = HydrogenDisplayType.BridgeHeadTetrahedralOnly;
                break;
            }
        }
    }

    // Note: DepictionGenerator is immutable
    DepictionGenerator myGenerator = generator.withSize(w, h).withZoom(zoom);

    // Configure style preset
    myGenerator = withStyle(myGenerator, style);

    myGenerator = myGenerator.withAnnotationScale(0.7).withAnnotationColor(Color.RED);

    // align rxn maps
    myGenerator = myGenerator.withMappedRxnAlign(alignRxnMap);

    // Improved depiction of anatomised graphs, e.g. ***1*****1**
    if (anon.equalsIgnoreCase("on")) {
        myGenerator = myGenerator.withParam(Visibility.class, new SymbolVisibility() {
            @Override
            public boolean visible(IAtom iAtom, List<IBond> list, RendererModel rendererModel) {
                return list.isEmpty();
            }
        });
    }

    final boolean isRxn = !smi.contains("V2000") && isRxnSmi(smi);
    final boolean isRgp = smi.contains("RG:");
    IReaction rxn = null;
    IAtomContainer mol = null;
    List<IAtomContainer> mols = null;

    Set<IChemObject> highlight;

    if (isRxn) {
        rxn = smipar.parseReactionSmiles(smi);
        for (IAtomContainer component : rxn.getReactants().atomContainers())
            setHydrogenDisplay(component, hDisplayType);
        for (IAtomContainer component : rxn.getProducts().atomContainers())
            setHydrogenDisplay(component, hDisplayType);
        for (IAtomContainer component : rxn.getAgents().atomContainers())
            setHydrogenDisplay(component, hDisplayType);
        highlight = findHits(sma, rxn, mol, smaLimit);
        abbreviate(rxn, abbr, annotate);
    } else {
        mol = loadMol(smi);
        setHydrogenDisplay(mol, hDisplayType);
        highlight = findHits(sma, rxn, mol, smaLimit);
        abbreviate(mol, abbr, annotate);
    }

    // Add annotations
    switch (annotate) {
    case "number":
        myGenerator = myGenerator.withAtomNumbers();
        abbr = "false";
        break;
    case "mapidx":
        myGenerator = myGenerator.withAtomMapNumbers();
        break;
    case "atomvalue":
        myGenerator = myGenerator.withAtomValues();
        break;
    case "colmap":
        myGenerator = myGenerator.withAtomMapHighlight(
                new Color[] { new Color(169, 199, 255), new Color(185, 255, 180), new Color(255, 162, 162),
                        new Color(253, 139, 255), new Color(255, 206, 86), new Color(227, 227, 227) })
                .withOuterGlowHighlight(6d);
        break;
    case "cip":
        if (isRxn) {
            for (IAtomContainer part : ReactionManipulator.getAllAtomContainers(rxn)) {
                annotateCip(part);
            }
        } else {
            annotateCip(mol);
        }
        break;
    }

    // add highlight from atom/bonds hit by the provided SMARTS
    switch (style) {
    case "nob":
        myGenerator = myGenerator.withHighlight(highlight, new Color(0xffaaaa));
        break;
    case "bow":
    case "wob":
        myGenerator = myGenerator.withHighlight(highlight, new Color(0xff0000));
        break;
    default:
        myGenerator = myGenerator.withHighlight(highlight, new Color(0xaaffaa));
        break;
    }

    if (showTitle) {
        if (isRxn)
            myGenerator = myGenerator.withRxnTitle();
        else
            myGenerator = myGenerator.withMolTitle();
    }

    // pre-render the depiction
    final Depiction depiction = isRxn ? myGenerator.depict(rxn)
            : isRgp ? myGenerator.depict(mols, mols.size(), 1) : myGenerator.depict(mol);

    final String fmtlc = fmt.toLowerCase(Locale.ROOT);
    switch (fmtlc) {
    case Depiction.SVG_FMT:
        return makeResponse(depiction.toSvgStr().getBytes(), "image/svg+xml");
    case Depiction.PDF_FMT:
        return makeResponse(depiction.toPdfStr().getBytes(), "application/pdf");
    case Depiction.PNG_FMT:
    case Depiction.JPG_FMT:
    case Depiction.GIF_FMT:
        ByteArrayOutputStream bao = new ByteArrayOutputStream();
        ImageIO.write(depiction.toImg(), fmtlc, bao);
        return makeResponse(bao.toByteArray(), "image/" + fmtlc);
    }

    throw new IllegalArgumentException("Unsupported format.");
}

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

/**
 * Find current city weather//w ww .ja v a 2  s .  co  m
 *
 * @param cityName is the name of the city
 * @param countryCode is the two letter country code
 * @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 currentWeatherAtCity(String cityName, String countryCode)
        throws IOException, JSONException {
    String subUrl = String.format(Locale.ROOT, "find/name?q=%s,%s", cityName, countryCode.toUpperCase());
    JSONObject response = doQuery(subUrl);
    return new WeatherStatusResponse(response);
}

From source file:com.wormsim.utils.Utils.java

/**
 * Returns the distribution associated with the specified string. See the
 * handbook for details of what is accepted. Or the code...
 *
 * @param str The string representing a distribution
 *
 * @return The distribution/*from  w w w.j  a  va 2s  .  c  o m*/
 */
public static IntegerDistribution readIntegerDistribution(String str) {
    if (str.matches("[0-9]+(.[0-9]*)?")) {
        // I.E. a number
        return new EnumeratedIntegerDistribution(new int[] { Integer.valueOf(str) });
    } else {
        int index = str.indexOf('(');
        String prefix = str.substring(0, index - 1).toLowerCase(Locale.ROOT);
        switch (prefix) {
        case "b":
        case "binom":
        case "binomial": {
            int comma_index = str.indexOf(',', index);
            return new BinomialDistribution(Integer.valueOf(str.substring(index, comma_index - 1)),
                    Double.valueOf(str.substring(comma_index).trim()));
        }
        case "u":
        case "uni":
        case "uniform": {
            int comma_index = str.indexOf(',', index);
            return new UniformIntegerDistribution(Integer.valueOf(str.substring(index, comma_index - 1)),
                    Integer.valueOf(str.substring(comma_index).trim()));
        }
        default: {
            throw new IllegalArgumentException(
                    "Unrecognised distribution form, see handbook for details. " + "Provided \"" + str + "\".");
        }
        }
    }
}

From source file:org.elasticsearch.http.ContextAndHeaderTransportIT.java

private void assertRequestContainsHeader(ActionRequest request, Map<String, String> context) {
    String msg = String.format(Locale.ROOT, "Expected header %s to be in request %s", CUSTOM_HEADER,
            request.getClass().getName());
    if (request instanceof IndexRequest) {
        IndexRequest indexRequest = (IndexRequest) request;
        msg = String.format(Locale.ROOT, "Expected header %s to be in index request %s/%s/%s", CUSTOM_HEADER,
                indexRequest.index(), indexRequest.type(), indexRequest.id());
    }//w  ww .ja  v  a2  s  .  co  m
    assertThat(msg, context.containsKey(CUSTOM_HEADER), is(true));
    assertThat(context.get(CUSTOM_HEADER).toString(), is(randomHeaderValue));
}

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

private boolean initFeatureMap() throws IOException {
    if (features == null) {
        // Don't create map here, because next line may throw exception
        final int reply = feat();
        if (FTPReply.NOT_LOGGED_IN == reply) {
            return false;
        } else {/*from   w w  w . j  a  v a2 s  .  co  m*/
            // we init the map here, so we don't keep trying if we know the command will fail
            features = new HashMap<String, Set<String>>();
        }
        boolean success = FTPReply.isPositiveCompletion(reply);
        if (!success) {
            return false;
        }
        for (String l : getReplyStrings()) {
            if (l.startsWith(" ")) { // it's a FEAT entry
                String key;
                String value = "";
                int varsep = l.indexOf(' ', 1);
                if (varsep > 0) {
                    key = l.substring(1, varsep);
                    value = l.substring(varsep + 1);
                } else {
                    key = l.substring(1);
                }
                key = key.toUpperCase(Locale.ROOT);
                Set<String> entries = features.get(key);
                if (entries == null) {
                    entries = new HashSet<String>();
                    features.put(key, entries);
                }
                entries.add(value);
            }
        }
    }
    return true;
}

From source file:org.jboss.as.test.integration.logging.formatters.JsonFormatterTestCase.java

@Test
public void testDateFormat() throws Exception {
    configure(Collections.emptyMap(), Collections.emptyMap(), false);

    final String dateFormat = "yyyy-MM-dd'T'HH:mm:ssSSSZ";
    final String timezone = "GMT";

    // Change the date format and time zone
    final CompositeOperationBuilder builder = CompositeOperationBuilder.create();
    builder.addStep(Operations.createWriteAttributeOperation(FORMATTER_ADDRESS, "date-format", dateFormat));
    builder.addStep(Operations.createWriteAttributeOperation(FORMATTER_ADDRESS, "zone-id", timezone));
    executeOperation(builder.build());// w w w .  j av a  2s . c  o  m

    final String msg = "Logging test: JsonFormatterTestCase.testNoExceptions";
    int statusCode = getResponse(msg,
            Collections.singletonMap(LoggingServiceActivator.LOG_EXCEPTION_KEY, "false"));
    Assert.assertTrue("Invalid response statusCode: " + statusCode, statusCode == HttpStatus.SC_OK);

    final List<String> expectedKeys = createDefaultKeys();

    for (String s : Files.readAllLines(logFile, StandardCharsets.UTF_8)) {
        if (s.trim().isEmpty())
            continue;
        try (JsonReader reader = Json.createReader(new StringReader(s))) {
            final JsonObject json = reader.readObject();

            validateDefault(json, expectedKeys, msg);
            validateStackTrace(json, false, false);

            // Validate the date format is correct. We don't want to validate the specific date, only that it's
            // parsable.
            final String jsonDate = json.getString("timestamp");
            // If the date is not parsable an exception should be thrown
            try {
                DateTimeFormatter.ofPattern(dateFormat, Locale.ROOT).withZone(ZoneId.of(timezone))
                        .parse(jsonDate);
            } catch (Exception e) {
                Assert.fail(String.format("Failed to parse %s with pattern %s and zone %s: %s", jsonDate,
                        dateFormat, timezone, e.getMessage()));
            }
        }
    }
}