Class UResourceBundle

java.lang.Object
java.util.ResourceBundle
com.adobe.agl.util.UResourceBundle
Direct Known Subclasses:
ICUResourceBundle, ResourceBundleWrapper

public abstract class UResourceBundle extends ResourceBundle
A class representing a collection of resource information pertaining to a given locale. A resource bundle provides a way of accessing locale- specific information in a data file. You create a resource bundle that manages the resources for a given locale and then ask it for individual resources.

In ResourceBundle class, an object is created and the sub items are fetched using getString, getObject methods. In UResourceBundle,each individual element of a resource is a resource by itself.

Resource bundles in ICU are currently defined using text files which conform to the following BNF definition. More on resource bundle concepts and syntax can be found in the Users Guide.

The packaging of ICU *.res files can be of two types ICU4C:

       root.res
         |
      --------
     |        |
   fr.res  en.res
     |
   --------
  |        |
 fr_CA.res fr_FR.res
 
JAVA/JDK:
    LocaleElements.res
         |
      -------------------
     |                   |
 LocaleElements_fr.res  LocaleElements_en.res
     |
   ---------------------------
  |                            |
 LocaleElements_fr_CA.res   LocaleElements_fr_FR.res
 
Depending on the organization of your resources, the syntax to getBundleInstance will change. To open ICU style organization use:
      UResourceBundle bundle = UResourceBundle.getBundleInstance("com/mycompany/resources", "en_US", myClassLoader);
 
To open Java/JDK style organization use:
      UResourceBundle bundle = UResourceBundle.getBundleInstance("com.mycompany.resources.LocaleElements", "en_US", myClassLoader);
 
Please use pass a class loader for loading non-ICU resources. Java security does not allow loading of resources across jar files. You must provide your class loader to load the resources
  • Field Details

    • NONE

      public static final int NONE
      Resource type constant for "no resource".
      See Also:
    • STRING

      public static final int STRING
      Resource type constant for strings.
      See Also:
    • BINARY

      public static final int BINARY
      Resource type constant for binary data.
      See Also:
    • TABLE

      public static final int TABLE
      Resource type constant for tables of key-value pairs.
      See Also:
    • INT

      public static final int INT
      Resource type constant for a single 28-bit integer, interpreted as signed or unsigned by the getInt() function.
      See Also:
    • ARRAY

      public static final int ARRAY
      Resource type constant for arrays of resources.
      See Also:
    • INT_VECTOR

      public static final int INT_VECTOR
      Resource type constant for vectors of 32-bit integers.
      See Also:
  • Constructor Details

    • UResourceBundle

      public UResourceBundle()
      Sole constructor. (For invocation by subclass constructors, typically implicit.) This is public for compatibility with Java, whose compiler will generate public default constructors for an abstract class.
  • Method Details

    • getBundleInstance

      public static UResourceBundle getBundleInstance(String baseName, String localeName)
      Creates a resource bundle using the specified base name and locale. ICU_DATA_CLASS is used as the default root.
      Parameters:
      baseName - the base name of the resource bundle, a fully qualified class name
      localeName - the locale for which a resource bundle is desired
      Returns:
      a resource bundle for the given base name and locale
      Throws:
      MissingResourceException - if no resource bundle for the specified base name can be found
    • getBundleInstance

      public static UResourceBundle getBundleInstance(String baseName, String localeName, ClassLoader root)
      Creates a resource bundle using the specified base name, locale, and class root.
      Parameters:
      baseName - the base name of the resource bundle, a fully qualified class name
      localeName - the locale for which a resource bundle is desired
      root - the class object from which to load the resource bundle
      Returns:
      a resource bundle for the given base name and locale
      Throws:
      MissingResourceException - if no resource bundle for the specified base name can be found
    • getBundleInstance

      public static UResourceBundle getBundleInstance(ULocale locale)
      Creates a UResourceBundle for the locale specified, from which users can extract resources by using their corresponding keys.
      Parameters:
      locale - specifies the locale for which we want to open the resource. If null the bundle for default locale is opened.
      Returns:
      a resource bundle for the given locale
    • getBundleInstance

      public static UResourceBundle getBundleInstance(String baseName)
      Creates a UResourceBundle for the default locale and specified base name, from which users can extract resources by using their corresponding keys.
      Parameters:
      baseName - specifies the locale for which we want to open the resource. If null the bundle for default locale is opened.
      Returns:
      a resource bundle for the given base name and default locale
    • getBundleInstance

      public static UResourceBundle getBundleInstance(String baseName, Locale locale)
      Creates a UResourceBundle for the specified locale and specified base name, from which users can extract resources by using their corresponding keys.
      Parameters:
      baseName - specifies the locale for which we want to open the resource. If null the bundle for default locale is opened.
      locale - specifies the locale for which we want to open the resource. If null the bundle for default locale is opened.
      Returns:
      a resource bundle for the given base name and locale
    • getBundleInstance

      public static UResourceBundle getBundleInstance(String baseName, ULocale locale)
      Creates a UResourceBundle, from which users can extract resources by using their corresponding keys.
      Parameters:
      baseName - string containing the name of the data package. If null the default ICU package name is used.
      locale - specifies the locale for which we want to open the resource. If null the bundle for default locale is opened.
      Returns:
      a resource bundle for the given base name and locale
    • getBundleInstance

      public static UResourceBundle getBundleInstance(String baseName, Locale locale, ClassLoader loader)
      Creates a UResourceBundle for the specified locale and specified base name, from which users can extract resources by using their corresponding keys.
      Parameters:
      baseName - specifies the locale for which we want to open the resource. If null the bundle for default locale is opened.
      locale - specifies the locale for which we want to open the resource. If null the bundle for default locale is opened.
      loader - the loader to use
      Returns:
      a resource bundle for the given base name and locale
    • getBundleInstance

      public static UResourceBundle getBundleInstance(String baseName, ULocale locale, ClassLoader loader)
      Creates a UResourceBundle, from which users can extract resources by using their corresponding keys.

      Note: Please use this API for loading non-ICU resources. Java security does not allow loading of resources across jar files. You must provide your class loader to load the resources
      Parameters:
      baseName - string containing the name of the data package. If null the default ICU package name is used.
      locale - specifies the locale for which we want to open the resource. If null the bundle for default locale is opened.
      loader - the loader to use
      Returns:
      a resource bundle for the given base name and locale
    • getULocale

      public abstract ULocale getULocale()
      Returns the RFC 3066 conformant locale id of this resource bundle. This method can be used after a call to getBundleInstance() to determine whether the resource bundle returned really corresponds to the requested locale or is a fallback.
      Returns:
      the locale of this resource bundle
    • getLocale

      public Locale getLocale()
      Get the locale of this bundle
      Overrides:
      getLocale in class ResourceBundle
      Returns:
      the locale of this resource bundle
    • getBinary

      public ByteBuffer getBinary()
      Returns a binary data from a binary resource.
      Returns:
      a pointer to a chuck of unsigned bytes which live in a memory mapped/DLL file.
      Throws:
      MissingResourceException
      UResourceTypeMismatchException
      See Also:
    • getString

      public String getString()
      Returns a string from a string resource type
      Returns:
      a string
      Throws:
      MissingResourceException
      UResourceTypeMismatchException
      See Also:
    • getStringArray

      public String[] getStringArray()
      Returns a string array from a array resource type
      Returns:
      a string
      Throws:
      MissingResourceException
      UResourceTypeMismatchException
      See Also:
    • getBinary

      public byte[] getBinary(byte[] ba)
      Returns a binary data from a binary resource.
      Parameters:
      ba - The byte array to write the bytes to. A null variable is OK.
      Returns:
      an array bytes containing the binary data from the resource.
      Throws:
      MissingResourceException
      UResourceTypeMismatchException
      See Also:
    • getIntVector

      public int[] getIntVector()
      Returns a 32 bit integer array from a resource.
      Returns:
      a pointer to a chunk of unsigned bytes which live in a memory mapped/DLL file.
      Throws:
      MissingResourceException
      UResourceTypeMismatchException
      See Also:
    • getInt

      public int getInt()
      Returns a signed integer from a resource.
      Returns:
      an integer value
      Throws:
      MissingResourceException
      UResourceTypeMismatchException
      See Also:
    • getUInt

      public int getUInt()
      Returns a unsigned integer from a resource. This integer is originally 28 bit and the sign gets propagated.
      Returns:
      an integer value
      Throws:
      MissingResourceException
      UResourceTypeMismatchException
      See Also:
    • get

      public UResourceBundle get(String aKey)
      Returns a resource in a given resource that has a given key.
      Parameters:
      aKey - a key associated with the wanted resource
      Returns:
      a resource bundle object representing the resource
      Throws:
      MissingResourceException
    • getSize

      public int getSize()
      Returns the size of a resource. Size for scalar types is always 1, and for vector/table types is the number of child resources.
      Warning: Integer array is treated as a scalar type. There are no APIs to access individual members of an integer array. It is always returned as a whole.
      Returns:
      number of resources in a given resource.
    • getVersion

      public VersionInfo getVersion()
      Return the version number associated with this UResourceBundle as an VersionInfo object.
      Returns:
      VersionInfo object containing the version of the bundle
    • getKey

      public String getKey()
      Returns the key associated with a given resource. Not all the resources have a key - only those that are members of a table.
      Returns:
      a key associated to this resource, or null if it doesn't have a key