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:org.elasticsearch.plugins.PluginManagerIT.java
private void assertThatPluginIsListed(String pluginName) { terminal.getTerminalOutput().clear(); assertStatusOk("list"); String message = String.format(Locale.ROOT, "Terminal output was: %s", terminal.getTerminalOutput()); assertThat(message, terminal.getTerminalOutput(), hasItem(containsString(pluginName))); }
From source file:com.ehsy.solr.util.SimplePostTool.java
private static boolean checkResponseCode(HttpURLConnection urlc) throws IOException { if (urlc.getResponseCode() >= 400) { warn("Solr returned an error #" + urlc.getResponseCode() + " (" + urlc.getResponseMessage() + ") for url: " + urlc.getURL()); Charset charset = StandardCharsets.ISO_8859_1; final String contentType = urlc.getContentType(); // code cloned from ContentStreamBase, but post.jar should be standalone! if (contentType != null) { int idx = contentType.toLowerCase(Locale.ROOT).indexOf("charset="); if (idx > 0) { charset = Charset.forName(contentType.substring(idx + "charset=".length()).trim()); }//from w w w. j a v a 2 s . c om } // Print the response returned by Solr try (InputStream errStream = urlc.getErrorStream()) { if (errStream != null) { BufferedReader br = new BufferedReader(new InputStreamReader(errStream, charset)); final StringBuilder response = new StringBuilder("Response: "); int ch; while ((ch = br.read()) != -1) { response.append((char) ch); } warn(response.toString().trim()); } } return false; } return true; }
From source file:org.elasticsearch.plugins.PluginManagerIT.java
private void assertThatPluginIsNotListed(String pluginName) { terminal.getTerminalOutput().clear(); assertStatusOk("list"); String message = String.format(Locale.ROOT, "Terminal output was: %s", terminal.getTerminalOutput()); assertFalse(message, terminal.getTerminalOutput().contains(pluginName)); }
From source file:com.spotify.docker.client.DefaultDockerClient.java
@Override public LogStream attachContainer(final String containerId, final AttachParameter... params) throws DockerException, InterruptedException { WebTarget resource = noTimeoutResource().path("containers").path(containerId).path("attach"); for (final AttachParameter param : params) { resource = resource.queryParam(param.name().toLowerCase(Locale.ROOT), String.valueOf(true)); }//from ww w . ja va 2 s. c o m return getLogStream(POST, resource, containerId); }
From source file:com.udojava.evalex.Expression.java
/** * Evaluates the expression.//from w ww .ja v a2 s.com * * @return The result of the expression. */ public MyComplex eval() { Stack<LazyNumber> stack = new Stack<>(); for (final String token : getRPN()) { if (operators.containsKey(token)) { final LazyNumber v1 = stack.pop(); final LazyNumber v2 = stack.pop(); LazyNumber number = () -> operators.get(token).eval(v2.eval(), v1.eval()); stack.push(number); } else if (mainVars.getMap().containsKey(token)) { MyComplex v = mainVars.get(token); if (v.type == ValueType.ARRAY) { stack.push(() -> v); } else { PitDecimal bd = new PitDecimal(v.real, v.imaginary); bd.type = v.type; bd.setVarToken(token); stack.push(() -> bd); } } else if (functions.containsKey(token.toUpperCase(Locale.ROOT))) { LazyFunction f = functions.get(token.toUpperCase(Locale.ROOT)); ArrayList<LazyNumber> p = new ArrayList<>(!f.numParamsVaries() ? f.getNumParams() : 0); // pop parameters off the stack until we hit the start of // this function's parameter list while (!stack.isEmpty() && stack.peek() != PARAMS_START) { p.add(0, stack.pop()); } if (stack.peek() == PARAMS_START) { stack.pop(); } LazyNumber fResult = f.lazyEval(p); stack.push(fResult); } else if ("(".equals(token)) { stack.push(PARAMS_START); } else { MyComplex bd; if (token.endsWith("i")) { String str = token.substring(0, token.length() - 1); if (str.isEmpty()) str = "1"; bd = new MyComplex("0", str); } else { bd = new MyComplex(token); } MyComplex finalBd = bd; stack.push(() -> finalBd); // blank constant } } return stack.pop().eval(); }
From source file:com.gargoylesoftware.htmlunit.html.HtmlElement.java
/** * Returns all elements which are descendants of this element and match the specified search criteria. * * @param elementName the name of the element to search for * @param attributeName the name of the attribute to search for * @param attributeValue the value of the attribute to search for * @param <E> the sub-element type * @return all elements which are descendants of this element and match the specified search criteria *//* w w w. j a v a 2s . com*/ @SuppressWarnings("unchecked") public final <E extends HtmlElement> List<E> getElementsByAttribute(final String elementName, final String attributeName, final String attributeValue) { final List<E> list = new ArrayList<>(); final String lowerCaseTagName = elementName.toLowerCase(Locale.ROOT); for (final HtmlElement next : getHtmlElementDescendants()) { if (next.getTagName().equals(lowerCaseTagName)) { final String attValue = next.getAttribute(attributeName); if (attValue != null && attValue.equals(attributeValue)) { list.add((E) next); } } } return list; }
From source file:net.yacy.cora.document.id.MultiProtocolURL.java
/** * Encode a string to the "x-www-form-urlencoded" form, enhanced * with the UTF-8-in-URL proposal. This is what happens: * * <ul>/*from w w w. j a va 2 s .c om*/ * <li>The ASCII characters 'a' through 'z', 'A' through 'Z', * and '0' through '9' remain the same. * * <li>The unreserved characters & : - _ . ! ~ * ' ( ) ; , = remain the same. * see RFC 1738 2.2 and RFC 3986 2.2 * * <li>All other ASCII characters are converted into the * 3-character string "%xy", where xy is * the two-digit hexadecimal representation of the character * code * * <li>All non-ASCII characters are encoded in two steps: first * to a sequence of 2 or 3 bytes, using the UTF-8 algorithm; * secondly each of these bytes is encoded as "%xx". * </ul> * * @param s The string to be encoded * @return The encoded string */ // from: http://www.w3.org/International/URLUTF8Encoder.java public static StringBuilder escape(final String s) { final int len = s.length(); final StringBuilder sbuf = new StringBuilder(len + 10); for (int i = 0; i < len; i++) { final int ch = s.charAt(i); if (ch == ' ') { // space sbuf.append("%20"); } else if (ch == '%') { if (i < len - 2 && s.charAt(i + 1) >= '0' && s.charAt(i + 1) <= '9' && s.charAt(i + 2) >= '0' && s.charAt(i + 2) <= '9') { // TODO: actually 0..9 A..F a..f is allowed (or any of hex[] sequence) sbuf.append((char) ch); // lets consider this is used for encoding, leave it that way } else { sbuf.append("%25"); // '%' RFC 1738 2.2 unsafe char shall be encoded } } else if (ch == '&') { if (i < len - 6 && "amp;".equals(s.substring(i + 1, i + 5).toLowerCase(Locale.ROOT))) { sbuf.append((char) ch); // leave it that way, it is used the right way } else { sbuf.append("%26"); // this must be urlencoded } } else if (ch == '#') { // RFC 1738 2.2 unsafe char is _not_ encoded because it may already be used for encoding sbuf.append((char) ch); } else if (ch == '!' || ch == ':' // unreserved || ch == '-' || ch == '_' || ch == '.' || ch == '~' || ch == '*' || ch == '\'' || ch == '(' || ch == ')' || ch == '{' || ch == '}' || ch == ';' || ch == ',' || ch == '=') { // RFC 1738 2.2 unsafe char (may be used unencoded) sbuf.append((char) ch); } else if ('0' <= ch && ch <= '9') { // '0'..'9' sbuf.append((char) ch); } else if (ch == '/') { // reserved, but may appear in post part where it should not be replaced sbuf.append((char) ch); } else if ('A' <= ch && ch <= 'Z') { // 'A'..'Z' sbuf.append((char) ch); } else if ('a' <= ch && ch <= 'z') { // 'a'..'z' sbuf.append((char) ch); } else if (ch <= 0x007f) { // other ASCII sbuf.append(hex[ch]); } else if (ch <= 0x07FF) { // non-ASCII <= 0x7FF sbuf.append(hex[0xc0 | (ch >> 6)]); sbuf.append(hex[0x80 | (ch & 0x3F)]); } else { // 0x7FF < ch <= 0xFFFF sbuf.append(hex[0xe0 | (ch >> 12)]); sbuf.append(hex[0x80 | ((ch >> 6) & 0x3F)]); sbuf.append(hex[0x80 | (ch & 0x3F)]); } } return sbuf; }
From source file:com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDocument.java
/** * Returns the character encoding of the current document. * @return the character encoding of the current document *//*from w w w . j a va 2 s . c o m*/ @JsxGetter({ @WebBrowser(FF), @WebBrowser(CHROME), @WebBrowser(IE) }) public String getCharacterSet() { final String charset = getPage().getPageEncoding(); if (charset != null && getBrowserVersion().hasFeature(HTMLDOCUMENT_CHARSET_LOWERCASE)) { return charset.toLowerCase(Locale.ROOT); } if (charset != null && getBrowserVersion().hasFeature(HTMLDOCUMENT_CHARSET_NORMALIZED)) { return EncodingSniffer.translateEncodingLabel(charset); } return charset; }
From source file:com.udojava.evalex.Expression.java
/** * Implementation of the <i>Shunting Yard</i> algorithm to transform an * infix expression to a RPN expression. * * @param expression The input expression in infx. * @return A RPN representation of the expression, with each token as a list * member./* w ww . jav a 2 s.c o m*/ */ private List<String> shuntingYard(String expression) { List<String> outputQueue = new ArrayList<>(); Stack<String> stack = new Stack<>(); Tokenizer tokenizer = new Tokenizer(expression); String lastFunction = null; String previousToken = null; while (tokenizer.hasNext()) { String token = tokenizer.next(); if (isNumber(token)) { if (token.startsWith("x")) { BigInteger bd = new BigInteger(token.substring(1), 16); outputQueue.add(bd.toString(10)); } else if (token.startsWith("b")) { BigInteger bd = new BigInteger(token.substring(1), 2); outputQueue.add(bd.toString(10)); } else if (token.startsWith("o")) { BigInteger bd = new BigInteger(token.substring(1), 8); outputQueue.add(bd.toString(10)); } else { outputQueue.add(token); } } else if (mainVars.containsKey(token)) { outputQueue.add(token); } else if (functions.containsKey(token.toUpperCase(Locale.ROOT))) { stack.push(token); lastFunction = token; } else if ((Character.isLetter(token.charAt(0)) || token.charAt(0) == '_') && !operators.containsKey(token)) { mainVars.put(token, new MyComplex(0, 0)); // create variable outputQueue.add(token); //stack.push(token); } else if (",".equals(token)) { if (operators.containsKey(previousToken)) { throw new ExpressionException("Missing parameter(s) for operator " + previousToken + " at character position " + (tokenizer.getPos() - 1 - previousToken.length())); } while (!stack.isEmpty() && !"(".equals(stack.peek())) { outputQueue.add(stack.pop()); } if (stack.isEmpty()) { throw new ExpressionException("Parse error for function '" + lastFunction + "'"); } } else if (operators.containsKey(token)) { if (",".equals(previousToken) || "(".equals(previousToken)) { throw new ExpressionException("Missing parameter(s) for operator " + token + " at character position " + (tokenizer.getPos() - token.length())); } Operator o1 = operators.get(token); String token2 = stack.isEmpty() ? null : stack.peek(); while (token2 != null && operators.containsKey(token2) && ((o1.isLeftAssoc() && o1.getPrecedence() <= operators.get(token2).getPrecedence()) || (o1.getPrecedence() < operators.get(token2).getPrecedence()))) { outputQueue.add(stack.pop()); token2 = stack.isEmpty() ? null : stack.peek(); } stack.push(token); } else if ("(".equals(token)) { if (previousToken != null) { if (isNumber(previousToken)) { throw new ExpressionException( "Missing operator at character position " + tokenizer.getPos()); } // if the ( is preceded by a valid function, then it // denotes the start of a parameter list if (functions.containsKey(previousToken.toUpperCase(Locale.ROOT))) { outputQueue.add(token); } } stack.push(token); } else if (")".equals(token)) { if (operators.containsKey(previousToken)) { throw new ExpressionException("Missing parameter(s) for operator " + previousToken + " at character position " + (tokenizer.getPos() - 1 - previousToken.length())); } while (!stack.isEmpty() && !"(".equals(stack.peek())) { outputQueue.add(stack.pop()); } if (stack.isEmpty()) { throw new ExpressionException("Mismatched parentheses"); } stack.pop(); if (!stack.isEmpty() && functions.containsKey(stack.peek().toUpperCase(Locale.ROOT))) { outputQueue.add(stack.pop()); } } previousToken = token; } while (!stack.isEmpty()) { String element = stack.pop(); if ("(".equals(element) || ")".equals(element)) { throw new ExpressionException("Mismatched parentheses"); } if (!operators.containsKey(element)) { throw new ExpressionException("Unknown operator or function: " + element); } outputQueue.add(element); } return outputQueue; }
From source file:com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDocument.java
/** * Retrieves the character set used to encode the document. * @return the character set used to encode the document *///from ww w . java 2s .c o m @JsxGetter({ @WebBrowser(IE), @WebBrowser(CHROME) }) public String getCharset() { String charset = getPage().getPageEncoding(); if (charset != null) { if (getBrowserVersion().hasFeature(HTMLDOCUMENT_CHARSET_NORMALIZED)) { return EncodingSniffer.translateEncodingLabel(charset); } if (getBrowserVersion().hasFeature(HTMLDOCUMENT_CHARSET_LOWERCASE)) { charset = charset.toLowerCase(Locale.ROOT); } } return charset; }