List of usage examples for java.util ResourceBundle getBundle
@CallerSensitive public static final ResourceBundle getBundle(String baseName)
From source file:io.github.benas.projector.PropertiesInjectorImplTest.java
@Before public void setUp() throws Exception { System.setProperty("threshold", "30"); context = new InitialContext(); context.bind("foo.property", "jndi"); properties = new Properties(); properties.load(this.getClass().getClassLoader().getResourceAsStream("myProperties.properties")); resourceBundle = ResourceBundle.getBundle("i18n/messages"); propertiesInjector = new PropertiesInjectorBuilder().build(); bean = new Bean(); propertiesInjector.injectProperties(bean); }
From source file:es.mityc.firmaJava.configuracion.Configuracion.java
public static String getNombreDirExterno() { String resultado = ""; try {/* ww w . ja v a2 s . co m*/ ResourceBundle propiedadesPorDefecto = ResourceBundle.getBundle(FICHERO_RESOURCE); resultado = propiedadesPorDefecto.getString(CONFIG_EXT_DIR); } catch (MissingResourceException ex) { } return resultado; }
From source file:jatoo.resources.ResourcesTexts.java
/** * Creates a {@link ResourcesTexts} object using as base name the package of * the specified class. If a resource is not found, the fallback will be used * before returning.//from ww w. j av a 2s .co m * * @param clazz * the class that will provide the base name * @param fallback * the {@link ResourcesTexts} to be used in case a resource is not * found in this one */ public ResourcesTexts(final Class<?> clazz, final ResourcesTexts fallback) { logger = LogFactory.getLog(clazz); ResourceBundle resourceBundleTmp; try { resourceBundleTmp = ResourceBundle.getBundle(clazz.getPackage().getName() + ".texts"); } catch (Exception e) { resourceBundleTmp = null; logger.error("no texts for class: " + clazz.getName() + ", getText(key) will return the key", e); } this.clazz = clazz; this.fallback = fallback; this.resourceBundle = resourceBundleTmp; }
From source file:it.cnr.icar.eric.server.util.ServerResourceBundle.java
protected ServerResourceBundle() { // Load the resource bundle of default locale bundle = ResourceBundle.getBundle(BASE_NAME); }
From source file:fi.hoski.web.forms.RaceEntryServlet.java
@Override public void init(ServletConfig config) throws ServletException { super.init(config); repositoryBundle = ResourceBundle.getBundle("fi/hoski/datastore/repository/fields"); datastore = DatastoreServiceFactory.getDatastoreService(); entities = new DSUtilsImpl(datastore); mailService = new MailServiceImpl(); LogWrapper log = new ServletLog(this); races = new RacesImpl(log, datastore, entities, mailService); boatInfoFactory = new BoatInfoFactory(log, new DatastorePersistence(datastore)); boatInfoFactory.setURL("LYS", msg(Messages.LYSINFOURL), msg(Messages.LYSCLASSINFOURL)); boatInfoFactory.setURL("IRC", msg(Messages.IRCINFOURL), null); boatInfoFactory.setURL("ORC", msg(Messages.ORCINFOURL), null); String uc = config.getInitParameter("use-cookies"); useCookies = Boolean.parseBoolean(uc); log("useCookies=" + useCookies + " // " + uc); }
From source file:io.github.benas.todolist.web.servlet.user.account.UpdateAccountServlet.java
@Override public void init(ServletConfig servletConfig) throws ServletException { ApplicationContext applicationContext = WebApplicationContextUtils .getWebApplicationContext(servletConfig.getServletContext()); userService = applicationContext.getBean(UserService.class); resourceBundle = ResourceBundle.getBundle("todolist"); }
From source file:Unicode.java
/** Construct the object including its GUI */ public Unicode() { super("Unicode"); Container cp = getContentPane(); // Used both for Buttons and Menus ResourceBundle b = ResourceBundle.getBundle("UnicodeWidgets"); JButton quitButton, nextButton, prevButton; Panel p = new Panel(); // Make a grid, add one for labels. p.setLayout(new GridLayout(ROWS + 1, COLUMNS + 1)); DecimalFormat df2d = new DecimalFormat("00"); // Add first row, just column labels. p.add(new JLabel("")); for (int i = 0; i < COLUMNS; i++) p.add(new JLabel(Integer.toString(i, 16), JLabel.CENTER)); // Add subsequent rows, each with an offset label for (int i = 0; i < ROWS; i++) { JLabel l = new JLabel("0000"); // room for max, i.e. \uFFFF p.add(l);//from ww w . j a v a2 s . c o m rowLabs[i] = l; for (int j = 0; j < COLUMNS; j++) { JLabel pb = new JLabel(" "); buttons[j][i] = pb; p.add(pb); } } // ActionListeners for jumping around; used by buttons and menus ActionListener firster = new ActionListener() { public void actionPerformed(ActionEvent e) { gotoPage(startNum = 0); } }; ActionListener previouser = new ActionListener() { public void actionPerformed(ActionEvent e) { if (startNum > 0) gotoPage(startNum -= QUADSIZE); } }; ActionListener nexter = new ActionListener() { public void actionPerformed(ActionEvent e) { if (startNum < 65535) gotoPage(startNum += QUADSIZE); } }; ActionListener laster = new ActionListener() { public void actionPerformed(ActionEvent e) { gotoPage(65536 - QUADSIZE); } }; cp.add(BorderLayout.NORTH, p); fontName = new JLabel("Default font", JLabel.CENTER); cp.add(BorderLayout.CENTER, fontName); Panel q = new Panel(); cp.add(BorderLayout.SOUTH, q); q.add(prevButton = mkButton(b, "page.prev")); prevButton.addActionListener(previouser); q.add(nextButton = mkButton(b, "page.next")); nextButton.addActionListener(nexter); q.add(quitButton = mkButton(b, "exit")); quitButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setVisible(false); dispose(); System.exit(0); } }); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { setVisible(false); dispose(); System.exit(0); } }); MenuItem mi; // used in various spots MenuBar mb = new MenuBar(); setMenuBar(mb); String titlebar; try { titlebar = b.getString("program" + ".title"); } catch (MissingResourceException e) { titlebar = "Unicode Demo"; } setTitle(titlebar); ActionListener fontSelector = new ActionListener() { public void actionPerformed(ActionEvent e) { String font = e.getActionCommand(); mySetFont(font, FONTSIZE); } }; Menu fontMenu = mkMenu(b, "font"); // String[] fontList = Toolkit.getDefaultToolkit().getFontList(); String[] fontList = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(); for (int i = 0; i < fontList.length; i++) { fontMenu.add(mi = new MenuItem(fontList[i])); mi.addActionListener(fontSelector); } mb.add(fontMenu); gotoPageUI = new GoToPage("Unicode Page"); centre(gotoPageUI); Menu vm = mkMenu(b, "page"); vm.add(mi = mkMenuItem(b, "page", "first")); mi.addActionListener(firster); vm.add(mi = mkMenuItem(b, "page", "prev")); mi.addActionListener(previouser); vm.add(mi = mkMenuItem(b, "page", "next")); mi.addActionListener(nexter); vm.add(mi = mkMenuItem(b, "page", "last")); mi.addActionListener(laster); vm.add(mi = mkMenuItem(b, "page", "goto")); mi.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Unicode.this.gotoPageUI.setVisible(true); } }); mb.add(vm); Menu hm = mkMenu(b, "help"); hm.add(mi = mkMenuItem(b, "help", "about")); mb.setHelpMenu(hm); // needed for portability (Motif, etc.). pack(); // After packing the Frame, centre it on the screen. centre(this); // start at a known place mySetFont(fontList[0], FONTSIZE); gotoPage(startNum); }
From source file:csiro.pidsvc.core.Settings.java
private Settings(HttpServlet servlet) throws NullPointerException, IOException { // Retrieve manifest. if ((_servlet = servlet) != null) { ServletConfig config = _servlet.getServletConfig(); if (config != null) { ServletContext application = config.getServletContext(); _manifest = new Manifest(application.getResourceAsStream("/META-INF/MANIFEST.MF")); }/*from ww w. java 2 s . com*/ } // Retrieve settings. FileInputStream fis = null; try { InitialContext context = new InitialContext(); String settingsFile = (String) context.lookup("java:comp/env/" + SETTINGS_OPT); fis = new FileInputStream(settingsFile); _properties = new PropertyResourceBundle(fis); } catch (NamingException ex) { _logger.debug("Using default pidsvc.properties file."); _properties = ResourceBundle.getBundle("pidsvc"); } finally { if (fis != null) fis.close(); } // Get additional system properties. _serverProperties.put("serverJavaVersion", System.getProperty("java.version")); _serverProperties.put("serverJavaVendor", System.getProperty("java.vendor")); _serverProperties.put("javaHome", System.getProperty("java.home")); _serverProperties.put("serverOsArch", System.getProperty("os.arch")); _serverProperties.put("serverOsName", System.getProperty("os.name")); _serverProperties.put("serverOsVersion", System.getProperty("os.version")); }
From source file:org.pentaho.aggdes.ui.UIMain.java
@SuppressWarnings("unchecked") public void start(ApplicationContext context) throws XulException { XulDomContainer container;/* w w w . ja va2s. c om*/ //check to see if they've specified an alternate resource bundle String bundleStr = configuration.getResourceBundle(); ResourceBundle bundle = null; if (bundleStr != null) { try { bundle = ResourceBundle.getBundle(bundleStr); } catch (MissingResourceException e) { logger.error("Could not load Resource Bundle: " + bundleStr); //$NON-NLS-1$ } } //Set the look and feel based on configuration setLAF(); if (bundle != null) { container = xulLoader.loadXul("org/pentaho/aggdes/ui/resources/mainFrame.xul", bundle); //$NON-NLS-1$ } else { container = xulLoader.loadXul("org/pentaho/aggdes/ui/resources/mainFrame.xul"); //$NON-NLS-1$ } //generically register all Spring-initialized XulEventHandlers Map handlerMap = context.getBeansOfType(XulEventHandler.class); for (Object handler : handlerMap.values()) { container.addEventHandler((XulEventHandler) handler); } xulRunner.addContainer(container); xulRunner.initialize(); xulRunner.start(); }
From source file:it.cnr.icar.eric.client.admin.AdminResourceBundle.java
protected AdminResourceBundle() { // Load the resource bundle of default locale bundle = ResourceBundle.getBundle(BASE_NAME); }