Exemplo n.º 1
0
        /**
         * Retrieves a message from the World Wind message resource bundle formatted with specified arguments. The arguments
         * are inserted into the message via {@link java.text.MessageFormat}.
         *
         * @param property the property identifying which message to retrieve.
         * @param args     the arguments referenced by the format string identified <code>property</code>.
         *
         * @return The requested string formatted with the arguments.
         *
         * @see java.text.MessageFormat
         */
        public static string getMessage(string property, params object[] args)
        {
            string message;

            try
            {
                message = (string)ResourceBundle.getBundle(MESSAGE_BUNDLE_NAME, Locale.getDefault()).getObject(property);
            }
            catch (Exception e)
            {
                message = "Exception looking up message from bundle " + MESSAGE_BUNDLE_NAME;
                logger().log(Level.SEVERE, message, e);
                return(message);
            }

            try
            {
                // TODO: This is no longer working with more than one arg in the message string, e.g., {1}
                return(args == null ? message : MessageFormat.format(message, args));
            }
            catch (ArgumentException e)
            {
                message = "Message arguments do not match format string: " + property;
                logger().log(Level.SEVERE, message, e);
                return(message);
            }
        }
Exemplo n.º 2
0
 /**
  * Serialization helper to setup transient resource bundle instance.
  *
  * @param in
  *            the input stream to read the instance data from.
  * @throws IOException
  *             if an IO error occurs.
  * @throws ClassNotFoundException
  *             if a class is not found.
  */
 private void readObject(java.io.ObjectInputStream inJ)//throws IOException,            ClassNotFoundException {
 {
     inJ.defaultReadObject();
     if (resourceBundleName != null)
     {
         try {
             rb = ResourceBundle.getBundle(resourceBundleName);
         } catch (MissingResourceException) {
             rb = null;
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Retrieves a message from the World Wind message resource bundle.
  *
  * @param property the property identifying which message to retrieve.
  *
  * @return The requested message.
  */
 public static string getMessage(string property)
 {
     try
     {
         return((string)ResourceBundle.getBundle(MESSAGE_BUNDLE_NAME, Locale.getDefault()).getObject(property));
     }
     catch (Exception e)
     {
         string message = "Exception looking up message from bundle " + MESSAGE_BUNDLE_NAME;
         logger().log(java.util.logging.Level.SEVERE, message, e);
         return(message);
     }
 }
Exemplo n.º 4
0
 private static void Initialise()
 {
     if (SdkUtil._resourceBundle != null)
     {
         return;
     }
     try
     {
         SdkUtil._resourceBundle = ResourceBundle.getBundle("com.vmware.vcloud.sdk.Resource", Locale.getDefault(), "Resource");
     }
     catch (MissingManifestResourceException ex)
     {
         Logger.Log(TraceLevel.Critical, ex.Message);
         Logger.Log(TraceLevel.Information, "Loading locale en_US properties");
         SdkUtil._resourceBundle = ResourceBundle.getBundle("com.vmware.vcloud.sdk.Resource", Locale.US, "Resource");
     }
     SdkUtil._isInitialised = true;
 }
Exemplo n.º 5
0
        /*
         * Helper method to do the actual work of fetching resources; allows
         * getResString(S,S) to be deprecated without affecting getResString(S);
         */
        private static String getResStringDefault(String key, String defaultValue, Locale forcedLocale)
        {
            if (key == null)
            {
                return(null);
            }
            // Resource keys cannot contain spaces, and are forced to lower case
            String resKey = key.Replace(' ', '_'); // $NON-NLS-1$ // $NON-NLS-2$

            resKey = resKey.ToLower();
            String resString = null;

            try {
                ResourceBundle bundle = resources;
                if (forcedLocale != null)
                {
                    bundle = ResourceBundle.getBundle("org.apache.jmeter.resources.messages", forcedLocale); // $NON-NLS-1$
                }
                if (bundle.containsKey(resKey))
                {
                    resString = bundle.getString(resKey);
                }
                else
                {
                    //log.warn("ERROR! Resource string not found: [" + resKey + "]");
                    resString = defaultValue;
                }
                if (ignoreResorces)   // Special mode for debugging resource handling
                {
                    return("[" + key + "]");
                }
            }
            catch (MissingResourceException mre)
            {
                if (ignoreResorces)   // Special mode for debugging resource handling
                {
                    return("[?" + key + "?]");
                }
                //log.warn("ERROR! Resource string not found: [" + resKey + "]", mre);
                resString = defaultValue;
            }
            return(resString);
        }
Exemplo n.º 6
0
 /**
  * Constructs an instance of {@code Level} taking the supplied name, level
  * value and resource bundle name.
  *
  * @param name
  *            the name of the level.
  * @param level
  *            an integer value indicating the level.
  * @param resourceBundleName
  *            the name of the resource bundle to use.
  * @throws NullPointerException
  *             if {@code name} is {@code null}.
  */
 protected Level(String name, int level, String resourceBundleName)
 {
     if (name == null)
     {
         // logging.1C=The 'name' parameter is null.
         throw new java.lang.NullPointerException("The 'name' parameter is null."); //$NON-NLS-1$
     }
     this.name  = name;
     this.value = level;
     this.resourceBundleName = resourceBundleName;
     if (resourceBundleName != null)
     {
         try {
             rb = ResourceBundle.getBundle(resourceBundleName, Locale
                                           .getDefault(), this.GetType().getClass().getClassLoader());
         } catch (MissingResourceException) {
             rb = null;
         }
     }
     lock (levels) {
         levels.add(this);
     }
 }