List of usage examples for java.util ResourceBundle getString
public final String getString(String key)
From source file:ispok.pres.bb.VisitorEdit.java
private boolean loadVisitorDetails() { if (selectedVisitor == null) { FacesContext context = FacesContext.getCurrentInstance(); ResourceBundle bundle = ResourceBundle.getBundle("ispok/pres/inter/ispok", context.getViewRoot().getLocale()); FacesUtil.addMessage(new FacesMessage(FacesMessage.SEVERITY_WARN, bundle.getString("warn"), bundle.getString("no_item_selected"))); RequestContext.getCurrentInstance().addCallbackParam("showDialog", false); return false; }/*from www . ja v a 2s. co m*/ visitorDto = visitorService.getVisitorById(selectedVisitor.getId()); domicileDto = domicileService.getDomicileById(visitorDto.getDomicileId()); cityDto = cityService.getCityById(domicileDto.getCityId()); postalCodeDto = postalCodeService.getPostalCodeById(domicileDto.getPostalCodeId()); regionDto = regionService.getRegionById(domicileDto.getRegionId()); countryDto = countryService.getCountryById(domicileDto.getCountryId()); citizenshipDto = countryService.getCountryById(visitorDto.getCitizenshipId()); if (Objects.equals(countryDto.getId(), citizenshipDto.getId())) { foreigner = false; } else { foreigner = true; } foreignerNewVal = foreigner; visitDtos = null; cashgameSessionDtos = null; tournamentSessionDtos = null; RequestContext.getCurrentInstance().addCallbackParam("showDialog", true); return true; }
From source file:fr.ippon.wip.portlet.WIPConfigurationPortlet.java
/** * This class will try to build an URL from a string and store an error if * the URL is malformed or empty/*from w w w . j a v a 2s . c o m*/ * * @param varName * The name of the variable, used to map errors correctly * @param urlAsString * The String to convert into a list * @param errors * The map containing the error messages * @param rb * The resource bundle used to set the error message * @return The URL built from the given String */ private void checkURL(String varName, String urlAsString, Map<String, String> errors, ResourceBundle rb) { if (StringUtils.isEmpty(urlAsString)) { errors.put(varName, rb.getString("wip.errors." + varName + ".empty")); return; } try { new URL(urlAsString); } catch (MalformedURLException e1) { errors.put(varName, rb.getString("wip.errors." + varName + ".malformed")); } }
From source file:com.puppycrawl.tools.checkstyle.MainTest.java
@Test public void testExistingTargetFileXmlOutput() throws Exception { exit.checkAssertionAfterwards(new Assertion() { @Override// www.j a va 2 s .c o m 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); final ResourceBundle compilationProperties = ResourceBundle.getBundle("checkstylecompilation"); String version = compilationProperties.getString("checkstyle.compile.version"); assertEquals(String.format(Locale.ROOT, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>%n" + "<checkstyle version=\"%s\">%n" + "<file name=\"%s\">%n" + "</file>%n" + "</checkstyle>%n", version, expectedPath), systemOut.getLog()); assertEquals("", systemErr.getLog()); } }); Main.main("-c", "src/test/resources/com/puppycrawl/tools/checkstyle/config-classname.xml", "-f", "xml", "src/test/resources/com/puppycrawl/tools/checkstyle/InputMain.java"); }
From source file:com.stratelia.silverpeas.silverstatistics.control.SilverStatisticsManager.java
/** * Method declaration//from w w w . j av a 2 s . co m * @param resource * @see */ private void initDirectoryToScan(java.util.ResourceBundle resource) { try { // read the directories // -------------------------- int i = 0; String directoryPath = resource.getString("SilverPeasDataPath" + Integer.toString(i)); // for each directory while (directoryPath != null) { // Test existence File dir = new File(directoryPath); if (!dir.isDirectory()) { throw new Exception("silverstatistics initDirectoryToScan" + directoryPath); } directoryToScan.add(directoryPath); i++; try { directoryPath = resource.getString("SilverPeasDataPath" + Integer.toString(i)); } catch (MissingResourceException ex) { directoryPath = null; } } } catch (Exception e) { SilverTrace.error("silverstatistics", "SilverStatisticsManager.initDirectoryToScan()", "silvertrace.ERR_INIT_APPENDER_FROM_PROP", e); } }
From source file:com.sonicle.webtop.mail.ICalendarRequest.java
public String getHtmlView(Locale locale, String serviceVersion, String laf, ResourceBundle bundle) { String htmlmsg = ""; if (method.equals("REQUEST")) { htmlmsg = MessageFormat.format(bundle.getString("tpl.ical.msg.invited"), StringEscapeUtils.escapeHtml4(organizerCN)); } else if (method.equals("REPLY")) { Parameter param = icalAttendees[0].getParameter("PARTSTAT"); String v = param.getValue(); if (v.equals("ACCEPTED")) htmlmsg = MessageFormat.format(bundle.getString("tpl.ical.msg.accepted"), StringEscapeUtils.escapeHtml4(attendeesCN[0])); else if (v.equals("DECLINED")) htmlmsg = MessageFormat.format(bundle.getString("tpl.ical.msg.declined"), StringEscapeUtils.escapeHtml4(attendeesCN[0])); else/*w w w. j a v a 2 s. co m*/ htmlmsg = MessageFormat.format(bundle.getString("tpl.ical.msg.answered"), StringEscapeUtils.escapeHtml4(attendeesCN[0])); } else if (method.equals("CANCEL")) { htmlmsg = MessageFormat.format(bundle.getString("tpl.ical.msg.canceled"), StringEscapeUtils.escapeHtml4(organizerCN)); } String htmlorganizer = "<span class='" + getParstatClassName(icalOrganizer) + "'></span> " + StringEscapeUtils.escapeHtml4(organizer); StringBuilder htmlattendees = new StringBuilder(); if (attendees != null) { for (int i = 0; i < attendees.length; ++i) { String s = attendees[i]; Attendee a = icalAttendees[i]; htmlattendees.append("<span class='" + getParstatClassName(a) + "'></span> "); htmlattendees.append(s); htmlattendees.append("<br>"); } } return String.format(locale, "<html><head><meta content='text/html; charset=utf-8' http-equiv='Content-Type'>" + "<link rel=\"stylesheet\" type=\"text/css\" href=\"resources/com.sonicle.webtop.mail/" + serviceVersion + "/laf/" + laf + "/service.css\" />" + "</head><body>" + "<table border=0 cellpadding=4 class=wtmail-ical-tabletitle>" + "<tr><td class=wtmail-ical-title>%s</td></tr>" + "</table>" + "<table border=0 cellpadding=4 class=wtmail-ical-tabledata>" + "<tr><td class=wtmail-ical-label>%s</td><td class=wtmail-ical-data>%s</td></tr>" + "<tr><td class=wtmail-ical-label>%s</td><td class=wtmail-ical-data>%s</td></tr>" + //"<tr><td class=wtmail-ical-label>Quando:</td><td>"+sDtStart+"</td></tr>"+ "<tr><td class=wtmail-ical-label>%s</td><td class=wtmail-ical-data>%s</td></tr>" + "<tr><td class=wtmail-ical-label>%s</td><td class=wtmail-ical-data>%s</td></tr>" + // "<tr><td class=wtmail-ical-label>Durata:</td><td class=wtmail-ical-data>%s</td></tr>"+ "<tr><td class=wtmail-ical-label>%s</td><td class=wtmail-ical-data>%s</td></tr>" + "<tr><td class=wtmail-ical-label>%s</td><td class=wtmail-ical-data>%s</td></tr>" + "<tr><td class=wtmail-ical-label>%s</td><td class=wtmail-ical-data>%s</td></tr>" + "</table>" + "</body></html>", htmlmsg, StringEscapeUtils.escapeHtml4(bundle.getString("tpl.ical.event.summary")), StringEscapeUtils.escapeHtml4(summary), StringEscapeUtils.escapeHtml4(bundle.getString("tpl.ical.event.location")), StringEscapeUtils.escapeHtml4(location), StringEscapeUtils.escapeHtml4(bundle.getString("tpl.ical.event.start")), StringEscapeUtils.escapeHtml4(String.format(locale, "%tc", dateStart)), StringEscapeUtils.escapeHtml4(bundle.getString("tpl.ical.event.end")), StringEscapeUtils.escapeHtml4(String.format(locale, "%tc", dateEnd)), // htmlduration, StringEscapeUtils.escapeHtml4(bundle.getString("tpl.ical.event.organizer")), htmlorganizer, StringEscapeUtils.escapeHtml4(bundle.getString("tpl.ical.event.description")), hyperlinkText(StringEscapeUtils.escapeHtml4(description), "_new"), StringEscapeUtils.escapeHtml4(bundle.getString("tpl.ical.event.attendees")), htmlattendees); }
From source file:com.stratelia.silverpeas.silverstatistics.control.SilverStatisticsManager.java
/** * Init attributes./* w w w . j a va 2s . c o m*/ * This method is invoked by the IoC container. Don't invoke it! */ public void initSilverStatisticsManager() { directoryToScan = new ArrayList<String>(); try { statsConfig = new StatisticsConfig(); try { statsConfig.init(); if (!statsConfig.isValidConfigFile()) { SilverTrace.error("silverstatistics", "SilverStatisticsManager.initSilverStatistics", "silverstatistics.MSG_CONFIG_FILE"); } } catch (SilverStatisticsConfigException e) { SilverTrace.error("silverstatistics", "SilverStatisticsManager.initSilverStatistics", "silverstatistics.MSG_CONFIG_FILE", e); } ResourceBundle resources = FileUtil .loadBundle("com.stratelia.silverpeas.silverstatistics.SilverStatistics", Locale.getDefault()); initSchedulerStatistics(resources.getString("scheduledGetStatVolumeTimeStamp"), STAT_VOLUME_JOB_NAME, "doGetStatVolume"); initSchedulerStatistics(resources.getString("scheduledGetStatSizeTimeStamp"), STAT_SIZE_JOB_NAME, "doGetStatSize"); initSchedulerStatistics(resources.getString("scheduledCumulStatTimeStamp"), STAT_CUMUL_JOB_NAME, "doCumulStat"); initDirectoryToScan(resources); } catch (Exception ex) { SilverTrace.error("silverstatistics", "SilverStatisticsManager.initSilverStatistics", "root.EX_CLASS_NOT_INITIALIZED", ex); } }
From source file:JAXRPublishPostal.java
/** * Creates an organization, its classification, and its * services, and saves it to the registry. The primary * contact has a postal address.//from w w w. ja v a 2 s . co m * * @param username the username for the registry * @param password the password for the registry */ public void executePublish(String username, String password) { RegistryService rs = null; BusinessLifeCycleManager blcm = null; BusinessQueryManager bqm = null; try { rs = connection.getRegistryService(); blcm = rs.getBusinessLifeCycleManager(); bqm = rs.getBusinessQueryManager(); System.out.println("Got registry service, query " + "manager, and life cycle manager"); // Get authorization from the registry PasswordAuthentication passwdAuth = new PasswordAuthentication(username, password.toCharArray()); HashSet<PasswordAuthentication> creds = new HashSet<PasswordAuthentication>(); creds.add(passwdAuth); connection.setCredentials(creds); System.out.println("Established security credentials"); ResourceBundle bundle = ResourceBundle.getBundle("JAXRExamples"); // Create organization name and description InternationalString s = blcm.createInternationalString(bundle.getString("postal.org.name")); Organization org = blcm.createOrganization(s); s = blcm.createInternationalString(bundle.getString("org.description")); org.setDescription(s); // Create primary contact, set name User primaryContact = blcm.createUser(); PersonName pName = blcm.createPersonName(bundle.getString("postal.person.name")); primaryContact.setPersonName(pName); // Set primary contact phone number TelephoneNumber tNum = blcm.createTelephoneNumber(); tNum.setNumber(bundle.getString("phone.number")); Collection<TelephoneNumber> phoneNums = new ArrayList<TelephoneNumber>(); phoneNums.add(tNum); primaryContact.setTelephoneNumbers(phoneNums); // Set primary contact email address EmailAddress emailAddress = blcm.createEmailAddress(bundle.getString("postal.email.address")); Collection<EmailAddress> emailAddresses = new ArrayList<EmailAddress>(); emailAddresses.add(emailAddress); primaryContact.setEmailAddresses(emailAddresses); // create postal address for primary contact String streetNumber = bundle.getString("postal.streetNumber"); String street = bundle.getString("postal.street"); String city = bundle.getString("postal.city"); String state = bundle.getString("postal.state"); String country = bundle.getString("postal.country"); String postalCode = bundle.getString("postal.postalCode"); String type = bundle.getString("postal.type"); PostalAddress postAddr = blcm.createPostalAddress(streetNumber, street, city, state, country, postalCode, type); Collection<PostalAddress> postalAddresses = new ArrayList<PostalAddress>(); postalAddresses.add(postAddr); primaryContact.setPostalAddresses(postalAddresses); // Set primary contact for organization org.setPrimaryContact(primaryContact); // Set classification scheme to NAICS, using // well-known UUID of ntis-gov:naics:1997 String uuid_naics = "uuid:C0B9FE13-179F-413D-8A5B-5004DB8E5BB2"; ClassificationScheme cScheme = (ClassificationScheme) bqm.getRegistryObject(uuid_naics, LifeCycleManager.CLASSIFICATION_SCHEME); // Create and add classification if (cScheme != null) { InternationalString sn = blcm.createInternationalString(bundle.getString("classification.name")); Classification classification = blcm.createClassification(cScheme, sn, bundle.getString("classification.value")); Collection<Classification> classifications = new ArrayList<Classification>(); classifications.add(classification); org.addClassifications(classifications); } else { System.out.println("Classification scheme not found, " + "not classifying organization"); } // Create services and service Collection<Service> services = new ArrayList<Service>(); s = blcm.createInternationalString(bundle.getString("service.name")); Service service = blcm.createService(s); s = blcm.createInternationalString(bundle.getString("service.description")); service.setDescription(s); // Create service bindings; don't validate this fake URL Collection<ServiceBinding> serviceBindings = new ArrayList<ServiceBinding>(); ServiceBinding binding = blcm.createServiceBinding(); s = blcm.createInternationalString(bundle.getString("svcbinding.description")); binding.setDescription(s); // Allow us to publish a fictitious URI without an error binding.setValidateURI(false); binding.setAccessURI(bundle.getString("svcbinding.accessURI")); serviceBindings.add(binding); // Add service bindings to service service.addServiceBindings(serviceBindings); // Add service to services, then add services to organization services.add(service); org.addServices(services); // Add organization and submit to registry // Retrieve key if successful Collection<Organization> orgs = new ArrayList<Organization>(); orgs.add(org); BulkResponse response = blcm.saveOrganizations(orgs); Collection exceptions = response.getExceptions(); if (exceptions == null) { System.out.println("Organization saved"); Collection keys = response.getCollection(); for (Object k : keys) { Key orgKey = (Key) k; String id = orgKey.getId(); System.out.println("Organization key is " + id); } } else { for (Object e : exceptions) { Exception exception = (Exception) e; System.err.println("Exception on save: " + exception.toString()); } } } catch (Exception e) { e.printStackTrace(); } finally { // At end, close connection to registry if (connection != null) { try { connection.close(); } catch (JAXRException je) { } } } }
From source file:com.inkubator.hrm.web.organisation.AnnouncementFormController.java
public void handingAttachmentUpload(FileUploadEvent fileUploadEvent) { Map<String, String> results = uploadFilesUtil.checkUploadFileSizeLimit(fileUploadEvent.getFile()); if (StringUtils.equals(results.get("result"), "true")) { UploadedFile attachmentFile = fileUploadEvent.getFile(); model.setAttachmentFile(attachmentFile); model.setAttachmentFileName(attachmentFile.getFileName()); } else {/*from w w w . j ava2 s . c o m*/ ResourceBundle messages = ResourceBundle.getBundle("Messages", new Locale(FacesUtil.getSessionAttribute(HRMConstant.BAHASA_ACTIVE).toString())); String errorMsg = messages.getString("global.file_size_should_not_bigger_than") + " " + results.get("sizeMax"); MessagesResourceUtil.setMessagesFromException(FacesMessage.SEVERITY_ERROR, "global.error", errorMsg, FacesUtil.getSessionAttribute(HRMConstant.BAHASA_ACTIVE).toString()); } }
From source file:org.jfree.chart.demo.JFreeChartDemo.java
/** * Creates a menubar./* ww w . ja v a2s.com*/ * * @param resources localised resources. * * @return the menu bar. */ private JMenuBar createMenuBar(final ResourceBundle resources) { // create the menus final JMenuBar menuBar = new JMenuBar(); String label; Character mnemonic; // first the file menu label = resources.getString("menu.file"); mnemonic = (Character) resources.getObject("menu.file.mnemonic"); final JMenu fileMenu = new JMenu(label, true); fileMenu.setMnemonic(mnemonic.charValue()); label = resources.getString("menu.file.exit"); mnemonic = (Character) resources.getObject("menu.file.exit.mnemonic"); final JMenuItem exitItem = new JMenuItem(label, mnemonic.charValue()); exitItem.setActionCommand(EXIT_COMMAND); exitItem.addActionListener(this); fileMenu.add(exitItem); // then the help menu label = resources.getString("menu.help"); mnemonic = (Character) resources.getObject("menu.help.mnemonic"); final JMenu helpMenu = new JMenu(label); helpMenu.setMnemonic(mnemonic.charValue()); label = resources.getString("menu.help.about"); mnemonic = (Character) resources.getObject("menu.help.about.mnemonic"); final JMenuItem aboutItem = new JMenuItem(label, mnemonic.charValue()); aboutItem.setActionCommand(ABOUT_COMMAND); aboutItem.addActionListener(this); helpMenu.add(aboutItem); // finally, glue together the menu and return it menuBar.add(fileMenu); menuBar.add(helpMenu); return menuBar; }
From source file:com.ibm.ids.example.ShowResult.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { String safename = StringEscapeUtils.escapeHtml4(request.getParameter("name")); Locale locale = request.getLocale(); ResourceBundle messages = ResourceBundle.getBundle("com.ibm.ids.example.Messages", locale); response.setContentType("text/html"); PrintWriter out = response.getWriter(); // log what we received in a vulnerable way try {//from w w w . ja v a 2 s . c om writeToVulnerableSink(getVulnerableSource(safename)); } catch (Exception e) { // ignore this, we're just logging, right? } out.println("<HTML><HEAD><TITLE>Hello World</TITLE></HEAD><BODY>"); if (safename == null) { String nobody = messages.getString("nobody"); out.println(nobody); } else { out.println("Hello, " + safename); } out.println("</BODY></HTML>"); }