List of usage examples for java.util ResourceBundle getString
public final String getString(String key)
From source file:net.sf.yal10n.analyzer.ExploratoryEncodingTest.java
/** * Test to load a resource bundle from a BOM encoded file that starts with a blank line. * @throws Exception any error/* w w w.j a v a 2s . co m*/ */ @Test public void testResourceBundleWithBOMandBlankLine() throws Exception { ResourceBundle bundle = PropertyResourceBundle.getBundle("UTF8BOMwithBlankLine", Locale.ROOT); Assert.assertEquals(4, bundle.keySet().size()); Assert.assertEquals("first key", bundle.getString("testkey1")); 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.yottaa.newrelic.PostJob.java
/** * *//* w ww . java 2s . c o m*/ public void postJobMethod() { DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss"); logger.info("Posting Yottaa metrics to New Relic @ " + dateFormat.format(System.currentTimeMillis())); ResourceBundle bundle = ResourceBundle.getBundle("yottaa"); YottaaHttpClientPublic yottaaHttpClientPublic = new YottaaHttpClientPublic( bundle.getString("yottaaAPIKey")); YottaaHttpClientPartner yottaaHttpClientPartner = new YottaaHttpClientPartner(false); // Prepare JSON data that will be posted to New Relic JSONObject jsonData = new JSONObject(); JSONObject agentData = new JSONObject(); agentData.put("host", "apps.yottaa.com"); agentData.put("pid", 0); agentData.put("version", "1.0.0"); jsonData.put("agent", agentData); JSONArray components = new JSONArray(); JSONArray sites = yottaaHttpClientPartner.getAccountSites(bundle.getString("yottaaUserId")); logger.info("Total number of sites is " + sites.size() + "."); for (int i = 0, len = sites.size(); i < len; i++) { JSONObject siteObj = (JSONObject) sites.get(i); String host = (String) siteObj.get("host"); logger.info("Retrieve last sample for host " + host + "(" + i + " of " + len + ")."); JSONObject lastSampleMetrics = yottaaHttpClientPublic.getLastSample(host); JSONObject yottaaMetricsObj = new JSONObject(); yottaaMetricsObj.put("guid", "com.yottaa.Yottaa"); yottaaMetricsObj.put("duration", 60); //yottaaMetricsObj.put("name", host); yottaaMetricsObj.put("name", (String) lastSampleMetrics.get("name")); JSONObject yottaaMetricsData = new JSONObject(); // Http Metrics if (lastSampleMetrics.get("http_metrics") != null) { JSONObject httpMetrics = (JSONObject) lastSampleMetrics.get("http_metrics"); JSONObject httpMetricsFirstByte = (JSONObject) httpMetrics.get("first_byte"); JSONObject httpMetricsWait = (JSONObject) httpMetrics.get("wait"); JSONObject httpMetricsDNS = (JSONObject) httpMetrics.get("dns"); JSONObject httpMetricsConnect = (JSONObject) httpMetrics.get("connect"); yottaaMetricsData.put("Component/Http Metrics/Time To First Byte[sec]", Double.parseDouble(httpMetricsFirstByte.get("average").toString())); yottaaMetricsData.put("Component/Http Metrics/Waiting Time[sec]", Double.parseDouble(httpMetricsWait.get("average").toString())); yottaaMetricsData.put("Component/Http Metrics/DNS Time[sec]", Double.parseDouble(httpMetricsDNS.get("average").toString())); yottaaMetricsData.put("Component/Http Metrics/Connection Time[sec]", Double.parseDouble(httpMetricsConnect.get("average").toString())); } // Issue Metrics if (lastSampleMetrics.get("issue_metrics") != null) { JSONObject issueMetrics = (JSONObject) lastSampleMetrics.get("issue_metrics"); yottaaMetricsData.put("Component/Issue Metrics/Critical Error Count[times]", Integer.parseInt(issueMetrics.get("critical_error_count").toString())); yottaaMetricsData.put("Component/Issue Metrics/Error Count[times]", Integer.parseInt(issueMetrics.get("error_count").toString())); yottaaMetricsData.put("Component/Issue Metrics/Info Count[times]", Integer.parseInt(issueMetrics.get("info_count").toString())); yottaaMetricsData.put("Component/Issue Metrics/Warning Count[times]", Integer.parseInt(issueMetrics.get("warning_count").toString())); } //Webpage Metrics if (lastSampleMetrics.get("webpage_metrics") != null) { JSONObject webpageMetrics = (JSONObject) lastSampleMetrics.get("webpage_metrics"); JSONObject webpageMetricsTimeToRender = (JSONObject) webpageMetrics.get("time_to_render"); JSONObject webpageMetricsTimeToDisplay = (JSONObject) webpageMetrics.get("time_to_display"); JSONObject webpageMetricsTimeToInteract = (JSONObject) webpageMetrics.get("time_to_interact"); yottaaMetricsData.put("Component/Webpage Metrics/Time To Render[sec]", Double.parseDouble(webpageMetricsTimeToRender.get("average").toString())); yottaaMetricsData.put("Component/Webpage Metrics/Time To Display[sec]", Double.parseDouble(webpageMetricsTimeToDisplay.get("average").toString())); yottaaMetricsData.put("Component/Webpage Metrics/Time To Interact[sec]", Double.parseDouble(webpageMetricsTimeToInteract.get("average").toString())); } yottaaMetricsObj.put("metrics", yottaaMetricsData); components.add(yottaaMetricsObj); logger.info("Finished Retrieve last sample for host " + host + "(" + i + " of " + len + ")."); } jsonData.put("components", components); logger.info("Posted Yottaa Metrics :" + jsonData); this.newrelicPost(null, bundle.getString("newrelicLicenseKey"), jsonData); }
From source file:es.pode.administracion.presentacion.descargas.crear.CrearDescargaControllerImpl.java
private String compruebaDescripcion(String descripcion, HttpServletRequest request) { ResourceBundle resources = ResourceBundle.getBundle("application-resources", (Locale) request.getSession().getAttribute(ConstantesAgrega.DEFAULT_LOCALE)); if (descripcion == null || descripcion.equals(resources.getString(descripcionPorDefecto))) { descripcion = VACIA;//from w w w . j av a 2 s . c o m } return descripcion; }
From source file:org.codehaus.mojo.chronos.chart.HistogramChartGenerator.java
protected final JFreeChart createHistogramChart(ResponsetimeSamples samples, String label, ResourceBundle bundle, ReportConfig config) { HistogramDataset histogramdataset = new HistogramDataset(); double[] sampleArray = samples.extractResponsetimes(config.getResponsetimedivider()); histogramdataset.addSeries(label, sampleArray, BINS); HistogramDataset dataset = histogramdataset; JFreeChart chart = ChartFactory.createHistogram(bundle.getString("chronos.label.histogram"), bundle.getString("chronos.label.histogram.x"), bundle.getString("chronos.label.histogram.y"), dataset, PlotOrientation.VERTICAL, true, false, false); XYPlot xyplot = (XYPlot) chart.getPlot(); xyplot.setForegroundAlpha(FOREGROUND_ALPHA); XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer(); xybarrenderer.setDrawBarOutline(false); if (config.isShowpercentile()) { String label1 = bundle.getString("chronos.label.percentile95.arrow"); double value = samples.getPercentile95(config.getResponsetimedivider()); ChartUtil.addDomainMarker(xyplot, label1, value); }/*w w w . j a v a 2s . c o m*/ if (config.isShowaverage()) { String label2 = bundle.getString("chronos.label.average.arrow"); double value = samples.getAverage(config.getResponsetimedivider()); ChartUtil.addDomainMarker(xyplot, label2, value); } return chart; }
From source file:com.inkubator.hrm.web.converter.BatchJobConverter.java
@Override public String getAsString(FacesContext context, UIComponent component, Object value) { ResourceBundle resourceBundle = ResourceBundle.getBundle("Messages", new Locale(FacesUtil.getSessionAttribute(HRMConstant.BAHASA_ACTIVE).toString())); String message = StringUtils.EMPTY; String data = (String) value; switch (data) { case "jobSynchDataFingerRealization": message = resourceBundle.getString("batch.jobSynchDataFingerRealization"); break;//w w w . ja v a 2 s . c o m case "jobPaySalaryUpload": message = resourceBundle.getString("batch.jobPaySalaryUpload"); break; case "jobPayAttendanceUpload": message = resourceBundle.getString("batch.jobPayAttendanceUpload"); break; case "jobPayTempOvertimeUpload": message = resourceBundle.getString("batch.jobPayTempOvertimeUpload"); break; case "jobPayEmployeeCalculation": message = resourceBundle.getString("batch.jobPayEmployeeCalculation"); break; case "jobPayReceiverAccount": message = resourceBundle.getString("batch.jobPayReceiverAccount"); break; case "jobMonthEndPayroll": message = resourceBundle.getString("batch.jobMonthEndPayroll"); break; case "jobLoanUpload": message = resourceBundle.getString("batch.jobLoanUpload"); break; case "jobUnregCalculation": message = resourceBundle.getString("batch.jobUnregCalculation"); break; case "jobUnregPayroll": message = resourceBundle.getString("batch.jobUnregPayroll"); break; case "jobAnnouncementLog": message = resourceBundle.getString("batch.jobAnnouncementLog"); break; case "jobEmailingAnnouncementNotSent": message = resourceBundle.getString("batch.jobEmailingAnnouncementNotSent"); break; default: message = data; break; } return message; }
From source file:Unicode.java
/** Convenience routine to make a MenuItem */ public MenuItem mkMenuItem(ResourceBundle b, String menu, String name) { String miLabel;// w ww . j a va2 s . c om try { miLabel = b.getString(menu + "." + name + ".label"); } catch (MissingResourceException e) { miLabel = name; } String key = null; try { key = b.getString(menu + "." + name + ".key"); } catch (MissingResourceException e) { key = null; } if (key == null) return new MenuItem(miLabel); else return new MenuItem(miLabel, new MenuShortcut(key.charAt(0))); }
From source file:org.gitana.platform.client.Gitana.java
/** * Authenticates to Gitana using the given credentials. * * These credentials can be any of the following: * * username/password (assumes the default domain of the platform) * user id/password (assumes the default domain of the platform) * domain qualified username / password * domain qualified id / password/*from w ww . ja v a2 s.c om*/ * credential key / credential secret * * This utilizes the OAuth2 resource owner username/password flow. * * @param username * @param password */ public Platform authenticate(String username, String password) { // if username and password are null, authenticate using credentials supplied in properties file if (username == null && password == null) { ResourceBundle bundle = readBundle("gitana"); username = bundle.getString("gitana.credentials.username"); password = bundle.getString("gitana.credentials.password"); } RemoteImpl remote = createRemote(); // apply OAuth2 HTTP Method Executor OAuth2HttpMethodExecutor httpMethodExecutor = new OAuth2HttpMethodExecutor(); httpMethodExecutor.setUri(this.baseUrl + "/oauth/token"); httpMethodExecutor.setClientId(this.clientKey); httpMethodExecutor.setClientSecret(this.clientSecret); httpMethodExecutor.setResourceOwnerPasswordCredentialsFlow(username, password); //httpMethodExecutor.setSignatureMethod(OAuth2SignatureMethod.QUERY_PARAMETER); httpMethodExecutor.setRequestedScope("api"); remote.setHttpMethodExecutor(httpMethodExecutor); // build driver instance Driver driver = new Driver(remote); DriverContext.setDriver(driver); // perform handshake and populate driver with info populateAuthenticationInformation(driver); // read back the platform return loadPlatform(driver); }
From source file:edu.ucsb.nceas.metacat.lsid.LSIDAuthorityMetaData.java
/** * given a query string, query MetaCat and return the response *///www .j av a 2 s . com private Reader getMetaCatResponse(String query) { logger.debug("Querying the metacat server."); // get the metacat server from the configuration file // ResourceBundle rb = ResourceBundle.getBundle("metacat-lsid"); String url = rb.getString("metacatserver"); Reader r = null; try { Metacat m = MetacatFactory.createMetacatConnection(url); r = m.query(new StringReader(query)); } catch (MetacatInaccessibleException mie) { logger.error("Metacat Inaccessible:\n" + mie.getMessage()); } catch (Exception e) { logger.error("General exception:\n" + e.getMessage()); } return r; }
From source file:edu.ucsb.nceas.metacat.lsid.LSIDAuthorityMetaData.java
/** * There's more than one metdata document *//*from w w w .ja v a2s . c o m*/ private ByteArrayInputStream metaDataList(String contents, LSID theLSID) { ResourceBundle rb = ResourceBundle.getBundle("metacat"); String metadataLabels = rb.getString("metadatalabels"); String result = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" \n" + " xmlns:dc=\"http://purl.org/dc/elements/1.1/\" \n" + " xmlns:pred=\"urn:lsid:i3c.org:predicates:\" xmlns=\"urn:lsid:" + metadataLabels + ":predicates:\"> \n" + "<rdf:Description rdf:about=\"" + theLSID.getLsid() + "\"> \n" + " <pred:title xmlns:pred=\"http://purl.org/dc/elements/1.1/\">There is more than one metadata document for this LSID - which confuses me right now. Try again soon and I'll be less confused.</pred:title>\n" + "</rdf:Description>\n" + "</rdf:RDF>\n"; return new ByteArrayInputStream(result.getBytes()); }
From source file:es.pode.empaquetador.presentacion.avanzado.organizaciones.gestor.GestorOrganizacionesControllerImpl.java
public final java.lang.String selectAction(ActionMapping mapping, es.pode.empaquetador.presentacion.avanzado.organizaciones.gestor.SelectActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { /*//from w w w . ja v a 2 s . c om * Metodo de decision para el action. Analiza los parametros * actionSubmit (value de los botones submit) para redirigir al caso de uso * correspondiente. El actionSubmit llegara * internacionalizado, por lo que es necesario acceder al ResouceBundle * para obtener el valor correcto en la comparacion. */ String result = null; String actionSubmit = form.getAction(); java.util.Locale locale = (Locale) request.getSession().getAttribute(ConstantesAgrega.DEFAULT_LOCALE); ResourceBundle i18n = ResourceBundle.getBundle("application-resources", locale); if (form.getAction() == (null)) { throw new ValidatorException("{portal_empaquetado.exception}"); } else if (actionSubmit.equals(i18n.getString("portal_empaquetado_gestorOrganizaciones.aceptar"))) { result = "Crear"; } else if (actionSubmit.equals(i18n.getString("portal_empaquetado_gestorOrganizaciones.cancelar"))) { result = "Cancelar"; } else if (actionSubmit.equals(i18n.getString("portal_empaquetado_gestorOrganizaciones.principal"))) { result = "Principal"; } else if (actionSubmit.equals(i18n.getString("portal_empaquetado_gestorOrganizaciones.eliminar"))) { result = "Eliminar"; } return result; }