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.html.HTMLInputElement.java
/** * Sets the value of the attribute {@code type}. * Note: this replace the DOM node with a new one. * @param newType the new type to set//w ww . j ava 2s . c o m */ @JsxSetter public void setType(String newType) { HtmlInput input = getDomNodeOrDie(); final String currentType = input.getAttribute("type"); if (!currentType.equalsIgnoreCase(newType)) { if (newType != null && getBrowserVersion().hasFeature(JS_INPUT_SET_TYPE_LOWERCASE)) { newType = newType.toLowerCase(Locale.ROOT); } final AttributesImpl attributes = readAttributes(input); final int index = attributes.getIndex("type"); if (index > -1) { attributes.setValue(index, newType); } else { attributes.addAttribute(null, "type", "type", null, newType); } // create a new one only if we have a new type if (ATTRIBUTE_NOT_DEFINED != currentType || !"text".equalsIgnoreCase(newType)) { final HtmlInput newInput = (HtmlInput) InputElementFactory.instance.createElement(input.getPage(), "input", attributes); if (input.wasCreatedByJavascript()) { newInput.markAsCreatedByJavascript(); } if (input.getParentNode() == null) { // the input hasn't yet been inserted into the DOM tree (likely has been // created via document.createElement()), so simply replace it with the // new Input instance created in the code above input = newInput; } else { input.getParentNode().replaceChild(newInput, input); } input.setScriptableObject(null); setDomNode(newInput, true); } else { super.setAttribute("type", newType); } } }
From source file:com.searchbox.framework.web.SystemController.java
@ModelAttribute("jvmInfo") public static Map<String, Object> getJvmInfo() { Map<String, Object> jvm = new HashMap<String, Object>(); final String javaVersion = System.getProperty("java.specification.version", "unknown"); final String javaVendor = System.getProperty("java.specification.vendor", "unknown"); final String javaName = System.getProperty("java.specification.name", "unknown"); final String jreVersion = System.getProperty("java.version", "unknown"); final String jreVendor = System.getProperty("java.vendor", "unknown"); final String vmVersion = System.getProperty("java.vm.version", "unknown"); final String vmVendor = System.getProperty("java.vm.vendor", "unknown"); final String vmName = System.getProperty("java.vm.name", "unknown"); // Summary Info jvm.put("version", jreVersion + " " + vmVersion); jvm.put("name", jreVendor + " " + vmName); // details/* w w w . j a v a 2 s .co m*/ Map<String, Object> java = new HashMap<String, Object>(); java.put("vendor", javaVendor); java.put("name", javaName); java.put("version", javaVersion); jvm.put("spec", java); Map<String, Object> jre = new HashMap<String, Object>(); jre.put("vendor", jreVendor); jre.put("version", jreVersion); jvm.put("jre", jre); Map<String, Object> vm = new HashMap<String, Object>(); vm.put("vendor", vmVendor); vm.put("name", vmName); vm.put("version", vmVersion); jvm.put("vm", vm); Runtime runtime = Runtime.getRuntime(); jvm.put("processors", runtime.availableProcessors()); // not thread safe, but could be thread local DecimalFormat df = new DecimalFormat("#.#", DecimalFormatSymbols.getInstance(Locale.ROOT)); Map<String, Object> mem = new HashMap<String, Object>(); Map<String, Object> raw = new HashMap<String, Object>(); long free = runtime.freeMemory(); long max = runtime.maxMemory(); long total = runtime.totalMemory(); long used = total - free; double percentUsed = ((double) (used) / (double) max) * 100; raw.put("free", free); mem.put("free", humanReadableUnits(free, df)); raw.put("total", total); mem.put("total", humanReadableUnits(total, df)); raw.put("max", max); mem.put("max", humanReadableUnits(max, df)); raw.put("used", used); mem.put("used", humanReadableUnits(used, df) + " (%" + df.format(percentUsed) + ")"); raw.put("used%", percentUsed); mem.put("raw", raw); jvm.put("memory", mem); // JMX properties -- probably should be moved to a different handler Map<String, Object> jmx = new HashMap<String, Object>(); try { RuntimeMXBean mx = ManagementFactory.getRuntimeMXBean(); jmx.put("bootclasspath", mx.getBootClassPath()); jmx.put("classpath", mx.getClassPath()); // the input arguments passed to the Java virtual machine // which does not include the arguments to the main method. jmx.put("commandLineArgs", mx.getInputArguments()); jmx.put("startTime", new Date(mx.getStartTime())); jmx.put("upTimeMS", mx.getUptime()); } catch (Exception e) { LOGGER.warn("Error getting JMX properties", e); } jvm.put("jmx", jmx); return jvm; }
From source file:com.gargoylesoftware.js.CodeStyleTest.java
private boolean isSvnPropertiesDefined(final File file) { try {/*from www. j a v a2 s . co m*/ final AtomicBoolean eol = new AtomicBoolean(); svnWCClient_.doGetProperty(file, null, SVNRevision.WORKING, SVNRevision.WORKING, SVNDepth.EMPTY, new ISVNPropertyHandler() { @Override public void handleProperty(final long revision, final SVNPropertyData property) { // nothing to do } @Override public void handleProperty(final SVNURL url, final SVNPropertyData property) { // nothing to do } @Override public void handleProperty(final File path, final SVNPropertyData property) { final String name = property.getName(); final String value = property.getValue().getString(); if ("svn:eol-style".equals(name) && "native".equals(value)) { eol.set(true); } } }, null); final String fileName = file.getName().toLowerCase(Locale.ROOT); for (final String extension : EOL_EXTENSIONS_) { if (fileName.endsWith(extension)) { return eol.get(); } } return true; } catch (final Exception e) { //nothing } final String path = file.getAbsolutePath(); // automatically generated and is outside SVN control return (path.contains("jQuery") && path.contains("WEB-INF") && path.contains("cgi")) || (path.contains("jQuery") && path.contains("csp.log")); }
From source file:fi.ilmoeuro.membertrack.membership.MembershipsPageModel.java
@Override public void saveState(BiConsumer<String, @Nullable String> pairConsumer) { pairConsumer.accept("page", String.valueOf(getCurrentPage())); Membership selected = membershipEditor.getMembership(); if (selected != null) { pairConsumer.accept("selected", selected.getPerson().getEmail()); } else {//from w w w. j a v a 2s .c om pairConsumer.accept("selected", null); } if (currentEditor != Editor.NONE) { pairConsumer.accept("editor", currentEditor.name().toLowerCase(Locale.ROOT)); } else { pairConsumer.accept("editor", null); } String searchString = membershipBrowser.getSearchString(); if (StringUtils.isBlank(searchString)) { pairConsumer.accept("search", null); } else { pairConsumer.accept("search", searchString); } }
From source file:com.puppycrawl.tools.checkstyle.internal.AllChecksTest.java
@Test public void testRequiredTokensAreSubsetOfDefaultTokens() throws Exception { for (Class<?> check : CheckUtil.getCheckstyleChecks()) { if (Check.class.isAssignableFrom(check)) { final Check testedCheck = (Check) check.getDeclaredConstructor().newInstance(); final int[] defaultTokens = testedCheck.getDefaultTokens(); final int[] requiredTokens = testedCheck.getRequiredTokens(); if (!isSubset(requiredTokens, defaultTokens)) { final String errorMessage = String.format(Locale.ROOT, "%s's required tokens must be a subset" + " of default tokens.", check.getName()); Assert.fail(errorMessage); }// w w w . ja v a2 s .c o m } } }
From source file:com.xpn.xwiki.web.SaveAction.java
/** * Saves the current document, updated according to the parameters sent in the request. * * @param context The current request {@link XWikiContext context}. * @return <code>true</code> if there was an error and the response needs to render an error page, * <code>false</code> if the document was correctly saved. * @throws XWikiException If an error occured: cannot communicate with the storage module, or cannot update the * document because the request contains invalid parameters. *//*from ww w. ja v a2 s. c om*/ public boolean save(XWikiContext context) throws XWikiException { XWiki xwiki = context.getWiki(); XWikiRequest request = context.getRequest(); XWikiDocument doc = context.getDoc(); EditForm form = (EditForm) context.getForm(); // Check save session int sectionNumber = 0; if (request.getParameter("section") != null && xwiki.hasSectionEdit(context)) { sectionNumber = Integer.parseInt(request.getParameter("section")); } // We need to clone this document first, since a cached storage would return the same object for the // following requests, so concurrent request might get a partially modified object, or worse, if an error // occurs during the save, the cached object will not reflect the actual document at all. doc = doc.clone(); String language = form.getLanguage(); // FIXME Which one should be used: doc.getDefaultLanguage or // form.getDefaultLanguage()? // String defaultLanguage = ((EditForm) form).getDefaultLanguage(); XWikiDocument tdoc; if (doc.isNew() || (language == null) || (language.equals("")) || (language.equals("default")) || (language.equals(doc.getDefaultLanguage()))) { // Saving the default document translation. // Need to save parent and defaultLanguage if they have changed tdoc = doc; } else { tdoc = doc.getTranslatedDocument(language, context); if ((tdoc == doc) && xwiki.isMultiLingual(context)) { // Saving a new document translation. tdoc = new XWikiDocument(doc.getDocumentReference()); tdoc.setLanguage(language); tdoc.setStore(doc.getStore()); } else if (tdoc != doc) { // Saving an existing document translation (but not the default one). // Same as above, clone the object retrieved from the store cache. tdoc = tdoc.clone(); } } if (doc.isNew()) { doc.setLocale(Locale.ROOT); if (doc.getDefaultLocale() == Locale.ROOT) { doc.setDefaultLocale( LocaleUtils.toLocale(context.getWiki().getLanguagePreference(context), Locale.ROOT)); } } try { tdoc.readFromTemplate(form.getTemplate(), context); } catch (XWikiException e) { if (e.getCode() == XWikiException.ERROR_XWIKI_APP_DOCUMENT_NOT_EMPTY) { context.put("exception", e); return true; } } if (sectionNumber != 0) { XWikiDocument sectionDoc = tdoc.clone(); sectionDoc.readFromForm(form, context); String sectionContent = sectionDoc.getContent() + "\n"; String content = tdoc.updateDocumentSection(sectionNumber, sectionContent); tdoc.setContent(content); tdoc.setComment(sectionDoc.getComment()); tdoc.setMinorEdit(sectionDoc.isMinorEdit()); } else { tdoc.readFromForm(form, context); } // TODO: handle Author String username = context.getUser(); tdoc.setAuthor(username); if (tdoc.isNew()) { tdoc.setCreator(username); } // Make sure we have at least the meta data dirty status tdoc.setMetaDataDirty(true); // Validate the document if we have xvalidate=1 in the request if ("1".equals(request.getParameter("xvalidate"))) { boolean validationResult = tdoc.validate(context); // If the validation fails we should show the "Inline form" edit mode if (validationResult == false) { // Set display context to 'edit' context.put("display", "edit"); // Set the action used by the "Inline form" edit mode as the context action. See #render(XWikiContext). context.setAction(tdoc.getDefaultEditMode(context)); // Set the document in the context context.put("doc", doc); context.put("cdoc", tdoc); context.put("tdoc", tdoc); // Force the "Inline form" edit mode. getCurrentScriptContext().setAttribute("editor", "inline", ScriptContext.ENGINE_SCOPE); return true; } } // Remove the redirect object if the save request doesn't update it. This allows users to easily overwrite // redirect place-holders that are created when we move pages around. if (tdoc.getXObject(REDIRECT_CLASS) != null && request.getParameter("XWiki.RedirectClass_0_location") == null) { tdoc.removeXObjects(REDIRECT_CLASS); } // We get the comment to be used from the document // It was read using readFromForm xwiki.saveDocument(tdoc, tdoc.getComment(), tdoc.isMinorEdit(), context); Job createJob = startCreateJob(tdoc.getDocumentReference(), form); if (createJob != null) { if (isAsync(request)) { if (Utils.isAjaxRequest(context)) { // Redirect to the job status URL of the job we have just launched. sendRedirect(context.getResponse(), String.format("%s/rest/jobstatus/%s?media=json", context.getRequest().getContextPath(), serializeJobId(createJob.getRequest().getId()))); } // else redirect normally and the operation will eventually finish in the background. // Note: It is preferred that async mode is called in an AJAX request that can display the progress. } else { // Sync mode, default, wait for the work to finish. try { createJob.join(); } catch (InterruptedException e) { throw new XWikiException(String.format( "Interrupted while waiting for template [%s] to be processed when creating the document [%s]", form.getTemplate(), tdoc.getDocumentReference()), e); } } } else { // Nothing more to do, just unlock the document. XWikiLock lock = tdoc.getLock(context); if (lock != null) { tdoc.removeLock(context); } } return false; }
From source file:es.emergya.ui.gis.FleetControlMapViewer.java
@Override public void actionPerformed(final ActionEvent e) { final CustomMapView mapViewLocal = this.mapView; SwingWorker<Object, Object> sw = new SwingWorker<Object, Object>() { @Override//from ww w . ja v a 2s . c o m protected Object doInBackground() throws Exception { try { final MouseEvent mouseEvent = FleetControlMapViewer.this.eventOriginal; if (e.getActionCommand().equals(// Centrar aqui i18n.getString(Locale.ROOT, "map.menu.centerHere"))) { mapViewLocal.zoomToFactor(mapViewLocal.getEastNorth(mouseEvent.getX(), mouseEvent.getY()), mapViewLocal.zoomFactor); } else if (e.getActionCommand().equals(// nueva incidencia i18n.getString("map.menu.newIncidence"))) { Incidencia f = new Incidencia(); f.setCreador(Authentication.getUsuario()); LatLon from = mapViewLocal.getLatLon(mouseEvent.getX(), mouseEvent.getY()); GeometryFactory gf = new GeometryFactory(); f.setGeometria(gf.createPoint(new Coordinate(from.lon(), from.lat()))); IncidenceDialog id = new IncidenceDialog(f, i18n.getString("Incidences.summary.title") + " " + i18n.getString("Incidences.nuevaIncidencia"), "tittleficha_icon_recurso"); id.setVisible(true); } else if (e.getActionCommand().equals(// ruta desde i18n.getString("map.menu.route.from"))) { routeDialog.showRouteDialog(mapViewLocal.getLatLon(mouseEvent.getX(), mouseEvent.getY()), null, mapViewLocal); } else if (e.getActionCommand().equals(// ruta hasta i18n.getString("map.menu.route.to"))) { routeDialog.showRouteDialog(null, mapViewLocal.getLatLon(mouseEvent.getX(), mouseEvent.getY()), mapViewLocal); } else if (e.getActionCommand().equals(// Actualizar gps i18n.getString("map.menu.gps"))) { if (!(menuObjective instanceof Recurso)) { return null; } GPSDialog sdsDialog = null; for (Frame f : Frame.getFrames()) { if (f instanceof GPSDialog) if (((GPSDialog) f).getRecurso().equals(menuObjective)) sdsDialog = (GPSDialog) f; } if (sdsDialog == null) sdsDialog = new GPSDialog((Recurso) menuObjective); sdsDialog.setVisible(true); sdsDialog.setExtendedState(JFrame.NORMAL); } else if (e.getActionCommand().equals(// Ficha i18n.getString("map.menu.summary"))) { if (log.isTraceEnabled()) { log.trace("Mostramos la ficha del objetivo del menu"); } if (menuObjective instanceof Recurso) { log.trace(">recurso"); SwingWorker<Object, Object> sw = new SwingWorker<Object, Object>() { @Override protected Object doInBackground() throws Exception { for (Frame f : JFrame.getFrames()) { if (f.getName().equals(((Recurso) menuObjective).getIdentificador()) && f instanceof SummaryDialog) { if (f.isShowing()) { f.toFront(); f.setExtendedState(JFrame.NORMAL); return null; } } } new SummaryDialog((Recurso) menuObjective).setVisible(true); return null; } }; sw.execute(); } else if (menuObjective instanceof Incidencia) { if (log.isTraceEnabled()) { log.trace(">incidencia"); } SwingWorker<Object, Object> sw = new SwingWorker<Object, Object>() { @Override protected Object doInBackground() throws Exception { for (Frame f : JFrame.getFrames()) { if (f.getName().equals(((Incidencia) menuObjective).getTitulo()) && f instanceof IncidenceDialog) { if (log.isTraceEnabled()) { log.trace("Ya lo tenemos abierto"); } if (f.isShowing()) { f.toFront(); f.setExtendedState(JFrame.NORMAL); } else { f.setVisible(true); f.setExtendedState(JFrame.NORMAL); } return null; } } if (log.isTraceEnabled()) { log.trace("Abrimos uno nuevo"); } new IncidenceDialog((Incidencia) menuObjective, i18n.getString("Incidences.summary.title") + " " + ((Incidencia) menuObjective).getTitulo(), "tittleficha_icon_recurso").setVisible(true); return null; } }; sw.execute(); } else { return null; } } else if (e.getActionCommand().equals( // Mas cercanos i18n.getString("map.menu.showNearest"))) { if (log.isTraceEnabled()) { log.trace("showNearest"); } if (menuObjective != null) { for (Frame f : JFrame.getFrames()) { String identificador = menuObjective.toString(); if (menuObjective instanceof Recurso) { identificador = ((Recurso) menuObjective).getIdentificador(); } if (menuObjective != null && f.getName().equals(identificador) && f instanceof NearestResourcesDialog && f.isDisplayable()) { if (log.isTraceEnabled()) { log.trace("Encontrado " + f); } if (f.isShowing()) { f.toFront(); f.setExtendedState(JFrame.NORMAL); } else { f.setVisible(true); f.setExtendedState(JFrame.NORMAL); } return null; } } } NearestResourcesDialog d; if (menuObjective instanceof Recurso) { d = new NearestResourcesDialog((Recurso) menuObjective, mapViewLocal); } else if (menuObjective instanceof Incidencia) { d = new NearestResourcesDialog((Incidencia) menuObjective, mapViewLocal.getLatLon(mouseEvent.getX(), mouseEvent.getY()), mapViewLocal); } else { d = new NearestResourcesDialog( mapViewLocal.getLatLon(mouseEvent.getX(), mouseEvent.getY()), mapViewLocal); } d.setVisible(true); } else { log.error("ActionCommand desconocido: " + e.getActionCommand()); } } catch (Throwable t) { log.error("Error al ejecutar la accion del menu contextual", t); } return null; } }; sw.execute(); }
From source file:net.sf.yal10n.analyzer.ExploratoryEncodingTest.java
/** * Test to load a reource bundle from a BOM encoded file. * @throws Exception any error/*from w w w . ja v a 2 s . c o m*/ */ @Test public void testResourceBundleWithBOM() throws Exception { ResourceBundle bundle = PropertyResourceBundle.getBundle("UTF8BOM", Locale.ROOT); Assert.assertEquals(3, bundle.keySet().size()); // Assert.assertEquals("first key", bundle.getString("testkey1")); // note: utf-8 bom read as iso-8859-1 Assert.assertEquals("first key", bundle.getString("\u00ef\u00bb\u00bftestkey1")); Assert.assertEquals("second key", bundle.getString("testkey2")); // note: utf-8 read as iso-8859-1 Assert.assertEquals("This file is encoded as UTF-8 with BOM \u00c3\u00a4.", bundle.getString("description")); }
From source file:com.netflix.discovery.shared.Applications.java
/** * Add the <em>application</em> to the list. * * @param app//from w ww . j a v a 2 s . c om * the <em>application</em> to be added. */ public void addApplication(Application app) { appNameApplicationMap.put(app.getName().toUpperCase(Locale.ROOT), app); addInstancesToVIPMaps(app); applications.add(app); }
From source file:com.puppycrawl.tools.checkstyle.AllChecksTest.java
@Test public void testRequiredTokensAreSubsetOfAcceptableTokens() throws Exception { Set<Class<?>> checkstyleChecks = getCheckstyleChecks(); for (Class<?> check : checkstyleChecks) { if (Check.class.isAssignableFrom(check)) { final Check testedCheck = (Check) check.getDeclaredConstructor().newInstance(); final int[] requiredTokens = testedCheck.getRequiredTokens(); final int[] acceptableTokens = testedCheck.getAcceptableTokens(); if (!isSubset(requiredTokens, acceptableTokens)) { String errorMessage = String.format(Locale.ROOT, "%s's required tokens must be a subset" + " of acceptable tokens.", check.getName()); Assert.fail(errorMessage); }/*from w w w .j a v a2 s. co m*/ } } }