Java Code Examples for java.util.ResourceBundle
The following examples show how to use
java.util.ResourceBundle.
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: openjdk-jdk8u-backup Author: AdoptOpenJDK File: ComponentOrientation.java License: GNU General Public License v2.0 | 6 votes |
/** * Returns the orientation appropriate for the given ResourceBundle's * localization. Three approaches are tried, in the following order: * <ol> * <li>Retrieve a ComponentOrientation object from the ResourceBundle * using the string "Orientation" as the key. * <li>Use the ResourceBundle.getLocale to determine the bundle's * locale, then return the orientation for that locale. * <li>Return the default locale's orientation. * </ol> * * @deprecated As of J2SE 1.4, use {@link #getOrientation(java.util.Locale)}. */ @Deprecated public static ComponentOrientation getOrientation(ResourceBundle bdl) { ComponentOrientation result = null; try { result = (ComponentOrientation)bdl.getObject("Orientation"); } catch (Exception e) { } if (result == null) { result = getOrientation(bdl.getLocale()); } if (result == null) { result = getOrientation(Locale.getDefault()); } return result; }
Example #2
Source Project: dragonwell8_jdk Author: alibaba File: TestBug4179766.java License: GNU General Public License v2.0 | 6 votes |
/** * Ensure the resource cache is working correctly for a single * resource from a single loader. If we get the same resource * from the same loader twice, we should get the same resource. */ public void testCache() throws Exception { Loader loader = new Loader(false); ResourceBundle b1 = getResourceBundle(loader, "Bug4179766Resource"); if (b1 == null) { errln("Resource not found: Bug4179766Resource"); } ResourceBundle b2 = getResourceBundle(loader, "Bug4179766Resource"); if (b2 == null) { errln("Resource not found: Bug4179766Resource"); } printIDInfo("[bundle1]",b1); printIDInfo("[bundle2]",b2); if (b1 != b2) { errln("Different objects returned by same ClassLoader"); } }
Example #3
Source Project: TencentKona-8 Author: Tencent File: Logger.java License: GNU General Public License v2.0 | 6 votes |
/** * Sets a resource bundle on this logger. * All messages will be logged using the given resource bundle for its * specific {@linkplain ResourceBundle#getLocale locale}. * @param bundle The resource bundle that this logger shall use. * @throws NullPointerException if the given bundle is {@code null}. * @throws IllegalArgumentException if the given bundle doesn't have a * {@linkplain ResourceBundle#getBaseBundleName base name}, * or if this logger already has a resource bundle set but * the given bundle has a different base name. * @throws SecurityException if a security manager exists, * this logger is not anonymous, and the caller * does not have LoggingPermission("control"). * @since 1.8 */ public void setResourceBundle(ResourceBundle bundle) { checkPermission(); // Will throw NPE if bundle is null. final String baseName = bundle.getBaseBundleName(); // bundle must have a name if (baseName == null || baseName.isEmpty()) { throw new IllegalArgumentException("resource bundle must have a name"); } synchronized (this) { LoggerBundle lb = loggerBundle; final boolean canReplaceResourceBundle = lb.resourceBundleName == null || lb.resourceBundleName.equals(baseName); if (!canReplaceResourceBundle) { throw new IllegalArgumentException("can't replace resource bundle"); } loggerBundle = LoggerBundle.get(baseName, bundle); } }
Example #4
Source Project: jdk8u-dev-jdk Author: frohoff File: TestBug4179766.java License: GNU General Public License v2.0 | 6 votes |
/** * Ensure that cached resources for different ClassLoaders * are cached seperately */ private void doTest(boolean sameHash) throws Exception { ResourceBundle b1 = getResourceBundle(new Loader(sameHash), "Bug4179766Resource"); if (b1 == null) { errln("Resource not found: Bug4179766Resource"); } ResourceBundle b2 = getResourceBundle(new Loader(sameHash), "Bug4179766Resource"); if (b2 == null) { errln("Resource not found: Bug4179766Resource"); } printIDInfo("[bundle1]",b1); printIDInfo("[bundle2]",b2); if (b1 == b2) { errln("Same object returned by different ClassLoaders"); } }
Example #5
Source Project: JsDroidCmd Author: coolwho File: ScriptRuntime.java License: Mozilla Public License 2.0 | 6 votes |
public String getMessage(String messageId, Object[] arguments) { final String defaultResource = "org.mozilla.javascript.resources.Messages"; Context cx = Context.getCurrentContext(); Locale locale = cx != null ? cx.getLocale() : Locale.getDefault(); // ResourceBundle does caching. ResourceBundle rb = ResourceBundle.getBundle(defaultResource, locale); String formatString; try { formatString = rb.getString(messageId); } catch (java.util.MissingResourceException mre) { throw new RuntimeException ("no message resource found for message property "+ messageId); } /* * It's OK to format the string, even if 'arguments' is null; * we need to format it anyway, to make double ''s collapse to * single 's. */ MessageFormat formatter = new MessageFormat(formatString); return formatter.format(arguments); }
Example #6
Source Project: jdk8u-jdk Author: frohoff File: Level.java License: GNU General Public License v2.0 | 6 votes |
private String computeLocalizedLevelName(Locale newLocale) { ResourceBundle rb = ResourceBundle.getBundle(resourceBundleName, newLocale); final String localizedName = rb.getString(name); final boolean isDefaultBundle = defaultBundle.equals(resourceBundleName); if (!isDefaultBundle) return localizedName; // This is a trick to determine whether the name has been translated // or not. If it has not been translated, we need to use Locale.ROOT // when calling toUpperCase(). final Locale rbLocale = rb.getLocale(); final Locale locale = Locale.ROOT.equals(rbLocale) || name.equals(localizedName.toUpperCase(Locale.ROOT)) ? Locale.ROOT : rbLocale; // ALL CAPS in a resource bundle's message indicates no translation // needed per Oracle translation guideline. To workaround this // in Oracle JDK implementation, convert the localized level name // to uppercase for compatibility reason. return Locale.ROOT.equals(locale) ? name : localizedName.toUpperCase(locale); }
Example #7
Source Project: jdk8u_jdk Author: JetBrains File: Bug6299235Test.java License: GNU General Public License v2.0 | 6 votes |
public static void main(String args[]) throws Exception { /* Try to load "sun.awt.resources.awt_ru_RU.properties which * is in awtres.jar. */ ResourceBundle russionAwtRes = ResourceBundle.getBundle("sun.awt.resources.awt", new Locale("ru", "RU"), CoreResourceBundleControl.getRBControlInstance()); /* If this call throws MissingResourceException, the test fails. */ if (russionAwtRes != null) { String result = russionAwtRes.getString("foo"); if (result.equals("bar")) { System.out.println("Bug6299235Test passed"); } else { System.err.println("Bug6299235Test failed"); throw new Exception("Resource found, but value of key foo is not correct\n"); } } }
Example #8
Source Project: netbeans Author: apache File: NbModuleProjectTest.java License: Apache License 2.0 | 6 votes |
public void testMemoryConsumption() throws Exception { // #90195 assertSize("java.project is not too big", Arrays.asList(javaProjectProject.evaluator(), javaProjectProject.getHelper()), 2345678, new MemoryFilter() { final Class<?>[] REJECTED = { Project.class, FileObject.class, ClassLoader.class, Class.class, ModuleInfo.class, LogManager.class, RequestProcessor.class, ResourceBundle.class, }; public @Override boolean reject(Object obj) { for (Class<?> c : REJECTED) { if (c.isInstance(obj)) { return true; } } return false; } }); }
Example #9
Source Project: Tomcat7.0.67 Author: tryandcatch File: TestResourceBundleELResolver.java License: Apache License 2.0 | 6 votes |
/** * Tests that a valid FeatureDescriptors are returned. */ @Test public void testGetFeatureDescriptors02() { ResourceBundleELResolver resolver = new ResourceBundleELResolver(); ELContext context = new ELContextImpl(); ResourceBundle resourceBundle = new TesterResourceBundle( new Object[][] { { "key", "value" } }); @SuppressWarnings("unchecked") Iterator<FeatureDescriptor> result = resolver.getFeatureDescriptors( context, resourceBundle); while (result.hasNext()) { FeatureDescriptor featureDescriptor = result.next(); Assert.assertEquals("key", featureDescriptor.getDisplayName()); Assert.assertEquals("key", featureDescriptor.getName()); Assert.assertEquals("", featureDescriptor.getShortDescription()); Assert.assertFalse(featureDescriptor.isExpert()); Assert.assertFalse(featureDescriptor.isHidden()); Assert.assertTrue(featureDescriptor.isPreferred()); Assert.assertEquals(String.class, featureDescriptor.getValue(ELResolver.TYPE)); Assert.assertEquals(Boolean.TRUE, featureDescriptor .getValue(ELResolver.RESOLVABLE_AT_DESIGN_TIME)); } }
Example #10
Source Project: openjdk-jdk9 Author: AdoptOpenJDK File: DatatypeException.java License: GNU General Public License v2.0 | 6 votes |
/** * Overrides this method to get the formatted&localized error message. * * REVISIT: the system locale is used to load the property file. * do we want to allow the appilcation to specify a * different locale? */ public String getMessage() { ResourceBundle resourceBundle = null; resourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages"); if (resourceBundle == null) throw new MissingResourceException("Property file not found!", "com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages", key); String msg = resourceBundle.getString(key); if (msg == null) { msg = resourceBundle.getString("BadMessageKey"); throw new MissingResourceException(msg, "com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages", key); } if (args != null) { try { msg = java.text.MessageFormat.format(msg, args); } catch (Exception e) { msg = resourceBundle.getString("FormatFailed"); msg += " " + resourceBundle.getString(key); } } return msg; }
Example #11
Source Project: tomcatsrc Author: wangyingjie File: TestResourceBundleELResolver.java License: Apache License 2.0 | 5 votes |
/** * Tests that the readOnly is true always when the base is ResourceBundle. */ @Test public void testIsReadOnly03() { ResourceBundleELResolver resolver = new ResourceBundleELResolver(); ELContext context = new ELContextImpl(); ResourceBundle resourceBundle = new TesterResourceBundle(); boolean result = resolver.isReadOnly(context, resourceBundle, new Object()); Assert.assertTrue(result); Assert.assertTrue(context.isPropertyResolved()); }
Example #12
Source Project: jdk8u_jdk Author: JetBrains File: LocaleData.java License: GNU General Public License v2.0 | 5 votes |
public static ResourceBundle getBundle(final String baseName, final Locale locale) { return AccessController.doPrivileged(new PrivilegedAction<ResourceBundle>() { @Override public ResourceBundle run() { return ResourceBundle .getBundle(baseName, locale, LocaleDataResourceBundleControl.INSTANCE); } }); }
Example #13
Source Project: Java8CN Author: Java8-CNAPI-Team File: WeekFields.java License: Apache License 2.0 | 5 votes |
@Override public String getDisplayName(Locale locale) { Objects.requireNonNull(locale, "locale"); if (rangeUnit == YEARS) { // only have values for week-of-year LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased() .getLocaleResources(locale); ResourceBundle rb = lr.getJavaTimeFormatData(); return rb.containsKey("field.week") ? rb.getString("field.week") : name; } return name; }
Example #14
Source Project: openjdk-jdk8u-backup Author: AdoptOpenJDK File: Logger.java License: GNU General Public License v2.0 | 5 votes |
private void doLog(LogRecord lr, ResourceBundle rb) { lr.setLoggerName(name); if (rb != null) { lr.setResourceBundleName(rb.getBaseBundleName()); lr.setResourceBundle(rb); } log(lr); }
Example #15
Source Project: jivejdon Author: banq File: FilterBeanInfo.java License: Apache License 2.0 | 5 votes |
public FilterBeanInfo() { //Get the locale that should be used, then load the resource bundle. Locale currentLocale = Locale.US; try { bundle = ResourceBundle.getBundle("bean_" + getName(), currentLocale); } catch (Exception e) { // Ignore any exception when trying to load bundle. } }
Example #16
Source Project: azure-devops-intellij Author: microsoft File: VsoLoginForm.java License: MIT License | 5 votes |
/** * Method generated by IntelliJ IDEA GUI Designer * >>> IMPORTANT!! <<< * DO NOT edit this method OR call it in your code! * * @noinspection ALL */ private void $$$setupUI$$$() { createUIComponents(); contentPanel = new JPanel(); contentPanel.setLayout(new GridLayoutManager(8, 4, new Insets(0, 0, 0, 0), -1, -1)); final Spacer spacer1 = new Spacer(); contentPanel.add(spacer1, new GridConstraints(7, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); descriptionLabel = new WrappingLabel(); descriptionLabel.setEnabled(true); descriptionLabel.setName(""); descriptionLabel.setText(ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin").getString("VsoLoginForm.Description")); contentPanel.add(descriptionLabel, new GridConstraints(1, 1, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); headerLabel = new JLabel(); this.$$$loadLabelText$$$(headerLabel, ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin").getString("VsoLoginForm.Header")); contentPanel.add(headerLabel, new GridConstraints(0, 1, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); contentPanel.add(vsIcon, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); busySpinnerPanel = new BusySpinnerPanel(); contentPanel.add(busySpinnerPanel, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); loginProgressLabel = new JLabel(); loginProgressLabel.setText("Sample Text for Busy Spinner Message"); contentPanel.add(loginProgressLabel, new GridConstraints(3, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final Spacer spacer2 = new Spacer(); contentPanel.add(spacer2, new GridConstraints(3, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); signInLink = new Hyperlink(); this.$$$loadLabelText$$$(signInLink, ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin").getString("VsoLoginForm.SignIn")); contentPanel.add(signInLink, new GridConstraints(2, 1, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); moreInfoLabel = new JLabel(); this.$$$loadLabelText$$$(moreInfoLabel, ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin").getString("LoginForm.VSO.MoreInformationLabel")); contentPanel.add(moreInfoLabel, new GridConstraints(4, 1, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); createAnAccountLink = new Hyperlink(); this.$$$loadLabelText$$$(createAnAccountLink, ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin").getString("VsoLoginForm.CreateAccount")); contentPanel.add(createAnAccountLink, new GridConstraints(5, 1, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); learnMoreLink = new Hyperlink(); this.$$$loadLabelText$$$(learnMoreLink, ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin").getString("VsoLoginForm.LearnMore")); contentPanel.add(learnMoreLink, new GridConstraints(6, 1, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); }
Example #17
Source Project: oim-fx Author: oimchat File: LoginController.java License: MIT License | 5 votes |
@Override public void initialize(URL location, ResourceBundle resources) { errorMessage.setText(""); userId.setPromptText("demo"); password.setPromptText("demo"); }
Example #18
Source Project: openjdk-jdk9 Author: AdoptOpenJDK File: BaseLoggerBridgeTest.java License: GNU General Public License v2.0 | 5 votes |
static Supplier<String> logpMessage(ResourceBundle bundle, String className, String methodName, Supplier<String> msg) { if (BEST_EFFORT_FOR_LOGP && bundle == null && (className != null || methodName != null)) { final String cName = className == null ? "" : className; final String mName = methodName == null ? "" : methodName; return () -> String.format("[%s %s] %s", cName, mName, msg.get()); } else { return msg; } }
Example #19
Source Project: openjdk-jdk9 Author: AdoptOpenJDK File: MyResourcesAsia.java License: GNU General Public License v2.0 | 5 votes |
@Override public ResourceBundle getBundle(String baseName, Locale locale) { if (asiaLocales.contains(locale)) { return super.getBundle(baseName, locale); } return null; }
Example #20
Source Project: GitFx Author: jughyd File: GitResourceBundleTest.java License: Apache License 2.0 | 5 votes |
@Test public void testDefaultRBProperty() { ResourceBundle bundle = new GitResourceBundle().getBundle(); assertNotNull(bundle); assert ("Open Repository".equals(bundle.getString("openRepo"))); assert ("Choose the Repository Path" .equals(bundle.getString("chooseRepo"))); assert ("Clone Repository".equals(bundle.getString("cloneRepo"))); assert ("Error Initializing".equals(bundle.getString("errorInit"))); assert ("Error Cloning".equals(bundle.getString("errorClone"))); assert ("Enter valid Project Name or Repository Path" .equals(bundle.getString("errorInitTitle"))); assert ("You either entered invalid Project Name or repository path" .equals(bundle.getString("errorInitDesc"))); assert ("Enter valid Remote Repository URL or Local Path" .equals(bundle.getString("errorCloneTitle"))); assert ("You either entered invalid Remote Repo URL or Local path" .equals(bundle.getString("errorCloneDesc"))); assert ("Error Opening".equals(bundle.getString("errorOpen"))); assert ("Error Opening the Repository" .equals(bundle.getString("errorOpenTitle"))); assert ("Not a valid Git Repository" .equals(bundle.getString("errorOpenDesc"))); assert ("Initialize Repository".equals(bundle.getString("initRepo"))); assert ("Repository".equals(bundle.getString("repo"))); assert ("Sync".equals(bundle.getString("sync"))); assert ("Sync Everything".equals(bundle.getString("syncAll"))); assert ("Select Repository".equals(bundle.getString("selectRepo"))); assert ("This will sync all repositories on all servers" .equals(bundle.getString("syncAllDesc"))); assert ("Sync Repositories".equals(bundle.getString("syncRepo"))); }
Example #21
Source Project: netbeans Author: apache File: InvalidComponent.java License: Apache License 2.0 | 5 votes |
public InvalidComponent() { this.setBorder(BorderFactory.createLineBorder(Color.RED)); this.setLayout(new BorderLayout()); label.setForeground(Color.RED); ResourceBundle bundle = FormUtils.getBundle(); label.setText("<html><center>" + bundle.getString("CTL_LB_InvalidComponent") + "</center></html>"); // NOI18N add(label); }
Example #22
Source Project: openjdk-jdk8u-backup Author: AdoptOpenJDK File: Logger.java License: GNU General Public License v2.0 | 5 votes |
private static ResourceBundle findSystemResourceBundle(final Locale locale) { // the resource bundle is in a restricted package return AccessController.doPrivileged(new PrivilegedAction<ResourceBundle>() { @Override public ResourceBundle run() { try { return ResourceBundle.getBundle(SYSTEM_LOGGER_RB_NAME, locale); } catch (MissingResourceException e) { throw new InternalError(e.toString()); } } }); }
Example #23
Source Project: sinavi-jfw Author: ctc-g File: ErrorResources.java License: Apache License 2.0 | 5 votes |
/** * リソースファイルよりメッセージを取得します。 * もし、指定されたキーでメッセージが解決できない場合はキーを返します。 * @param key エラーメッセージのキー * @param locale ロケール * @return エラーメッセージ */ public static String find(String key, Locale locale) { if (Strings.isEmpty(key)) return key; String msg = key; try { msg = ResourceBundle.getBundle(RESOURCE_NAME, locale != null ? locale : Locale.getDefault(), new ErrorMessageCacheControl(Control.FORMAT_PROPERTIES)).getString(key); } catch (MissingResourceException e) { if (L.isDebugEnabled()) { L.debug(Strings.substitute(R.getString("D-REST-JERSEY-UTIL#0001"), Maps.hash("key", key))); } } return msg; }
Example #24
Source Project: jdk8u-jdk Author: frohoff File: ResourceBundleSearchTest.java License: GNU General Public License v2.0 | 5 votes |
public static boolean isOnClassPath(String baseName, ClassLoader cl) { ResourceBundle rb = null; try { rb = ResourceBundle.getBundle(baseName, Locale.getDefault(), cl); System.out.println("INFO: Found bundle " + baseName + " on " + cl); } catch (MissingResourceException e) { System.out.println("INFO: Could not find bundle " + baseName + " on " + cl); return false; } return (rb != null); }
Example #25
Source Project: ctsms Author: phoenixctms File: WebUtil.java License: GNU Lesser General Public License v2.1 | 5 votes |
public static void clearResourceBundleCache() throws Exception { WebUtil.getServiceLocator().getToolsService().clearResourceBundleCache(); //https://stackoverflow.com/questions/4325164/how-to-reload-resource-bundle-in-web-application ResourceBundle.clearCache(Thread.currentThread().getContextClassLoader()); Iterator<ApplicationResourceBundle> it = ApplicationAssociate.getCurrentInstance().getResourceBundles().values().iterator(); while (it.hasNext()) { ApplicationResourceBundle appBundle = it.next(); Map<Locale, ResourceBundle> resources = CommonUtil.getDeclaredFieldValue(appBundle, "resources"); resources.clear(); } }
Example #26
Source Project: ebics-java-client Author: uwemaurer File: DefaultConfiguration.java License: GNU Lesser General Public License v2.1 | 5 votes |
/** * Creates a new application configuration. * @param rootDir the root directory */ public DefaultConfiguration(String rootDir) { this.rootDir = rootDir; bundle = ResourceBundle.getBundle(RESOURCE_DIR); properties = new Properties(); logger = new DefaultEbicsLogger(); serializationManager = new DefaultSerializationManager(); traceManager = new DefaultTraceManager(); }
Example #27
Source Project: Overchan-Android Author: miku-nyan File: JSONObject.java License: GNU General Public License v3.0 | 5 votes |
/** * Construct a JSONObject from a ResourceBundle. * * @param baseName * The ResourceBundle base name. * @param locale * The Locale to load the ResourceBundle for. * @throws JSONException * If any JSONExceptions are detected. */ public JSONObject(String baseName, Locale locale) throws JSONException { this(); ResourceBundle bundle = ResourceBundle.getBundle(baseName, locale, Thread.currentThread().getContextClassLoader()); // Iterate through the keys in the bundle. Enumeration<String> keys = bundle.getKeys(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); if (key != null) { // Go through the path, ensuring that there is a nested JSONObject for each // segment except the last. Add the value using the last segment's name into // the deepest nested JSONObject. String[] path = ((String) key).split("\\."); int last = path.length - 1; JSONObject target = this; for (int i = 0; i < last; i += 1) { String segment = path[i]; JSONObject nextTarget = target.optJSONObject(segment); if (nextTarget == null) { nextTarget = new JSONObject(); target.put(segment, nextTarget); } target = nextTarget; } target.put(path[last], bundle.getString((String) key)); } } }
Example #28
Source Project: openjdk-8 Author: bpupadhyaya File: Util.java License: GNU General Public License v2.0 | 5 votes |
private void initMessages() throws Exit { try { m = ResourceBundle.getBundle("com.sun.tools.javah.resources.l10n"); } catch (MissingResourceException mre) { fatal("Error loading resources. Please file a bug report.", mre); } }
Example #29
Source Project: sqoop-on-spark Author: vybs File: ConfigFiller.java License: Apache License 2.0 | 5 votes |
private static boolean fillInputLong(MLongInput input, ConsoleReader reader, ResourceBundle bundle) throws IOException { generatePrompt(reader, bundle, input); if (!input.isEmpty() && !input.isSensitive()) { reader.putString(input.getValue().toString()); } // Get the data String userTyped; if (input.isSensitive()) { userTyped = reader.readLine('*'); } else { userTyped = reader.readLine(); } if (userTyped == null) { return false; } else if (userTyped.isEmpty()) { input.setEmpty(); } else { Long value; try { value = Long.valueOf(userTyped); input.setValue(value); } catch (NumberFormatException ex) { errorMessage("Input is not a valid long"); return fillInputLong(input, reader, bundle); } input.setValue(Long.valueOf(userTyped)); } return true; }
Example #30
Source Project: drftpd Author: drftpd-ng File: IMDBList.java License: GNU General Public License v2.0 | 5 votes |
public ListElementsContainer addElements(DirectoryHandle dir, ListElementsContainer container) { ResourceBundle bundle = container.getCommandManager().getResourceBundle(); if (IMDBConfig.getInstance().barEnabled()) { IMDBVFSDataNFO imdbData = new IMDBVFSDataNFO(dir); IMDBInfo imdbInfo = imdbData.getIMDBInfoFromCache(); if (imdbInfo != null) { if (imdbInfo.getMovieFound()) { Map<String, Object> env = new HashMap<>(); env.put("title", imdbInfo.getTitle()); env.put("year", imdbInfo.getYear() != null ? imdbInfo.getYear() : "9999"); env.put("language", imdbInfo.getLanguage()); env.put("country", imdbInfo.getCountry()); env.put("director", imdbInfo.getDirector()); env.put("genres", imdbInfo.getGenres()); env.put("plot", imdbInfo.getPlot()); env.put("rating", imdbInfo.getRating() != null ? imdbInfo.getRating() / 10 + "." + imdbInfo.getRating() % 10 : "0"); env.put("votes", imdbInfo.getVotes() != null ? imdbInfo.getVotes() : "0"); env.put("url", imdbInfo.getURL()); env.put("runtime", imdbInfo.getRuntime() != null ? imdbInfo.getRuntime() : "0"); String imdbDirName = container.getSession().jprintf(bundle, "imdb.dir", env, container.getUser()); try { container.getElements().add(new LightRemoteInode(imdbDirName, "drftpd", "drftpd", IMDBConfig.getInstance().barAsDirectory(), dir.lastModified(), 0L)); } catch (FileNotFoundException e) { // dir was deleted during list operation } } } } return container; }