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.apache.manifoldcf.agents.output.amazoncloudsearch.AmazonCloudSearchConnector.java
/** Detect if a mime type is indexable or not. This method is used by participating repository connectors to pre-filter the number of * unusable documents that will be passed to this output connector. *@param outputDescription is the document's output version. *@param mimeType is the mime type of the document. *@return true if the mime type is indexable by this connector. *///from w ww.j av a 2 s. c o m @Override public boolean checkMimeTypeIndexable(VersionContext outputDescription, String mimeType, IOutputCheckActivity activities) throws ManifoldCFException, ServiceInterruption { if (mimeType == null) return false; return acceptableMimeTypes.contains(mimeType.toLowerCase(Locale.ROOT)); }
From source file:com.gargoylesoftware.htmlunit.javascript.host.dom.EventNode.java
/** * Fires a specified event on this element (IE only). See the * <a href="http://msdn.microsoft.com/en-us/library/ms536423.aspx">MSDN documentation</a> * for more information./* w w w .j a va 2 s . c o m*/ * @param type specifies the name of the event to fire. * @param event specifies the event object from which to obtain event object properties. * @return {@code true} if the event fired successfully, {@code false} if it was canceled */ public boolean fireEvent(final String type, Event event) { if (event == null) { event = new MouseEvent(); } // Create the event, whose class will depend on the type specified. final String cleanedType = StringUtils.removeStart(type.toLowerCase(Locale.ROOT), "on"); if (MouseEvent.isMouseEvent(cleanedType)) { event.setPrototype(getPrototype(MouseEvent.class)); } else { event.setPrototype(getPrototype(Event.class)); } event.setParentScope(getWindow()); // These four properties have predefined values, independent of the template. event.setCancelBubble(false); event.setReturnValue(Boolean.TRUE); event.setSrcElement(this); event.setEventType(cleanedType); fireEvent(event); return ((Boolean) event.getReturnValue()).booleanValue(); }
From source file:me.ryanhamshire.PopulationDensity.DataStore.java
private void loadPlayerDataFromFile(String source, String dest) { //load player data into memory File playerFile = new File(playerDataFolderPath + File.separator + source); BufferedReader inStream = null; try {// w w w . j av a 2 s. c o m PlayerData playerData = new PlayerData(); inStream = new BufferedReader(new FileReader(playerFile.getAbsolutePath())); //first line is home region coordinates String homeRegionCoordinatesString = inStream.readLine(); //second line is date of last disconnection String lastDisconnectedString = inStream.readLine(); //third line is login priority String rankString = inStream.readLine(); //convert string representation of home coordinates to a proper object RegionCoordinates homeRegionCoordinates = new RegionCoordinates(homeRegionCoordinatesString); playerData.homeRegion = homeRegionCoordinates; //parse the last disconnect date string try { DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, Locale.ROOT); Date lastDisconnect = dateFormat.parse(lastDisconnectedString); playerData.lastDisconnect = lastDisconnect; } catch (Exception e) { playerData.lastDisconnect = Calendar.getInstance().getTime(); } //parse priority string if (rankString == null || rankString.isEmpty()) { playerData.loginPriority = 0; } else { try { playerData.loginPriority = Integer.parseInt(rankString); } catch (Exception e) { playerData.loginPriority = 0; } } //shove into memory for quick access this.playerNameToPlayerDataMap.put(dest, playerData); } //if the file isn't found, just don't do anything (probably a new-to-server player) catch (FileNotFoundException e) { return; } //if there's any problem with the file's content, log an error message and skip it catch (Exception e) { PopulationDensity.AddLogEntry("Unable to load data for player \"" + source + "\": " + e.getMessage()); } try { if (inStream != null) inStream.close(); } catch (IOException exception) { } }
From source file:business.security.control.OwmClient.java
public WeatherForecastResponse tenForecastWeatherAtCity(String cityName) throws JSONException, IOException { String subUrl = String.format(Locale.ROOT, "forecast/daily?q=%s&cnt=10&mode=json", cityName); JSONObject response = doQuery(subUrl); return new WeatherForecastResponse(response); }
From source file:org.jboss.as.test.integration.logging.formatters.XmlFormatterTestCase.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());/*from www .j a v a 2 s .c o m*/ final String msg = "Logging test: XmlFormatterTestCase.testNoExceptions"; int statusCode = getResponse(msg, Collections.singletonMap(LoggingServiceActivator.LOG_EXCEPTION_KEY, "false")); Assert.assertEquals("Invalid response statusCode: " + statusCode, statusCode, HttpStatus.SC_OK); final List<String> expectedKeys = createDefaultKeys(); final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); final DocumentBuilder documentBuilder = factory.newDocumentBuilder(); for (String s : Files.readAllLines(logFile, StandardCharsets.UTF_8)) { if (s.trim().isEmpty()) continue; final Document doc = documentBuilder.parse(new InputSource(new StringReader(s))); validateDefault(doc, expectedKeys, msg); validateStackTrace(doc, false, false); // Validate the date format is correct. We don't want to validate the specific date, only that it's // parsable. final NodeList timestampNode = doc.getElementsByTagName("timestamp"); Assert.assertEquals(1, timestampNode.getLength()); final String xmlDate = timestampNode.item(0).getTextContent(); // If the date is not parsable an exception should be thrown try { DateTimeFormatter.ofPattern(dateFormat, Locale.ROOT).withZone(ZoneId.of(timezone)).parse(xmlDate); } catch (Exception e) { Assert.fail(String.format("Failed to parse %s with pattern %s and zone %s: %s", xmlDate, dateFormat, timezone, e.getMessage())); } } }
From source file:com.gargoylesoftware.htmlunit.html.HTMLParser.java
/** * Returns the pre-registered element factory corresponding to the specified tag, or an UnknownElementFactory. * @param page the page/* w ww. j a v a2s. c o m*/ * @param namespaceURI the namespace URI * @param qualifiedName the qualified name * @return the pre-registered element factory corresponding to the specified tag, or an UnknownElementFactory */ static ElementFactory getElementFactory(final SgmlPage page, final String namespaceURI, final String qualifiedName) { if (SVG_NAMESPACE.equals(namespaceURI)) { return SVG_FACTORY; } if (namespaceURI == null || namespaceURI.isEmpty() || !qualifiedName.contains(":") || namespaceURI.equals(XHTML_NAMESPACE)) { String tagName = qualifiedName; final int index = tagName.indexOf(':'); if (index == -1) { tagName = tagName.toLowerCase(Locale.ROOT); } else { tagName = tagName.substring(index + 1); } final ElementFactory factory = ELEMENT_FACTORIES.get(tagName); if (factory != null) { return factory; } } return UnknownElementFactory.instance; }
From source file:com.puppycrawl.tools.checkstyle.MainTest.java
@Test public void testExistingTargetFileWithError() throws Exception { exit.expectSystemExitWithStatus(2);/* w w w. j a va2 s . c o m*/ exit.checkAssertionAfterwards(new Assertion() { @Override public void checkAssertion() throws IOException { String currentPath = new File(".").getCanonicalPath(); String expectedPath = currentPath + "/src/test/resources/com/puppycrawl/tools/checkstyle/InputMain.java".replace("/", File.separator); assertEquals(String.format(Locale.ROOT, "Starting audit...%n" + "%1$s:3:14: error: " + "Name 'InputMain' must match pattern '^[a-z0-9]*$'.%n" + "%1$s:5:7: error: " + "Name 'InputMainInner' must match pattern '^[a-z0-9]*$'.%n" + "Audit done.%n" + "Checkstyle ends with 2 errors.%n", expectedPath), systemOut.getLog()); assertEquals("", systemErr.getLog()); } }); Main.main("-c", "src/test/resources/com/puppycrawl/tools/checkstyle/config-classname2-error.xml", "src/test/resources/com/puppycrawl/tools/checkstyle/InputMain.java"); }
From source file:com.google.gwt.resources.rg.GssResourceGenerator.java
public static GssOptions getGssOptions(PropertyOracle propertyOracle, TreeLogger logger) throws UnableToCompleteException { boolean gssEnabled; boolean gssDefaultInUiBinder; AutoConversionMode conversionMode;//from ww w . j a va 2 s. com try { ConfigurationProperty enableGssProp = propertyOracle.getConfigurationProperty(KEY_ENABLE_GSS); String enableGss = enableGssProp.getValues().get(0); gssEnabled = Boolean.parseBoolean(enableGss); } catch (BadPropertyValueException ex) { logger.log(Type.ERROR, "Unable to determine if GSS need to be used"); throw new UnableToCompleteException(); } try { conversionMode = Enum.valueOf(AutoConversionMode.class, propertyOracle .getConfigurationProperty(KEY_CONVERSION_MODE).getValues().get(0).toUpperCase(Locale.ROOT)); } catch (BadPropertyValueException ex) { logger.log(Type.ERROR, "Unable to conversion mode for GSS"); throw new UnableToCompleteException(); } try { ConfigurationProperty uiBinderGssDefaultProp = propertyOracle .getConfigurationProperty(KEY_GSS_DEFAULT_IN_UIBINDER); String uiBinderGssDefaultValue = uiBinderGssDefaultProp.getValues().get(0); gssDefaultInUiBinder = Boolean.parseBoolean(uiBinderGssDefaultValue); } catch (BadPropertyValueException ex) { logger.log(Type.ERROR, "Unable to determine default for GSS in UiBinder"); throw new UnableToCompleteException(); } return new GssOptions(gssEnabled, conversionMode, gssDefaultInUiBinder); }
From source file:com.xpn.xwiki.internal.filter.output.XWikiDocumentOutputFilterStream.java
@Override public void beginWikiDocument(String name, FilterEventParameters parameters) throws FilterException { super.beginWikiDocument(name, parameters); if (parameters.containsKey(WikiDocumentFilter.PARAMETER_LOCALE)) { this.currentDefaultLocale = get(Locale.class, WikiDocumentFilter.PARAMETER_LOCALE, parameters, Locale.ROOT); } else {//from w ww. j av a 2 s . c o m this.currentDefaultLocale = this.localizationContext.getCurrentLocale(); } this.currentLocale = Locale.ROOT; this.currentLocaleParameters = parameters; begin(parameters); }
From source file:alba.components.FilteredShowFileRequestHandler.java
public static boolean isHiddenFile(SolrQueryRequest req, SolrQueryResponse rsp, String fnameIn, boolean reportError, Set<String> hiddenFiles) { String fname = fnameIn.toUpperCase(Locale.ROOT); if (hiddenFiles.contains(fname) || hiddenFiles.contains("*")) { if (reportError) { log.error("Cannot access " + fname); rsp.setException(/* w w w . j av a 2 s. c o m*/ new SolrException(SolrException.ErrorCode.FORBIDDEN, "Can not access: " + fnameIn)); } return true; } // This is slightly off, a valid path is something like ./schema.xml. I don't think it's worth the effort though // to fix it to handle all possibilities though. if (fname.indexOf("..") >= 0 || fname.startsWith(".")) { if (reportError) { log.error("Invalid path: " + fname); rsp.setException(new SolrException(SolrException.ErrorCode.FORBIDDEN, "Invalid path: " + fnameIn)); } return true; } // Make sure that if the schema is managed, we don't allow editing. Don't really want to put // this in the init since we're not entirely sure when the managed schema will get initialized relative to this // handler. SolrCore core = req.getCore(); IndexSchema schema = core.getLatestSchema(); if (schema instanceof ManagedIndexSchema) { String managed = schema.getResourceName(); if (fname.equalsIgnoreCase(managed)) { return true; } } return false; }