Location of resourcebundle files




















It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi. Forum: Beginning Java. Optional 'thank-you' note:. Hello all im using resource bundle to load values from properties files , i like to know from where the resource bundle load its properties file in the classpath is there away to do this?

Minh Tran. It is safer and more securer if you use ResourceBundle to load. You can write it by yourself as simple way. It use classLoader and stream to load file as its locale. Refer to the descriptions of the getBundle factory method , clearCache , ResourceBundle.

Example The following is a very simple example of a ResourceBundle subclass, MyResources , that manages two resources for a larger number of resources you would probably use a Map.

Notice that you don't need to supply a value if a "parent-level" ResourceBundle handles the same key with the same value as for the okKey below.

Control ResourceBundle. Control defines a set of callback methods that are invoked by the ResourceBundle. Removes all resource bundles from the cache that have been loaded by the caller's module. Removes all resource bundles from the cache that have been loaded by the given class loader.

Determines whether the given key is contained in this ResourceBundle or its parent bundles. Gets a resource bundle using the specified base name, the default locale, and the caller module. Gets a resource bundle using the specified base name and the default locale on behalf of the specified module. Gets a resource bundle using the specified base name and locale, and the caller module. Returns a resource bundle using the specified base name, target locale, class loader and control. Gets a resource bundle using the specified base name and locale on behalf of the specified module.

Returns a resource bundle using the specified base name, target locale and control, and the caller's class loader. Returns a resource bundle using the specified base name, the default locale and the specified control. Gets an object for the given key from this resource bundle or one of its parents. Gets a string array for the given key from this resource bundle or one of its parents.

Returns a Set of the keys contained only in this ResourceBundle. Returns a Set of all keys contained in this ResourceBundle and its parent bundles. Field Detail parent protected ResourceBundle parent The parent bundle of this bundle. The parent bundle is searched by getObject when this bundle does not contain a particular resource. Sole constructor. For invocation by subclass constructors, typically implicit. Returns the base name of this bundle, if known, or null if unknown.

If not null, then this is the value of the baseName parameter that was passed to the ResourceBundle. Gets a string for the given key from this resource bundle or one of its parents.

Calling this method is equivalent to calling String getObject key. Calling this method is equivalent to calling String[] getObject key. This method first tries to obtain the object from this resource bundle using handleGetObject. If not successful, and the parent resource bundle is not null, it calls the parent's getObject method.

If still not successful, it throws a MissingResourceException. Returns the locale of this resource bundle. This method can be used after a call to getBundle to determine whether the resource bundle returned really corresponds to the requested locale or is a fallback. Sets the parent bundle of this bundle. Calling this method is equivalent to calling getBundle baseName, Locale.

See getBundle for the complete description of the resource bundle loading process with a ResourceBundle. Calling this method is equivalent to calling getBundle baseName, locale, callerModule ,. This method is equivalent to calling getBundle baseName, Locale. Calling this method is equivalent to calling getBundle baseName, targetLocale, this.

Gets a resource bundle using the specified base name, locale, and class loader. Resource Bundle Search and Loading Strategy getBundle uses the base name, the specified locale, and the default locale obtained from Locale. Once the parent chain is complete, the bundle is returned.

Example: The following class and property files are provided: MyResources. Unlike the getBundle factory methods with no control argument, the given control specifies how to locate and instantiate resource bundles. Conceptually, the bundle loading process with the given control is performed in the following steps. This factory method looks up the resource bundle in the cache for the specified baseName , targetLocale and loader. If the requested resource bundle instance is found in the cache and the time-to-live periods of the instance and all of its parent instances have not expired, the instance is returned to the caller.

Otherwise, this factory method proceeds with the loading process below. The control. The strings "java. Other strings starting with "java. Other strings designate application-defined formats. Refer to the note on the cache lookup below. This step is iterated over all combinations of the candidate locales and formats until the newBundle method returns a ResourceBundle instance or the iteration has used up all the combinations.

For example, if the candidate locales are Locale "de", "DE" , Locale "de" and Locale "" and the formats are "java. If a bundle has been found that is a base bundle a bundle for Locale "" , and the candidate locale list only contained Locale "" , return the bundle to the caller.

If a bundle has been found that is a base bundle, but the candidate locale list contained locales other than Locale "" , put the bundle on hold and proceed to Step 6. If a bundle has been found that is not a base bundle, proceed to Step 7. If the method returns a non-null locale, it becomes the next target locale and the loading process starts over from Step 3.

Otherwise, if a base bundle was found and put on hold in a previous Step 5, it is returned to the caller now. Otherwise, a MissingResourceException is thrown. At this point, we have found a resource bundle that's not the base bundle. If this bundle set its parent during its instantiation, it is returned to the caller. An iOS application should be internationalized and have a language.

Even if you provide localized versions, however, you should always include a default version of these files at the top-level of your application bundle.

The default version is used in situations where a specific localization is not available. For more information about localized resources, see Localized Resources in Bundles.

Every iOS application must have an information property list Info. When you create a new iOS application project, Xcode creates this file automatically and sets the value of some of the key properties for you. Table lists some additional keys that you should set explicitly.

Xcode obscures actual key names by default, so the string displayed by Xcode is also listed in parenthesis where one is used. The bundle display name is the name displayed underneath the application icon. This value should be localized for all supported languages. The bundle identifier string identifies your application to the system. This string must be a uniform type identifier UTI that contains only alphanumeric A - Z , a - z , 0 - 9 , hyphen - , and period.

The string should also be in reverse-DNS format. The bundle version string specifies the build version number of the bundle. This value is a monotonically increased string, comprised of one or more period-separated integers. This value cannot be localized. Although technically not required, it is strongly encouraged that you use it. A Boolean value that indicates whether the bundle can run on iOS only.

Xcode adds this key automatically and sets its value to true. You should not change the value of this key. A key that tells iTunes and the App Store know which device-related features an application requires in order to run. The value of this key is either an array or a dictionary. If you use an array, the presence of a given key indicates the corresponding feature is required.

If you use a dictionary, you must specify a Boolean value for each key indicating whether the feature is required. In both cases, not including a key indicates that the feature is not required. This key is supported in iOS 3. In addition to the keys in the preceding table, Table lists some keys that are commonly used by iOS applications. Although these keys are not required, most provide a way to adjust the configuration of your application at launch time.

Providing these keys can help ensure that your application is presented appropriately by the system. If you want to use a nib file other than the default one created for your project, associate the name of that nib file with this key. The name of the nib file should not include the. A string that identifies the style of the status bar as the application launches.

The application can change this initial status-bar style when it finishes launching. A Boolean value that determines whether the status bar is initially hidden when the application launches. Set it to true to hide the status bar. The default value is false. A Boolean value that indicates whether the application icon already includes gloss and bevel effects. Set it to true if you do not want the system to add these effects to your artwork. A Boolean value that notifies the system that the application uses the Wi-Fi network for communication.

Applications that use Wi-Fi for any period of time must set this key to true ; otherwise, after 30 minutes, the device shuts down Wi-Fi connections to save power. Setting this flag also lets the system know that it should display the network selection dialog when Wi-Fi is available but not currently being used.

Even if the value of this property is true , this key has no effect when the device is idle that is, screen-locked. During that time, the application is considered inactive and, although it may function on some levels, it has no Wi-Fi connection.

If you do not specify this key, the base name is assumed to be the string Default. Application icons and launch images are standard graphics that must be present in every application. And an application may specify several different icons for use in different situations.

For example, applications can provide a small version of the application icon to use when displaying search results. Launch images provide visual feedback to the user that your application launched. The image files used to represent icons and launch images must all reside in the root level of your bundle. How you identify these images to the system can vary, but the recommended way to specify your application icons is to use the CFBundleIconFiles key.

For detailed information about how to specify the icons and launch images in your application, see the discussion of these items in Advanced App Tricks in App Programming Guide for iOS. Although you should place most nonlocalized resources in this top-level directory, you can also create subdirectories to organize your resource files.

Localized resources must be placed in one or more language-specific subdirectories, which are discussed in more detail in Localized Resources in Bundles. Listing shows a fictional application that includes both localized and nonlocalized resources. The nonlocalized resources include Hand.

The localized resources include everything in the en. Listing An iOS application with localized and nonlocalized resources. For information about finding resource files in your application bundle, see Accessing a Bundle's Contents. For information about how to load resource files and use them in your program, see Resource Programming Guide.

The project templates provided by Xcode do most of the work necessary for setting up your Mac app bundle during development.

The hierarchical nature also helps the system distinguish code bundles such as applications from the directory packages used by other applications to implement document types.

The basic structure of a Mac app bundle is very simple. At the top-level of the bundle is a directory named Contents. This directory contains everything, including the resources, executable code, private frameworks, private plug-ins, and support files needed by the application. While the Contents directory might seem superfluous, it identifies the bundle as a modern-style bundle and separates it from document and legacy bundle types found in earlier versions of Mac OS.

Listing shows the high-level structure of a typical application bundle, including the immediate files and directories you are most likely to find inside the Contents directory. This structure represents the core of every Mac app.

Listing The basic structure of a Mac app. Table lists some of the directories that you might find inside the Contents directory, along with the purpose of each one.

This list is not exhaustive but merely represents the directories in common usage. However, you may put other standalone executables such as command-line tools in this directory as well. This contents of this directory are further organized to distinguish between localized and nonlocalized resources.

For more information about the structure of this directory, see The Resources Directory. Contains any private shared libraries and frameworks used by the executable. The frameworks in this directory are revision-locked to the application and cannot be superseded by any other, even newer, versions that may be available to the operating system.

In other words, the frameworks included in this directory take precedence over any other similarly named frameworks found in other parts of the operating system. For information on how to add private frameworks to your application bundle, see Framework Programming Guide.

Contains loadable bundles that extend the basic features of your application. You would not use this directory to store standalone executables. Contains additional non-critical resources that do not impact the ability of the application to run.

You might use this directory to include things like document templates, clip art, and tutorials that your application expects to be present but that do not affect the ability of your application to run.

Application bundles have evolved significantly over the years but the overall goal has been the same. The bundle organization makes it easier for the application to find its resources while making it harder for users to interfere with those resources.

Because the Finder treats most bundles as opaque entities, it is difficult for casual users to move or delete the resources an application might need. For the Finder to recognize an application bundle as such, you need to include an information property list Info.

This file contains XML property-list data that identifies the configuration of your bundle. For a minimal bundle, this file would contain very little information, most likely just the name and identifier of the bundle. For more complex bundles, the Info.

Table lists the keys that you should always include in your Info. Xcode provides all of these keys automatically when you create a new project. Xcode obscures actual key names by default, so the string displayed by Xcode is also listed in parenthesis.



0コメント

  • 1000 / 1000