Configuration Issues > Globalization > Resources
 
Resources
This section describes the way ICU resources are handled within the IlEnvironment class.
Files and Bundles
Resources are grouped in bundles which are loaded from binary files. Thus, depending of the platform using 'little endian" or "big endian", the resource files are different.
At installation time, Rogue Wave DB Link ensures that the resource file is adequate for the port and only copies the appropriate root.res file.
Therefore, it is not recommended to proceed with the installation of two different ports in the same location as the file will be overwritten with the one adapted for the second port which may differ from the standpoint of the "endian" configuration.
The original textual format is defined in the ICU documentation: see http://icu-project.org.
The IlEnvironment class provides the ability to load several resource files at runtime.
The IlEnvironment instance considers each file as a separate top level bundle whose name is given at load time.
Loading
Resource files are loaded using the function loadResources which takes one argument: the directory where to look for the resource file (usually named "root.res").
The function will return IlFalse if given a null or empty argument.
The function makes use of an internal list of pathnames, in turn concatenating the bundle name to each of them to build full directory pathnames where it will look until a file is found.
The pathname list can be enlarged using the function addDataDir where the only argument is the new pathname to add to the list. If the given pathname is already present in the list, a new one is not added but the function will not fail.
The pathname list can be reset to be empty or to contain a unique, valid, pathname using the function setDataDir. If the argument to this function is a null or empty string, the existing list is emptied and the function returns IlFalse, meaning that no pathname was set in the list.
Using Resource Bundles
1. Retrieving a specific bundle
Resource bundles are retrieved from the instance using the function getResources where the unique argument is a bundle name. If the argument is null or no bundle with the given name is found, the last loaded bundle, if any, is returned.
The returned object is of the ResourceBundle ICU class.
Warning: This object must not be destroyed by the application.
2. Retrieving a resource value in the bundles tree
Several functions allow retrieving a specific typed value from the bundles tree. These functions use a list of bundle names to look into the tree until a resource with a given name is found.
The functions getCharResource (to retrieve a Unicode string) and getIntResource (to retrieve an integer) take three arguments:
*The number of bundles to traverse while exploring the tree.
*The list of bundle names. This list must have at a minimum as many entries as given by the first argument.
*An optional key to be used as the last search indicator once the tree has been traversed.
The functions getIntVectResource, getIntVectNthResource, and getBinaryResource have an additional argument coming before the optional key.
This additional argument is a reference to an IlInt for the functions getIntVectResource and getBinaryResource which will be modified on output while the argument is an IlInt value for the getIntVectNthResource function. For both functions getIntVectResource and getBinaryResource, the value returned in this integer is the length of the vector or of the binary data.
As their names imply, the functions return:
*A Unicode string for getCharResource,
*A integer for getIntResource,
*A vector of integers for getIntVectResource,
*A binary string for getBinaryResource,
*The integer at the position given by the third argument in an integer vector resource for getIntVectNthResource.

Version 5.8
Copyright © 2014, Rogue Wave Software, Inc. All Rights Reserved.