Class BundleUtil
- java.lang.Object
- 
- com.inductiveautomation.ignition.common.BundleUtil
 
- 
 public class BundleUtil extends java.lang.Object
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description protected classBundleUtil.BundleGroupClassLoaderBundleUtil.BundleGroupClassLoaderexists so that getResource*() calls can be intercepted and directed togetLangPackLoader()and the wrappedClassLoaderbefore going to the systemClassLoaderif necessary.protected classBundleUtil.KeyTracker
 - 
Field SummaryFields Modifier and Type Field Description protected java.lang.ClassLoaderbaseLoaderprotected com.inductiveautomation.ignition.common.BundleUtil.BundleGroupcommonGroupprotected java.lang.ClassLoaderlangPackLoaderprotected org.apache.log4j.Loggerlogprotected java.util.List<com.inductiveautomation.ignition.common.BundleUtil.ReplaceToken>replacementsprotected java.util.concurrent.ConcurrentMap<java.lang.String,com.inductiveautomation.ignition.common.BundleUtil.BundleGroup>subGroupsprotected java.util.Map<java.lang.String,Version>versionCache
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddBundle(java.lang.Class<?> clazz)Shortcut for adding a resource bundle for a specific class whose prefix is the simple classname.voidaddBundle(java.lang.String prefix, java.lang.Class<?> clazz, java.lang.String bundleName)Adds a bundle that is located next to a class with a custom prefix.voidaddBundle(java.lang.String prefix, java.lang.ClassLoader owner, java.lang.String bundleName)Adds a new prefixed sub-bundle with the given classloader.voidaddCommonBundle(java.lang.String bundleName)Adds a new bundle to the common (non-prefixed) bundle.voidaddExternalLookupLocations(java.util.List<java.net.URL> locations)Registers locations that will be consulted for translation packs.voidaddReplacement(java.lang.String key, java.lang.String value)Adds a new key, value pair that will be used as a replacement token for all bundle strings.voidaddSupportedLocales(java.util.Collection<java.util.Locale> locales)protected java.lang.StringapplyReplacements(java.lang.String source)static BundleUtilget()booleangetBoolean(java.lang.String keyName)java.lang.StringgetClientName()java.awt.ColorgetColor(java.lang.String keyName, java.awt.Color defaultColor)java.lang.StringgetCompanyName()java.lang.StringgetDefinedString(java.util.Locale locale, java.lang.String keyName)Returns the raw translated text, after replacements have been made, but without applying any formatting values.java.lang.StringgetDesignerName()java.lang.StringgetGatewayName()intgetInt(java.lang.String keyName)java.lang.ClassLoadergetLangPackLoader()chargetMnemonic(java.lang.String keyName, char fallBack)Returns a single char that defines a keyboard shortcut, defined in an externalized file.java.lang.StringgetPlatformName()VersiongetPlatformVersion()java.lang.StringgetPlatformVersionString()protected java.lang.StringgetRawString(java.util.Locale locale, java.lang.String key)Looks up the raw key from the local resource bundles.java.lang.StringgetString(java.lang.String keyName)Looks up the resource string associated with the given keyname.java.lang.StringgetString(java.lang.String keyName, java.lang.Object... formatArgs)java.lang.StringgetString(java.util.Locale locale, java.lang.String keyName)java.lang.StringgetString(java.util.Locale locale, java.lang.String keyName, java.lang.Object... formatArgs)java.lang.StringgetStringLenient(java.lang.String keyName)Returns the resource string associated with the given keyname, if any.java.lang.StringgetStringLenient(java.lang.String keyName, java.lang.Object... formatArgs)java.lang.StringgetStringLenient(java.util.Locale locale, java.lang.String keyName, java.lang.Object... formatArgs)java.util.List<java.util.Locale>getSupportedLocales()Provides a list of the locales that are currently supported/selectable.VersiongetVersion(java.lang.String prefix)Shortcut for creating a Version from property resources.java.lang.StringgetVersionString(java.lang.String module)Returns the full version string, like "3.1.1 (build 1557)"java.lang.StringgetVersionStringShort(java.lang.String module)Returns the version string like 1.5.2static java.lang.Stringi18n(java.lang.String key, java.lang.Object... args)Static shorthand forBundleUtil.get().getStringLenient(key, args)static java.lang.Stringi18n(java.util.Locale locale, java.lang.String key, java.lang.Object... args)booleanisKeyPresent(java.lang.String keyName)static booleanisWhiteLabeled()Tests to see if this is a white-labeled build of Ignitionprotected voidrefreshClassLoaders()voidregisterBaseClassLoader(java.lang.ClassLoader loader)voidremoveBundle(java.lang.Class<?> clazz)Equiv to removeBundle(clazz.getSimpleName(), clazz.getName().replace('.', '/'));voidremoveBundle(java.lang.String prefix)Removes all bundles added under the given prefixvoidremoveBundle(java.lang.String prefix, java.lang.String bundleName)Removes all the specific bundle that was added under the given prefix and the given bundle name.booleanremoveReplacement(java.lang.String key)Removes the replacement with this key.protected voidupdateLanguagePackLoader(java.lang.ClassLoader loader)
 
- 
- 
- 
Field Detail- 
baseLoaderprotected java.lang.ClassLoader baseLoader 
 - 
langPackLoaderprotected java.lang.ClassLoader langPackLoader 
 - 
commonGroupprotected com.inductiveautomation.ignition.common.BundleUtil.BundleGroup commonGroup 
 - 
subGroupsprotected java.util.concurrent.ConcurrentMap<java.lang.String,com.inductiveautomation.ignition.common.BundleUtil.BundleGroup> subGroups 
 - 
replacementsprotected java.util.List<com.inductiveautomation.ignition.common.BundleUtil.ReplaceToken> replacements 
 - 
versionCacheprotected java.util.Map<java.lang.String,Version> versionCache 
 - 
logprotected org.apache.log4j.Logger log 
 
- 
 - 
Method Detail- 
getpublic static BundleUtil get() 
 - 
i18npublic static java.lang.String i18n(java.lang.String key, java.lang.Object... args)Static shorthand forBundleUtil.get().getStringLenient(key, args)
 - 
i18npublic static java.lang.String i18n(java.util.Locale locale, java.lang.String key, java.lang.Object... args)
 - 
isWhiteLabeledpublic static boolean isWhiteLabeled() Tests to see if this is a white-labeled build of Ignition
 - 
addExternalLookupLocationspublic void addExternalLookupLocations(java.util.List<java.net.URL> locations) Registers locations that will be consulted for translation packs. The URLs must be to jar files or directories.
 - 
refreshClassLoadersprotected void refreshClassLoaders() 
 - 
updateLanguagePackLoaderprotected void updateLanguagePackLoader(java.lang.ClassLoader loader) 
 - 
registerBaseClassLoaderpublic void registerBaseClassLoader(java.lang.ClassLoader loader) 
 - 
getSupportedLocalespublic java.util.List<java.util.Locale> getSupportedLocales() Provides a list of the locales that are currently supported/selectable.
 - 
addSupportedLocalespublic void addSupportedLocales(java.util.Collection<java.util.Locale> locales) 
 - 
getLangPackLoaderpublic java.lang.ClassLoader getLangPackLoader() 
 - 
addReplacementpublic void addReplacement(java.lang.String key, java.lang.String value)Adds 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
 - 
removeReplacementpublic boolean removeReplacement(java.lang.String key) Removes the replacement with this key.- Returns:
- trueif the key was found.
 
 - 
addBundlepublic void addBundle(java.lang.String prefix, java.lang.ClassLoader owner, java.lang.String bundleName)Adds 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");
 - 
removeBundlepublic void removeBundle(java.lang.Class<?> clazz) Equiv to removeBundle(clazz.getSimpleName(), clazz.getName().replace('.', '/'));
 - 
removeBundlepublic void removeBundle(java.lang.String prefix) Removes all bundles added under the given prefix
 - 
removeBundlepublic void removeBundle(java.lang.String prefix, java.lang.String bundleName)Removes all the specific bundle that was added under the given prefix and the given bundle name.
 - 
addBundlepublic void addBundle(java.lang.Class<?> clazz) Shortcut 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('.', '/'));
 - 
addBundlepublic void addBundle(java.lang.String prefix, java.lang.Class<?> clazz, java.lang.String bundleName)Adds 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"
 - 
addCommonBundlepublic void addCommonBundle(java.lang.String bundleName) Adds 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.
 - 
getMnemonicpublic char getMnemonic(java.lang.String keyName, char fallBack)Returns 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.
 - 
getStringLenientpublic java.lang.String getStringLenient(java.lang.String keyName) Returns 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?".
 - 
getStringLenientpublic java.lang.String getStringLenient(java.lang.String keyName, java.lang.Object... formatArgs)
 - 
getStringLenientpublic java.lang.String getStringLenient(java.util.Locale locale, java.lang.String keyName, java.lang.Object... formatArgs)
 - 
getStringpublic java.lang.String getString(java.lang.String keyName) Looks up the resource string associated with the given keyname. If no resource string is found, null is returned.
 - 
getStringpublic java.lang.String getString(java.lang.String keyName, java.lang.Object... formatArgs)
 - 
getStringpublic java.lang.String getString(java.util.Locale locale, java.lang.String keyName)
 - 
getStringpublic java.lang.String getString(java.util.Locale locale, java.lang.String keyName, java.lang.Object... formatArgs)
 - 
getDefinedStringpublic java.lang.String getDefinedString(java.util.Locale locale, java.lang.String keyName)Returns the raw translated text, after replacements have been made, but without applying any formatting values.
 - 
isKeyPresentpublic boolean isKeyPresent(java.lang.String keyName) 
 - 
getRawStringprotected java.lang.String getRawString(java.util.Locale locale, java.lang.String key)Looks up the raw key from the local resource bundles. Returns null if nothing is found. Does not apply replacements or deal with formatting arguments
 - 
applyReplacementsprotected java.lang.String applyReplacements(java.lang.String source) 
 - 
getColorpublic java.awt.Color getColor(java.lang.String keyName, java.awt.Color defaultColor)
 - 
getBooleanpublic boolean getBoolean(java.lang.String keyName) 
 - 
getIntpublic int getInt(java.lang.String keyName) 
 - 
getCompanyNamepublic java.lang.String getCompanyName() 
 - 
getGatewayNamepublic java.lang.String getGatewayName() 
 - 
getClientNamepublic java.lang.String getClientName() 
 - 
getDesignerNamepublic java.lang.String getDesignerName() 
 - 
getPlatformNamepublic java.lang.String getPlatformName() 
 - 
getVersionpublic Version getVersion(java.lang.String prefix) Shortcut for creating a Version from property resources. Given the prefix, uses the keyPREFIX.versionwhich should be valid according toVersion.parse(String)
 - 
getPlatformVersionpublic Version getPlatformVersion() 
 - 
getPlatformVersionStringpublic java.lang.String getPlatformVersionString() 
 - 
getVersionStringpublic java.lang.String getVersionString(java.lang.String module) Returns the full version string, like "3.1.1 (build 1557)"
 - 
getVersionStringShortpublic java.lang.String getVersionStringShort(java.lang.String module) Returns the version string like 1.5.2
 
- 
 
-