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.n52.iceland.config.AbstractSettingValueFactory.java
/** * Parses the a string to a {@code Boolean}. * <p/>//from w w w . j a v a2 s. com * * @param stringValue * the string value * <p/> * @return the parsed value * <p/> * @throws IllegalArgumentException * if the string value is invalid */ public Boolean parseBoolean(String stringValue) throws IllegalArgumentException { if (nullOrEmpty(stringValue)) { return Boolean.FALSE; } String trimmedLowerCase = stringValue.trim().toLowerCase(Locale.ROOT); if (VALID_FALSE_VALUES.contains(trimmedLowerCase)) { return Boolean.FALSE; } else if (VALID_TRUE_VALUES.contains(trimmedLowerCase)) { return Boolean.TRUE; } else { throw new IllegalArgumentException(String.format("'%s' is not a valid boolean value", stringValue)); } }
From source file:com.android.talkback.labeling.LabelProvider.java
/** * Updates a label in the labels database. * * @param uri The URI matching {code LABELS_ID_CONTENT_URI} that represents * the specific label to update. * @param values The values to use to update the label. * @param selection The WHERE clause for the query. * @param selectionArgs The arguments for the WHERE clause of the query. * @return The number of rows affected./*from ww w . j a v a 2 s . co m*/ */ @Override public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { if (uri == null) { LogUtils.log(this, Log.WARN, NULL_URI_FORMAT_STRING); return 0; } if (!UserManagerCompat.isUserUnlocked(getContext())) { return 0; } switch (sUriMatcher.match(uri)) { case LABELS: { initializeDatabaseIfNull(); int result = mDatabase.update(LabelsTable.TABLE_NAME, values, selection, selectionArgs); getContext().getContentResolver().notifyChange(uri, null /* observer */); return result; } case LABELS_ID: { initializeDatabaseIfNull(); final String labelIdString = uri.getLastPathSegment(); final int labelId; try { labelId = Integer.parseInt(labelIdString); } catch (NumberFormatException e) { LogUtils.log(this, Log.WARN, UNKNOWN_URI_FORMAT_STRING, uri); return 0; } final String where = String.format(Locale.ROOT, "%s = %d", LabelsTable.KEY_ID, labelId); final int result = mDatabase.update(LabelsTable.TABLE_NAME, values, combineSelectionAndWhere(selection, where), selectionArgs); getContext().getContentResolver().notifyChange(uri, null /* observer */); return result; } default: LogUtils.log(this, Log.WARN, UNKNOWN_URI_FORMAT_STRING, uri); return 0; } }
From source file:com.xpn.xwiki.web.XWikiMessageTool.java
/** * Find a translation and then replace any parameters found in the translation by the passed parameters. The format * is the one used by {@link java.text.MessageFormat}. * /*from ww w. j ava 2 s . c o m*/ * @param key the key of the string to find * @param params the list of parameters to use for replacing "{N}" elements in the string. See * {@link java.text.MessageFormat} for the full syntax * @return the translated string with parameters resolved */ public String get(String key, Object... params) { String translation; if (this.localization != null) { String language = this.context.getWiki().getLanguagePreference(this.context); Locale locale = StringUtils.isEmpty(language) ? Locale.ROOT : LocaleUtils.toLocale(language); Translation translations = this.localization.getTranslation(key, locale); if (translations != null) { Block block = translations.render(locale, params); BlockRenderer renderer; try { renderer = this.componentManager.getInstance(BlockRenderer.class, Syntax.PLAIN_1_0.toIdString()); DefaultWikiPrinter wikiprinter = new DefaultWikiPrinter(); renderer.render(block, wikiprinter); translation = wikiprinter.toString(); } catch (ComponentLookupException e) { LOGGER.debug("Failed to find a plain text renderer", e); translation = key; } } else { translation = key; } } else { translation = get(key); if (params != null && translation != null) { translation = MessageFormat.format(translation, params); } } return translation; }
From source file:com.puppycrawl.tools.checkstyle.MainTest.java
@Test public void testNonExistingClass() throws Exception { exit.expectSystemExitWithStatus(-2); final String cause = "Unable to instantiate 'NonExistingClass' class," + " it is also not possible to instantiate it as" + " com.puppycrawl.tools.checkstyle.checks.annotation.NonExistingClass," + " com.puppycrawl.tools.checkstyle.checks.blocks.NonExistingClass," + " com.puppycrawl.tools.checkstyle.checks.coding.NonExistingClass," + " com.puppycrawl.tools.checkstyle.checks.design.NonExistingClass," + " com.puppycrawl.tools.checkstyle.checks.header.NonExistingClass," + " com.puppycrawl.tools.checkstyle.checks.imports.NonExistingClass," + " com.puppycrawl.tools.checkstyle.checks.indentation.NonExistingClass," + " com.puppycrawl.tools.checkstyle.checks.javadoc.NonExistingClass," + " com.puppycrawl.tools.checkstyle.checks.metrics.NonExistingClass," + " com.puppycrawl.tools.checkstyle.checks.modifier.NonExistingClass," + " com.puppycrawl.tools.checkstyle.checks.naming.NonExistingClass," + " com.puppycrawl.tools.checkstyle.checks.regexp.NonExistingClass," + " com.puppycrawl.tools.checkstyle.checks.sizes.NonExistingClass," + " com.puppycrawl.tools.checkstyle.checks.whitespace.NonExistingClass," + " com.puppycrawl.tools.checkstyle.checks.NonExistingClass," + " com.puppycrawl.tools.checkstyle.filters.NonExistingClass," + " com.puppycrawl.tools.checkstyle.NonExistingClass." + " Please recheck that class name is specified as canonical name or read" + " how to configure short name usage http://checkstyle.sourceforge.net/config.html#Packages." + " Please also recheck that provided ClassLoader to Checker is configured correctly."; final String expectedExceptionMessage = String.format(Locale.ROOT, "cannot initialize module TreeWalker - %1$s%n" + "Cause: com.puppycrawl.tools.checkstyle.api.CheckstyleException: %1$s%n" + "Checkstyle ends with 1 errors.%n", cause);/* w w w.j ava 2 s .c o m*/ exit.checkAssertionAfterwards(new Assertion() { @Override public void checkAssertion() { assertEquals(expectedExceptionMessage, systemOut.getLog()); assertEquals("", systemErr.getLog()); } }); Main.main("-c", "src/test/resources/com/puppycrawl/tools/checkstyle/config-non-existing-classname.xml", "src/test/resources/com/puppycrawl/tools/checkstyle/InputMain.java"); }
From source file:com.gargoylesoftware.js.CodeStyleTest.java
/** * Checks the year in LICENSE.txt.//from www. j a va 2 s .co m */ private void licenseYear() throws IOException { final List<String> lines = FileUtils.readLines(new File("LICENSE.txt")); if (!lines.get(1).contains("Copyright (c) " + Calendar.getInstance(Locale.ROOT).get(Calendar.YEAR))) { addFailure("Incorrect year in LICENSE.txt"); } }
From source file:com.puppycrawl.tools.checkstyle.ConfigurationLoader.java
/** * Returns the module configurations from a specified input source. * Note that if the source does wrap an open byte or character * stream, clients are required to close that stream by themselves * * @param configSource the input stream to the Checkstyle configuration * @param overridePropsResolver overriding properties * @param omitIgnoredModules {@code true} if modules with severity * 'ignore' should be omitted, {@code false} otherwise * @return the check configurations/* ww w . j a v a 2 s .co m*/ * @throws CheckstyleException if an error occurs */ public static Configuration loadConfiguration(InputSource configSource, PropertyResolver overridePropsResolver, boolean omitIgnoredModules) throws CheckstyleException { try { final ConfigurationLoader loader = new ConfigurationLoader(overridePropsResolver, omitIgnoredModules); loader.parseInputSource(configSource); return loader.configuration; } catch (final SAXParseException e) { final String message = String.format(Locale.ROOT, "%s - %s:%s:%s", UNABLE_TO_PARSE_EXCEPTION_PREFIX, e.getMessage(), e.getLineNumber(), e.getColumnNumber()); throw new CheckstyleException(message, e); } catch (final ParserConfigurationException | IOException | SAXException e) { throw new CheckstyleException(UNABLE_TO_PARSE_EXCEPTION_PREFIX, e); } }
From source file:com.silverpeas.util.FileUtil.java
/** * Loads a ResourceBundle from the Silverpeas configuration directory. * * @param bundleName the name of the bundle. * @param locale the locale of the bundle. * @return the corresponding ResourceBundle if it exists - null otherwise. *///from w w w .ja va 2 s .com public static ResourceBundle loadBundle(final String bundleName, final Locale locale) { String name = convertBundleName(bundleName); ResourceBundle bundle; Locale loc = locale; if (loc == null) { loc = Locale.ROOT; } try { bundle = ResourceBundle.getBundle(name, loc, loader, new ConfigurationControl()); if (bundle == null) { bundle = ResourceBundle.getBundle(bundleName, loc, loader, new ConfigurationControl()); } } catch (MissingResourceException mex) { //Let's try with the real name bundle = ResourceBundle.getBundle(bundleName, loc, loader, new ConfigurationControl()); } return bundle; }
From source file:com.facebook.share.internal.VideoUploader.java
private static void logError(Exception e, String format, Object... args) { Log.e(TAG, String.format(Locale.ROOT, format, args), e); }
From source file:net.radai.beanz.util.ReflectionUtil.java
public static boolean isGetter(Method method) { Type returnType = method.getGenericReturnType(); if (returnType.equals(void.class)) { return false; //should return something }//from www. j a v a 2 s . c o m Type[] argumentTypes = method.getGenericParameterTypes(); if (argumentTypes != null && argumentTypes.length != 0) { return false; //should not accept any arguments } String name = method.getName(); if (name.startsWith("get")) { if (name.length() < 4) { return false; //has to be getSomething } String fourthChar = name.substring(3, 4); return fourthChar.toUpperCase(Locale.ROOT).equals(fourthChar); //getSomething (upper case) } else if (name.startsWith("is")) { if (name.length() < 3) { return false; //isSomething } String thirdChar = name.substring(2, 3); //noinspection SimplifiableIfStatement if (!thirdChar.toUpperCase(Locale.ROOT).equals(thirdChar)) { return false; //has to start with uppercase (or something that uppercases to itself, like a number?) } return returnType.equals(boolean.class) || returnType.equals(Boolean.class); } else { return false; } }
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 blank line. * @throws Exception any error/*from w ww . ja v a 2 s.c om*/ */ @Test public void testSpringMessageSourceBOMandBlankLine() throws Exception { ReloadableResourceBundleMessageSource source = new ReloadableResourceBundleMessageSource(); source.setBasename("UTF8BOMwithBlankLine"); source.setDefaultEncoding("UTF-8"); source.setFallbackToSystemLocale(false); 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)); }