Class BundleUtil
java.lang.Object
com.inductiveautomation.ignition.common.BundleUtil
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected classBundleUtil.BundleGroupClassLoaderexists so that getResource*() calls can be intercepted and directed togetLangPackLoader()and the wrappedClassLoaderbefore going to the systemClassLoaderif necessary.protected class
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected ClassLoaderprotected com.inductiveautomation.ignition.common.BundleUtil.BundleGroupprotected ClassLoaderprotected org.apache.log4j.Loggerprotected List<com.inductiveautomation.ignition.common.BundleUtil.ReplaceToken>protected ConcurrentMap<String,com.inductiveautomation.ignition.common.BundleUtil.BundleGroup> 
- 
Method SummaryModifier and TypeMethodDescriptionvoidShortcut for adding a resource bundle for a specific class whose prefix is the simple classname.voidAdds a bundle that is located next to a class with a custom prefix.voidaddBundle(String prefix, ClassLoader owner, String bundleName) Adds a new prefixed sub-bundle with the given classloader.voidaddCommonBundle(String bundleName) Adds a new bundle to the common (non-prefixed) bundle.voidaddExternalLookupLocations(List<URL> locations) Registers locations that will be consulted for translation packs.voidaddReplacement(String key, String value) Adds a new key, value pair that will be used as a replacement token for all bundle strings.voidaddSupportedLocales(Collection<Locale> locales) protected StringapplyReplacements(String source) static BundleUtilget()booleangetBoolean(String keyName) getDefinedString(Locale locale, String keyName) Returns the raw translated text, after replacements have been made, but without applying any formatting values.intchargetMnemonic(String keyName, char fallBack) Returns a single char that defines a keyboard shortcut, defined in an externalized file.protected StringgetRawString(Locale locale, String key) Looks up the raw key from the local resource bundles.Looks up the resource string associated with the given keyname.getStringLenient(String keyName) Returns the resource string associated with the given keyname, if any.getStringLenient(String keyName, Object... formatArgs) getStringLenient(Locale locale, String keyName, Object... formatArgs) Provides a list of the locales that are currently supported/selectable.getVersion(String prefix) Shortcut for creating a Version from property resources.getVersionString(String module) Returns the full version string, like "3.1.1 (build 1557)"getVersionStringShort(String module) Returns the version string like 1.5.2static StringStatic shorthand forBundleUtil.get().getStringLenient(key, args)static StringbooleanisKeyPresent(String keyName) static booleanTests to see if this is a white-labeled build of Ignitionprotected voidvoidregisterBaseClassLoader(ClassLoader loader) voidremoveBundle(Class<?> clazz) Equiv to removeBundle(clazz.getSimpleName(), clazz.getName().replace('.', '/'));voidremoveBundle(String prefix) Removes all bundles added under the given prefixvoidremoveBundle(String prefix, String bundleName) Removes all the specific bundle that was added under the given prefix and the given bundle name.booleanremoveReplacement(String key) Removes the replacement with this key.protected voidupdateLanguagePackLoader(ClassLoader loader) 
- 
Field Details- 
baseLoader
- 
langPackLoader
- 
commonGroupprotected com.inductiveautomation.ignition.common.BundleUtil.BundleGroup commonGroup
- 
subGroupsprotected ConcurrentMap<String,com.inductiveautomation.ignition.common.BundleUtil.BundleGroup> subGroups
- 
replacements
- 
versionCache
- 
logprotected org.apache.log4j.Logger log
 
- 
- 
Method Details- 
get
- 
i18nStatic shorthand forBundleUtil.get().getStringLenient(key, args)
- 
i18n
- 
isWhiteLabeledpublic static boolean isWhiteLabeled()Tests to see if this is a white-labeled build of Ignition
- 
addExternalLookupLocationsRegisters locations that will be consulted for translation packs. The URLs must be to jar files or directories.
- 
refreshClassLoadersprotected void refreshClassLoaders()
- 
updateLanguagePackLoader
- 
registerBaseClassLoader
- 
getSupportedLocalesProvides a list of the locales that are currently supported/selectable.
- 
addSupportedLocales
- 
getLangPackLoader
- 
addReplacementAdds a new key, value pair that will be used as a replacement token for all bundle strings. For example, if one added:addReplacement("COMPANY","Acme SuperSCADA");
 then the following resource key:
 mymod.aboutblurb=Brought to you by ${COMPANY}
 would expand to:
 Brought to you by Acme SuperSCADA
- 
removeReplacementRemoves the replacement with this key.- Returns:
- trueif the key was found.
 
- 
addBundleAdds a new prefixed sub-bundle with the given classloader. The prefix will be used to retrieve all the keys in the bundle. For example, if you bundle is like:Confirm=Are You Sure HelpText=Eek! And you add the bundle like:addBundle("MyModule", loader, "com/acme/product/PropFile");Then you'd get the key like this:BundleUtil.get().getString("MyModule.Confirm");
- 
removeBundleEquiv to removeBundle(clazz.getSimpleName(), clazz.getName().replace('.', '/'));
- 
removeBundleRemoves all bundles added under the given prefix
- 
removeBundleRemoves all the specific bundle that was added under the given prefix and the given bundle name.
- 
addBundleShortcut for adding a resource bundle for a specific class whose prefix is the simple classname.For example, if you had com.example.MyClass, then you would put a resource file atcom/example/MyClass.propertiesand you would access properties via"MyClass.Keyname"Equivalent to: addBundle(clazz.getSimpleName(), clazz.getClassLoader(), clazz.getName().replace('.', '/'));
- 
addBundleAdds a bundle that is located next to a class with a custom prefix. For example, if you hadcom.example.MyClass, and a resource file such ascom/example/strings.properties, a call such asaddBundle("mymod", MyClass.class, "strings");would let you would access the properties via"mymod.Keyname"
- 
addCommonBundleAdds a new bundle to the common (non-prefixed) bundle. Only will work if the bundle can be loaded by the classloader that loaded the BundleUtil itself. Will not work for module-supplied bundles.
- 
getMnemonicReturns a single char that defines a keyboard shortcut, defined in an externalized file. Takes a fallback return value in case the entry isn't found.
- 
getStringLenientReturns the resource string associated with the given keyname, if any. If no resource string is found, the keyname itself is returned, but with question marks around it, like "MyKey?".
- 
getStringLenient
- 
getStringLenient
- 
getStringLooks up the resource string associated with the given keyname. If no resource string is found, null is returned.
- 
getString
- 
getString
- 
getString
- 
getDefinedStringReturns the raw translated text, after replacements have been made, but without applying any formatting values.
- 
isKeyPresent
- 
getRawStringLooks up the raw key from the local resource bundles. Returns null if nothing is found. Does not apply replacements or deal with formatting arguments
- 
applyReplacements
- 
getColor
- 
getBoolean
- 
getInt
- 
getCompanyName
- 
getGatewayName
- 
getClientName
- 
getDesignerName
- 
getPlatformName
- 
getVersionShortcut for creating a Version from property resources. Given the prefix, uses the keyPREFIX.versionwhich should be valid according toVersion.parse(String)
- 
getPlatformVersion
- 
getPlatformVersionString
- 
getVersionStringReturns the full version string, like "3.1.1 (build 1557)"
- 
getVersionStringShortReturns the version string like 1.5.2
 
-