Class ResourceManager


  • @OpenApiAll
    public class ResourceManager
    extends java.lang.Object
    This class is used to retrieve the resources from the resource bundle files
    • Constructor Summary

      Constructors 
      Constructor Description
      ResourceManager()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void createAvailableLanguages()
      Creates Available language.
      static java.lang.String formatMessage​(java.lang.Object[] messageArguments, java.lang.String message)  
      static java.lang.String formatMessage​(java.lang.String message, java.lang.String... arguments)  
      static java.util.Set<java.lang.String> getAvailableLanguages()  
      static java.util.Locale getLocale()
      Gets set locale.
      static LocaleInfo getLocaleInfo()  
      static java.lang.String getMetaModelResource​(MDElement presentationElement)
      Returns meta model resource.
      static java.lang.String getMetaModelResource​(java.lang.Class type)
      Returns meta model resource.
      static java.lang.String getMetaModelResource​(javax.jmi.reflect.RefObject element)
      Returns meta model resource.
      static java.lang.String getStringFor​(java.lang.String key, int bundle)
      Get string according to key and bundle id.
      static java.lang.String getStringFor​(java.lang.String key, int bundle, java.lang.Object[] messageArguments)
      Get string according to key and bundle id.
      static java.lang.String getStringFor​(java.lang.String key, int bundle, java.lang.String messageArguments)
      Get string according to key and bundle id.
      static java.lang.String getStringFor​(java.lang.String key, java.lang.String bundleName, java.lang.ClassLoader loader)
      Get string according to key and bundle id.
      static java.lang.String getStringOrElse​(java.lang.String key, java.lang.String bundleName, java.lang.ClassLoader loader, java.util.function.Supplier<java.lang.String> alternative)
      Get string according to key and bundle id.
      static void setLocale​(LocaleInfo localeInfo)
      Sets locale.
      static void setLocale​(java.util.Locale locale)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • ENGLISH

        public static final java.lang.String ENGLISH
      • RESOURCES_CLASS_NAMES

        public static final java.lang.String[] RESOURCES_CLASS_NAMES
    • Constructor Detail

      • ResourceManager

        public ResourceManager()
    • Method Detail

      • getMetaModelResource

        public static java.lang.String getMetaModelResource​(java.lang.Class type)
        Returns meta model resource.
      • getMetaModelResource

        public static java.lang.String getMetaModelResource​(MDElement presentationElement)
        Returns meta model resource.
      • getMetaModelResource

        public static java.lang.String getMetaModelResource​(javax.jmi.reflect.RefObject element)
        Returns meta model resource.
      • getStringFor

        public static java.lang.String getStringFor​(java.lang.String key,
                                                    int bundle)
        Get string according to key and bundle id. If there are no such - returns key.
        Parameters:
        key - Key to fetch string
        bundle - Bundle ID
        Returns:
        String for key from given bundle.
      • getStringFor

        public static java.lang.String getStringFor​(java.lang.String key,
                                                    java.lang.String bundleName,
                                                    @CheckForNull
                                                    java.lang.ClassLoader loader)
        Get string according to key and bundle id. If there are no such - returns key.
        Parameters:
        key - Key to fetch string
        bundleName - Bundle name
        loader - loader to load resources
        Returns:
        String for key from given bundle.
      • getStringOrElse

        public static java.lang.String getStringOrElse​(java.lang.String key,
                                                       java.lang.String bundleName,
                                                       @CheckForNull
                                                       java.lang.ClassLoader loader,
                                                       java.util.function.Supplier<java.lang.String> alternative)
        Get string according to key and bundle id. If there is no such - returns alternative from the passed in supplier.
        Parameters:
        key - Key to fetch string
        bundleName - Bundle name
        loader - loader to load resources
        alternative - result to be returned in case key or bundle is not found
        Returns:
        String for key from given bundle, or alternative if the key or bundle is not found
      • getStringFor

        public static java.lang.String getStringFor​(java.lang.String key,
                                                    int bundle,
                                                    java.lang.String messageArguments)
        Get string according to key and bundle id. If there are no such - returns key. Can retrieve customizable message bundles.
        Parameters:
        key - Key to fetch string
        bundle - Bundle ID
        messageArguments - Set of the message bundle arguments.
        Returns:
        String for key from given bundle.
      • getStringFor

        public static java.lang.String getStringFor​(java.lang.String key,
                                                    int bundle,
                                                    @CheckForNull
                                                    java.lang.Object[] messageArguments)
        Get string according to key and bundle id. If there are no such - returns key. Can retrieve customizable message bundles.
        Parameters:
        key - Key to fetch string
        bundle - Bundle id
        messageArguments - Set of the message bundle arguments.
        Returns:
        String for key from given bundle.
      • formatMessage

        public static java.lang.String formatMessage​(java.lang.String message,
                                                     java.lang.String... arguments)
      • formatMessage

        public static java.lang.String formatMessage​(java.lang.Object[] messageArguments,
                                                     java.lang.String message)
      • getLocale

        public static java.util.Locale getLocale()
        Gets set locale. If there are no such - creates default.
        Returns:
        locale, which is used for bundles
      • getLocaleInfo

        public static LocaleInfo getLocaleInfo()
      • setLocale

        public static void setLocale​(java.util.Locale locale)
      • setLocale

        public static void setLocale​(LocaleInfo localeInfo)
        Sets locale. This operation is called only when is read environment options
        Parameters:
        localeInfo - Bundles will be chosen according this locale
      • getAvailableLanguages

        public static java.util.Set<java.lang.String> getAvailableLanguages()
      • createAvailableLanguages

        public static void createAvailableLanguages()
        Creates Available language.