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.gargoylesoftware.htmlunit.javascript.host.xml.XMLSerializer.java
private void toXml(final int indent, final DomNode node, final StringBuilder buffer, final String foredNamespace) { final String nodeName = node.getNodeName(); buffer.append('<').append(nodeName); String optionalPrefix = ""; final String namespaceURI = node.getNamespaceURI(); final String prefix = node.getPrefix(); if (namespaceURI != null && prefix != null) { boolean sameNamespace = false; for (DomNode parentNode = node .getParentNode(); parentNode instanceof DomElement; parentNode = parentNode.getParentNode()) { if (namespaceURI.equals(parentNode.getNamespaceURI())) { sameNamespace = true;/* w ww . ja v a 2 s. com*/ } } if (node.getParentNode() == null || !sameNamespace) { ((DomElement) node).setAttribute("xmlns:" + prefix, namespaceURI); } } else if (foredNamespace != null) { buffer.append(" xmlns=\"").append(foredNamespace).append('"'); optionalPrefix = " "; } final NamedNodeMap attributesMap = node.getAttributes(); for (int i = 0; i < attributesMap.getLength(); i++) { final DomAttr attrib = (DomAttr) attributesMap.item(i); buffer.append(' ').append(attrib.getQualifiedName()).append('=').append('"').append(attrib.getValue()) .append('"'); } boolean startTagClosed = false; for (final DomNode child : node.getChildren()) { if (!startTagClosed) { buffer.append(optionalPrefix).append('>'); startTagClosed = true; } switch (child.getNodeType()) { case Node.ELEMENT_NODE: toXml(indent + 1, child, buffer, null); break; case Node.TEXT_NODE: String value = child.getNodeValue(); value = StringUtils.escapeXmlChars(value); buffer.append(value); break; case Node.CDATA_SECTION_NODE: case Node.COMMENT_NODE: buffer.append(child.asXml()); break; default: } } if (!startTagClosed) { final String tagName = nodeName.toLowerCase(Locale.ROOT); final boolean nonEmptyTagsSupported = getBrowserVersion().hasFeature(JS_XML_SERIALIZER_NON_EMPTY_TAGS); if (nonEmptyTagsSupported && NON_EMPTY_TAGS.contains(tagName)) { buffer.append('>'); buffer.append("</").append(nodeName).append('>'); } else { buffer.append(optionalPrefix); if (buffer.charAt(buffer.length() - 1) != ' ' && getBrowserVersion().hasFeature(JS_XML_SERIALIZER_BLANK_BEFORE_SELF_CLOSING)) { buffer.append(" "); } buffer.append("/>"); } } else { buffer.append('<').append('/').append(nodeName).append('>'); } }
From source file:com.puppycrawl.tools.checkstyle.MainTest.java
@Test public void testExistingTargetFile() throws Exception { exit.checkAssertionAfterwards(new Assertion() { @Override//from w w w. j a v a 2 s .c om 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", "src/test/resources/com/puppycrawl/tools/checkstyle/InputMain.java"); }
From source file:br.com.OCTur.view.InfograficoController.java
private BufferedImage participacao() { DefaultPieDataset dpdDados = new DefaultPieDataset(); hoteis = new ArrayList<>(); for (Hotel hotel : new HotelDAO().pegarTodos()) { List<Reserva> reservas = new ReservaDAO().pegarPorHotelInicioFim(hotel, inicio, fim); double total = 0; for (Reserva reserva : reservas) { long dias = (reserva.getFim().getTime() - reserva.getInicio().getTime()) / 1000 / 60 / 60 / 24; if (dias <= 0) { dias = 1;/*from w ww. ja v a 2 s . c o m*/ } total += (reserva.getQuarto().getOrcamento().getPreco() * dias); } hoteis.add(new EntidadeGrafico<>(hotel, total)); } hoteis.sort((EntidadeGrafico<Hotel> o1, EntidadeGrafico<Hotel> o2) -> Double.compare(o1.getValue(), o2.getValue()) * -1); for (EntidadeGrafico<Hotel> entidadeGrafico : hoteis.subList(0, hoteis.size() > 4 ? 4 : hoteis.size())) { dpdDados.setValue(entidadeGrafico.toString(), entidadeGrafico.getValue()); } if (hoteis.size() > 4) { dpdDados.setValue("Outros", hoteis.subList(4, hoteis.size()).stream().mapToDouble(EntidadeGrafico::getValue).sum()); } JFreeChart jFreeChart = ChartFactory.createRingChart("", dpdDados, true, false, Locale.ROOT); PiePlot piePlot = (PiePlot) jFreeChart.getPlot(); piePlot.setLabelGenerator(new StandardPieSectionLabelGenerator("{2}")); return jFreeChart.createBufferedImage(175, 252); }
From source file:com.puppycrawl.tools.checkstyle.filters.SuppressionCommentFilterTest.java
@Override protected Checker createChecker(Configuration checkConfig) throws CheckstyleException { final DefaultConfiguration checkerConfig = new DefaultConfiguration("configuration"); final DefaultConfiguration checksConfig = createCheckConfig(TreeWalker.class); checksConfig.addChild(createCheckConfig(FileContentsHolder.class)); checksConfig.addChild(createCheckConfig(MemberNameCheck.class)); checksConfig.addChild(createCheckConfig(ConstantNameCheck.class)); checksConfig.addChild(createCheckConfig(IllegalCatchCheck.class)); checkerConfig.addChild(checksConfig); if (checkConfig != null) { checkerConfig.addChild(checkConfig); }/*from w ww . j a v a 2s .co m*/ final 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); checker.addListener(new BriefLogger(stream)); return checker; }
From source file:com.msopentech.thali.utilities.xmlhttprequestbridge.Bridge.java
private String ProxyRequest(XmlHttpRequest xmlHttpRequest) throws UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException, URISyntaxException, IOException { HttpKeyURL remoteServerThaliUrl = new HttpKeyURL(xmlHttpRequest.url); BasicHttpEntityEnclosingRequest basicHttpRequest = new BasicHttpEntityEnclosingRequest( xmlHttpRequest.method, remoteServerThaliUrl.createHttpsUrl()); for (Map.Entry<String, String> entry : xmlHttpRequest.headers.entrySet()) { // TODO: Test with multiple incoming headers with the same name basicHttpRequest.setHeader(entry.getKey(), entry.getValue()); }/*from w w w . ja v a2s .c om*/ if (xmlHttpRequest.requestText != null && xmlHttpRequest.requestText.isEmpty() == false) { StringEntity stringEntity = new StringEntity(xmlHttpRequest.requestText); basicHttpRequest.setEntity(stringEntity); } HttpHost httpHost = new HttpHost(remoteServerThaliUrl.getHost(), remoteServerThaliUrl.getPort(), "https"); HttpClient httpClient = createClientBuilder.CreateApacheClient(remoteServerThaliUrl, keyStore, ThaliCryptoUtilities.DefaultPassPhrase); HttpResponse httpResponse = httpClient.execute(httpHost, basicHttpRequest); XmlHttpResponse xmlHttpResponse = new XmlHttpResponse(); xmlHttpResponse.transactionId = xmlHttpRequest.transactionId; xmlHttpResponse.status = httpResponse.getStatusLine().getStatusCode(); for (Header header : httpResponse.getAllHeaders()) { String lowerCaseHeaderValue = header.getName().toLowerCase(Locale.ROOT); xmlHttpResponse.headers.put(lowerCaseHeaderValue, xmlHttpResponse.headers.containsValue(lowerCaseHeaderValue) ? xmlHttpResponse.headers.get(lowerCaseHeaderValue) + " , " + header.getValue() : header.getValue()); } if (httpResponse.getEntity() != null) { // TODO: Obvious attack, just send us a huge response and we go kaboom! Or hold up the connection. Etc. // I'm sure there are other fun things too. Lots of hardening needed here. xmlHttpResponse.responseText = IOUtils.toString(httpResponse.getEntity().getContent()); } return mapper.writeValueAsString(xmlHttpResponse); }
From source file:ch.cyberduck.core.ftp.FTPClient.java
/** * Query the server for a supported feature. * Caches the parsed response to avoid resending the command repeatedly. * * @param feature the name of the feature; it is converted to upper case. * @return {@code true} if the feature is present, {@code false} if the feature is not present * or the {@link #feat()} command failed. Check {@link #getReplyCode()} or {@link #getReplyString()} * if it is necessary to distinguish these cases. * @throws IOException/* w ww . j av a2 s . c o m*/ * @since 3.0 */ public boolean hasFeature(String feature) throws IOException { if (!initFeatureMap()) { return false; } return features.containsKey(feature.toUpperCase(Locale.ROOT)); }
From source file:com.searchbox.framework.web.SystemController.java
@ModelAttribute("systemInfo") private Map<String, Object> getSystemInfo() { Map<String, Object> info = new HashMap<String, Object>(); OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean(); info.put("name", os.getName()); info.put("version", os.getVersion()); info.put("arch", os.getArch()); info.put("systemLoadAverage", os.getSystemLoadAverage()); // com.sun.management.OperatingSystemMXBean addGetterIfAvaliable(os, "committedVirtualMemorySize", info); addGetterIfAvaliable(os, "freePhysicalMemorySize", info); addGetterIfAvaliable(os, "freeSwapSpaceSize", info); addGetterIfAvaliable(os, "processCpuTime", info); addGetterIfAvaliable(os, "totalPhysicalMemorySize", info); addGetterIfAvaliable(os, "totalSwapSpaceSize", info); // com.sun.management.UnixOperatingSystemMXBean addGetterIfAvaliable(os, "openFileDescriptorCount", info); addGetterIfAvaliable(os, "maxFileDescriptorCount", info); try {/*w ww . j a va 2 s. com*/ if (!os.getName().toLowerCase(Locale.ROOT).startsWith("windows")) { // Try some command line things info.put("uname", execute("uname -a")); info.put("uptime", execute("uptime")); } } catch (Exception ex) { ex.printStackTrace(); } return info; }
From source file:net.pms.dlna.protocolinfo.MimeType.java
@Override public boolean equals(Object obj) { if (this == obj) { return true; }//from ww w. ja va2 s . co m if (obj == null) { return false; } if (!(obj instanceof MimeType)) { return false; } MimeType other = (MimeType) obj; if (parameters == null) { if (other.parameters != null) { return false; } } else if (!parameters.equals(other.parameters)) { return false; } if (subtype == null) { if (other.subtype != null) { return false; } } else if (other.subtype == null) { return false; } else if (!subtype.toLowerCase(Locale.ROOT).equals(other.subtype.toLowerCase(Locale.ROOT))) { return false; } if (type == null) { if (other.type != null) { return false; } } else if (other.type == null) { return false; } else if (!type.toLowerCase(Locale.ROOT).equals(other.type.toLowerCase(Locale.ROOT))) { return false; } return true; }
From source file:net.pms.util.AudioUtils.java
/** * Parses the old RealAudio 1.0 and 2.0 formats that's not supported by * neither {@link org.jaudiotagger} nor MediaInfo. Returns {@code false} if * {@code channel} isn't one of these formats or the parsing fails. * <p>//from ww w .j a v a 2s . c om * Primary references: * <ul> * <li><a href="https://wiki.multimedia.cx/index.php/RealMedia">RealAudio on * MultimediaWiki</a></li> * <li><a * href="https://github.com/FFmpeg/FFmpeg/blob/master/libavformat/rmdec.c" * >FFmpeg rmdec.c</a></li> * </ul> * * @param channel the {@link Channel} containing the input. Size will only * be parsed if {@code channel} is a {@link FileChannel} * instance. * @param media the {@link DLNAMediaInfo} instance to write the parsing * results to. * @return {@code true} if the {@code channel} input is in RealAudio 1.0 or * 2.0 format and the parsing succeeds; false otherwise */ public static boolean parseRealAudio(ReadableByteChannel channel, DLNAMediaInfo media) { final byte[] magicBytes = { 0x2E, 0x72, 0x61, (byte) 0xFD }; ByteBuffer buffer = ByteBuffer.allocate(8); buffer.order(ByteOrder.BIG_ENDIAN); DLNAMediaAudio audio = new DLNAMediaAudio(); try { int count = channel.read(buffer); if (count < 4) { LOGGER.trace("Input is too short to be RealAudio"); return false; } buffer.flip(); byte[] signature = new byte[4]; buffer.get(signature); if (!Arrays.equals(magicBytes, signature)) { if (LOGGER.isTraceEnabled()) { LOGGER.trace("Input signature ({}) mismatches RealAudio version 1.0 or 2.0", new String(signature, StandardCharsets.US_ASCII)); } return false; } media.setContainer(FormatConfiguration.RA); short version = buffer.getShort(); int reportedHeaderSize = 0; int reportedDataSize = 0; if (version == 3) { audio.setCodecA(FormatConfiguration.REALAUDIO_14_4); audio.getAudioProperties().setNumberOfChannels(1); audio.getAudioProperties().setSampleFrequency(8000); short headerSize = buffer.getShort(); buffer = ByteBuffer.allocate(headerSize); channel.read(buffer); buffer.flip(); buffer.position(8); int bytesPerMinute = buffer.getShort() & 0xFFFF; reportedDataSize = buffer.getInt(); byte b = buffer.get(); if (b != 0) { byte[] title = new byte[b & 0xFF]; buffer.get(title); String titleString = new String(title, StandardCharsets.US_ASCII); audio.setSongname(titleString); audio.setAudioTrackTitleFromMetadata(titleString); } b = buffer.get(); if (b != 0) { byte[] artist = new byte[b & 0xFF]; buffer.get(artist); audio.setArtist(new String(artist, StandardCharsets.US_ASCII)); } audio.setBitRate(bytesPerMinute * 8 / 60); media.setBitrate(bytesPerMinute * 8 / 60); } else if (version == 4 || version == 5) { buffer = ByteBuffer.allocate(14); channel.read(buffer); buffer.flip(); buffer.get(signature); if (!".ra4".equals(new String(signature, StandardCharsets.US_ASCII))) { LOGGER.debug("Invalid RealAudio 2.0 signature \"{}\"", new String(signature, StandardCharsets.US_ASCII)); return false; } reportedDataSize = buffer.getInt(); buffer.getShort(); //skip version repeated reportedHeaderSize = buffer.getInt(); buffer = ByteBuffer.allocate(reportedHeaderSize); channel.read(buffer); buffer.flip(); buffer.getShort(); // skip codec flavor buffer.getInt(); // skip coded frame size buffer.getInt(); // skip unknown long bytesPerMinute = buffer.getInt() & 0xFFFFFFFFL; buffer.getInt(); // skip unknown buffer.getShort(); // skip sub packet buffer.getShort(); // skip frame size buffer.getShort(); // skip sub packet size buffer.getShort(); // skip unknown if (version == 5) { buffer.position(buffer.position() + 6); // skip unknown } short sampleRate = buffer.getShort(); buffer.getShort(); // skip unknown short sampleSize = buffer.getShort(); short nrChannels = buffer.getShort(); byte[] fourCC; if (version == 4) { buffer.position(buffer.get() + buffer.position()); // skip interleaver id fourCC = new byte[buffer.get()]; buffer.get(fourCC); } else { buffer.getFloat(); // skip deinterlace id fourCC = new byte[4]; buffer.get(fourCC); } String fourCCString = new String(fourCC, StandardCharsets.US_ASCII).toLowerCase(Locale.ROOT); switch (fourCCString) { case "lpcJ": audio.setCodecA(FormatConfiguration.REALAUDIO_14_4); break; case "28_8": audio.setCodecA(FormatConfiguration.REALAUDIO_28_8); break; case "dnet": audio.setCodecA(FormatConfiguration.AC3); break; case "sipr": audio.setCodecA(FormatConfiguration.SIPRO); break; case "cook": audio.setCodecA(FormatConfiguration.COOK); case "atrc": audio.setCodecA(FormatConfiguration.ATRAC); case "ralf": audio.setCodecA(FormatConfiguration.RALF); case "raac": audio.setCodecA(FormatConfiguration.AAC_LC); case "racp": audio.setCodecA(FormatConfiguration.HE_AAC); default: LOGGER.debug("Unknown RealMedia codec FourCC \"{}\" - parsing failed", fourCCString); return false; } if (buffer.hasRemaining()) { parseRealAudioMetaData(buffer, audio, version); } audio.setBitRate((int) (bytesPerMinute * 8 / 60)); media.setBitrate((int) (bytesPerMinute * 8 / 60)); audio.setBitsperSample(sampleSize); audio.getAudioProperties().setNumberOfChannels(nrChannels); audio.getAudioProperties().setSampleFrequency(sampleRate); } else { LOGGER.error("Could not parse RealAudio format - unknown format version {}", version); return false; } media.getAudioTracksList().add(audio); long fileSize = 0; if (channel instanceof FileChannel) { fileSize = ((FileChannel) channel).size(); media.setSize(fileSize); } // Duration is estimated based on bitrate and might not be accurate if (audio.getBitRate() > 0) { int dataSize; if (fileSize > 0 && reportedHeaderSize > 0) { int fullHeaderSize = reportedHeaderSize + (version == 3 ? 8 : 16); if (reportedDataSize > 0) { dataSize = (int) Math.min(reportedDataSize, fileSize - fullHeaderSize); } else { dataSize = (int) (fileSize - fullHeaderSize); } } else { dataSize = reportedDataSize; } media.setDuration((double) dataSize / audio.getBitRate() * 8); } } catch (IOException e) { LOGGER.debug("Error while trying to parse RealAudio version 1 or 2: {}", e.getMessage()); LOGGER.trace("", e); return false; } if (PMS.getConfiguration() != null && !PMS.getConfiguration().getAudioThumbnailMethod().equals(CoverSupplier.NONE) && (StringUtils.isNotBlank(media.getFirstAudioTrack().getSongname()) || StringUtils.isNotBlank(media.getFirstAudioTrack().getArtist()))) { ID3v1Tag tag = new ID3v1Tag(); if (StringUtils.isNotBlank(media.getFirstAudioTrack().getSongname())) { tag.setTitle(media.getFirstAudioTrack().getSongname()); } if (StringUtils.isNotBlank(media.getFirstAudioTrack().getArtist())) { tag.setArtist(media.getFirstAudioTrack().getArtist()); } try { media.setThumb(DLNAThumbnail.toThumbnail(CoverUtil.get().getThumbnail(tag), 640, 480, ScaleType.MAX, ImageFormat.SOURCE, false)); } catch (IOException e) { LOGGER.error("An error occurred while generating thumbnail for RealAudio source: [\"{}\", \"{}\"]", tag.getFirstTitle(), tag.getFirstArtist()); } } media.setThumbready(true); media.setMediaparsed(true); return true; }
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 and starts with a comment. * @throws Exception any error//from w ww .j ava2 s .c o m */ @Test public void testSpringMessageSourceBOMandComment() throws Exception { ReloadableResourceBundleMessageSource source = new ReloadableResourceBundleMessageSource(); source.setBasename("UTF8BOMwithComment"); source.setDefaultEncoding("UTF-8"); source.setFallbackToSystemLocale(false); Assert.assertEquals("", source.getMessage("\ufeff#abc", null, Locale.ROOT)); Assert.assertEquals("first key", source.getMessage("testkey1", 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)); }