List of usage examples for java.util ResourceBundle getString
public final String getString(String key)
From source file:com.clustercontrol.ClusterControlPlugin.java
/** * Returns the string from the plugin's resource bundle, or 'key' if not * found./*from www.ja va 2 s.co m*/ */ public static String getResourceString(String key) { ResourceBundle bundle = ClusterControlPlugin.getDefault().getResourceBundle(); try { return (bundle != null) ? bundle.getString(key) : key; } catch (MissingResourceException e) { return key; } }
From source file:net.openkoncept.vroom.VroomUtilities.java
/** * <p>/*w w w . j a va2 s .c o m*/ * This useful method converts a map to JSONObject. * </p> * * @param bundle - ResourceBundle (preferrably with key/value pairs) * @return - JSON object. */ public static JSONObject bundleToJSONObject(ResourceBundle bundle) { JSONObject jo = new JSONObject(); if (bundle != null) { Enumeration e = bundle.getKeys(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); try { jo.append(key, bundle.getString(key)); } catch (JSONException ex) { // Not required! } } } return jo; }
From source file:org.soitoolkit.commons.mule.util.MiscUtil.java
/** * Convert ResourceBundle into a Properties object. * * @param resource a resource bundle to convert. * @return Properties a properties version of the resource bundle. *//* w w w . java 2s.c o m*/ static Properties convertResourceBundleToProperties(ResourceBundle resource) { Properties properties = new Properties(); Enumeration<String> keys = resource.getKeys(); while (keys.hasMoreElements()) { String key = keys.nextElement(); properties.put(key, resource.getString(key)); } return properties; }
From source file:at.favre.tools.dconvert.ui.CLIInterpreter.java
private static Options setupOptions(ResourceBundle bundle) { Options options = new Options(); Option srcOpt = Option.builder(SOURCE_ARG).required().argName("path to file or folder").hasArg(true) .desc(bundle.getString("arg.descr.cmd.src")).build(); Option srcScaleOpt = Option.builder(SCALE_ARG).argName("[float]|[int]dp").hasArg(true) .desc(bundle.getString("arg.descr.cmd.scale")).build(); Option dstOpt = Option.builder(DST_ARG).hasArg(true).argName("path") .desc(bundle.getString("arg.descr.cmd.dst")).build(); Option platform = Option.builder(PLATFORM_ARG).hasArg(true).argName("all|android|ios|win|web") .desc(MessageFormat.format(bundle.getString("arg.descr.cmd.platform"), Arguments.DEFAULT_PLATFORM)) .build();/* w w w. j a v a 2s . co m*/ Option threadCount = Option.builder(THREADS_ARG).argName("1-8").hasArg(true).desc(MessageFormat .format(bundle.getString("arg.descr.cmd.threads"), String.valueOf(Arguments.DEFAULT_THREAD_COUNT))) .build(); Option roundingHandler = Option .builder(ROUNDING_MODE_ARG).argName("round|ceil|floor").hasArg(true).desc(MessageFormat .format(bundle.getString("arg.descr.cmd.rounding"), Arguments.DEFAULT_ROUNDING_STRATEGY)) .build(); Option compression = Option.builder(OUT_COMPRESSION_ARG).hasArg(true).argName("png|jpg|gif|bmp") .desc(bundle.getString("arg.descr.cmd.outcompression")).build(); Option compressionQuality = Option.builder(COMPRESSION_QUALITY_ARG).hasArg(true).argName("0.0-1.0") .desc(MessageFormat.format(bundle.getString("arg.descr.cmd.compression"), String.valueOf(Arguments.DEFAULT_COMPRESSION_QUALITY))) .build(); Option upScalingAlgo = Option.builder(UPSCALING_ALGO_ARG).hasArg(true) .argName(EScalingAlgorithm.getCliArgString(EScalingAlgorithm.Type.UPSCALING)) .desc(MessageFormat.format(bundle.getString("arg.descr.scalingalgo"), Arguments.DEFAULT_PLATFORM)) .build(); Option downScalingAlgo = Option.builder(DOWNSCALING_ALGO_ARG).hasArg(true) .argName(EScalingAlgorithm.getCliArgString(EScalingAlgorithm.Type.DOWNSCALING)) .desc(MessageFormat.format(bundle.getString("arg.descr.scalingalgo"), Arguments.DEFAULT_PLATFORM)) .build(); Option skipExistingFiles = Option.builder(SKIP_EXISTING_ARG) .desc(bundle.getString("arg.descr.skipexisting")).build(); Option androidIncludeLdpiTvdpi = Option.builder("androidIncludeLdpiTvdpi") .desc(bundle.getString("arg.descr.androidmipmap")).build(); Option mipmapInsteadOfDrawable = Option.builder("androidMipmapInsteadOfDrawable") .desc(bundle.getString("arg.descr.androidldpi")).build(); Option iosCreateImagesetFolders = Option.builder("iosCreateImagesetFolders") .desc(bundle.getString("arg.descr.iosimageset")).build(); Option skipUpscaling = Option.builder("skipUpscaling").desc(bundle.getString("arg.descr.skipupscaling")) .build(); Option verboseLog = Option.builder(VERBOSE_ARG).desc(bundle.getString("arg.descr.cmd.verbose")).build(); Option haltOnError = Option.builder("haltOnError").desc(bundle.getString("arg.descr.halterror")).build(); Option antiAliasing = Option.builder("antiAliasing").desc(bundle.getString("arg.descr.antialiasing")) .build(); Option enablePngCrush = Option.builder("postProcessorPngCrush").desc(bundle.getString("arg.descr.pngcrush")) .build(); Option postWebpConvert = Option.builder("postProcessorWebp").desc(bundle.getString("arg.descr.webp")) .build(); Option keepUnPostProcessed = Option.builder("keepOriginalPostProcessedFiles") .desc(bundle.getString("arg.descr.keeporiginal")).build(); Option dpScaleIsHeight = Option.builder(SCALE_IS_HEIGHT_DP_ARG) .desc(bundle.getString("arg.descr.cmd.dpIsHeight")).build(); Option dryRun = Option.builder("dryRun").desc(bundle.getString("arg.descr.dryrun")).build(); Option enableMozJpeg = Option.builder("postProcessorMozJpeg").desc(bundle.getString("arg.descr.mozjpeg")) .build(); Option cleanBeforeConvert = Option.builder("clean").desc(bundle.getString("arg.descr.clean")).build(); Option help = Option.builder("h").longOpt("help").desc(bundle.getString("arg.descr.cmd.help")).build(); Option version = Option.builder("v").longOpt("version").desc(bundle.getString("arg.descr.cmd.version")) .build(); Option gui = Option.builder("gui").desc(bundle.getString("arg.descr.cmd.gui")).build(); OptionGroup mainArgs = new OptionGroup(); mainArgs.addOption(srcOpt).addOption(help).addOption(version).addOption(gui); mainArgs.setRequired(true); options.addOption(srcScaleOpt).addOption(dstOpt); options.addOption(platform).addOption(compression).addOption(compressionQuality).addOption(threadCount) .addOption(roundingHandler).addOption(upScalingAlgo).addOption(downScalingAlgo); options.addOption(skipExistingFiles).addOption(skipUpscaling).addOption(androidIncludeLdpiTvdpi) .addOption(verboseLog).addOption(antiAliasing).addOption(dryRun).addOption(haltOnError) .addOption(mipmapInsteadOfDrawable).addOption(enablePngCrush).addOption(postWebpConvert) .addOption(dpScaleIsHeight).addOption(enableMozJpeg).addOption(keepUnPostProcessed) .addOption(iosCreateImagesetFolders).addOption(cleanBeforeConvert); options.addOptionGroup(mainArgs); return options; }
From source file:com.teamsun.framework.util.ConvertUtil.java
/** * ???MAP.//from w ww .j a v a 2 s . com * * @param rb * a given resource bundle * @return Map a populated map */ public static Map convertBundleToMap(ResourceBundle rb) { Map map = new HashMap(); for (Enumeration keys = rb.getKeys(); keys.hasMoreElements();) { String key = (String) keys.nextElement(); map.put(key, rb.getString(key)); } return map; }
From source file:com.google.code.pentahoflashcharts.charts.PentahoOFC4JChartHelper.java
@SuppressWarnings("unchecked") private static Map createChartFactoryMap() { Properties chartFactories = new Properties(); // First, get known chart factories... try {/* w w w . j a va2 s . c o m*/ ResourceBundle pluginBundle = ResourceBundle.getBundle(PLUGIN_BUNDLE_NAME); if (pluginBundle != null) { // Copy the bundle here... Enumeration keyEnum = pluginBundle.getKeys(); String bundleKey = null; while (keyEnum.hasMoreElements()) { bundleKey = (String) keyEnum.nextElement(); chartFactories.put(bundleKey, pluginBundle.getString(bundleKey)); } } } catch (Exception ex) { logger.warn(Messages.getString("PentahoOFC4JChartHelper.WARN_NO_CHART_FACTORY_PROPERTIES_BUNDLE")); //$NON-NLS-1$ } // Get overrides... // // Note - If the override wants to remove an existing "known" plugin, // simply adding an empty value will cause the "known" plugin to be removed. // if (PentahoSystem.getObjectFactory() == null || !PentahoSystem.getObjectFactory().objectDefined(ISolutionRepository.class.getSimpleName())) { // this is ok return chartFactories; } ISolutionRepository solutionRepository = PentahoSystem.get(ISolutionRepository.class, new StandaloneSession("system")); //$NON-NLS-1$ try { if (solutionRepository.resourceExists(SOLUTION_PROPS)) { InputStream is = solutionRepository.getResourceInputStream(SOLUTION_PROPS, false); Properties overrideChartFactories = new Properties(); overrideChartFactories.load(is); chartFactories.putAll(overrideChartFactories); // load over the top of the known properties } } catch (FileNotFoundException ignored) { logger.warn(Messages.getString("PentahoOFC4JChartHelper.WARN_NO_CHART_FACTORY_PROPERTIES")); //$NON-NLS-1$ } catch (IOException ignored) { logger.warn(Messages.getString("PentahoOFC4JChartHelper.WARN_BAD_CHART_FACTORY_PROPERTIES"), ignored); //$NON-NLS-1$ } return chartFactories; }
From source file:msearch.tool.MSFunktionen.java
public static String getCompileDate() { final ResourceBundle rb; String propToken = "DATE"; String msg = ""; try {//w w w . ja v a2 s . com ResourceBundle.clearCache(); rb = ResourceBundle.getBundle("version"); msg = rb.getString(propToken); } catch (Exception e) { MSLog.fehlerMeldung(807293847, MSLog.FEHLER_ART_PROG, MSFunktionen.class.getName(), e); } return msg; }
From source file:msearch.tool.MSFunktionen.java
public static String getBuildNr() { final ResourceBundle rb; String propToken = "BUILD"; String msg = ""; try {//from w w w .java 2 s. c om ResourceBundle.clearCache(); rb = ResourceBundle.getBundle("version"); msg = rb.getString(propToken); } catch (Exception e) { MSLog.fehlerMeldung(134679898, MSLog.FEHLER_ART_PROG, MSFunktionen.class.getName(), e); } return msg; }
From source file:com.teamsun.framework.util.ConvertUtil.java
/** * Method to convert a ResourceBundle to a Properties object. * /*from w w w . j av a 2 s . co m*/ * @param rb * a given resource bundle * @return Properties a populated properties object */ public static Properties convertBundleToProperties(ResourceBundle rb) { Properties props = new Properties(); for (Enumeration keys = rb.getKeys(); keys.hasMoreElements();) { String key = (String) keys.nextElement(); props.put(key, rb.getString(key)); } return props; }
From source file:org.eclipselabs.garbagecat.Main.java
/** * @return version string.//www . ja v a 2 s. co m */ private static String getVersion() { ResourceBundle rb = ResourceBundle.getBundle("META-INF/maven/garbagecat/garbagecat/pom"); return rb.getString("version"); }