Package wt.util
Class LocalizedResource
java.lang.Object
wt.util.LocalizedResource
LocalizedResource contains the utility methods for finding and opening the resource that
best matches the given Locale.
Supported API: true
Extendable: false
Supported API: true
Extendable: false
-
Constructor Summary
ConstructorsConstructorDescriptionLocalizedResource(String resourceName)
Supported API: trueLocalizedResource(String resourceName, String alternateExtension)
Supported API: true -
Method Summary
Modifier and TypeMethodDescriptionprotected voidClose input stream of this instance.protected InputStreamReturn input stream of best matching resource.Get the Locale object for this instance.static StringgetLocalizedResourceName(Locale aLocale, String aFilename) Returns the Localized name of a Resource, with a specified Locale and a filename.static StringgetLocalizedResourceName(WTContext aContext, String aFilename) Returns the Localized name of a Resource, with a specified Locale and a filename.Get the resource name that best matched.protected voidinit()Look for the given resource for the server's locale.protected voidLook for the given resource for the given locale.voidLook for the given resource for the given locales.Look for the given resource for the server's locale.openResource(Locale locale) Look for the given resource for the given locale.openResource(Vector preferences) Look for the given resource for the given locales.static voidsetDebug(boolean value) Sets the debug value which controls logging from this class.voidSet the Locale object for this instance.
-
Constructor Details
-
LocalizedResource
Supported API: true -
LocalizedResource
Supported API: true
-
-
Method Details
-
getLocale
Get the Locale object for this instance. Instance must be initialized or opened prior to call.
Supported API: true -
getResourceName
Get the resource name that best matched. Instance must be initialized or opened prior to call.
Supported API: true -
setLocale
Set the Locale object for this instance. Used to override locale set when instance was initialized or opened.
Supported API: true -
getLocalizedResourceName
Returns the Localized name of a Resource, with a specified Locale and a filename. This method supports localized backoff. The locale is 'backed off' to attempt a best guess. For example, given the locale of "en_US" and the resourceName of "resource.xxx", if resource_en_US.xxx is not found, it will attempt to find resource_en.xxx. If that in turn is not found, resource.xxx is looked for. If no best match is found, an attempt to find a best match on the server's locale is attempted. The locale will be determined from WTContext, which is set in an HTML file using the property "wt.context.locale".Replaces LocaleHelper.translateURLString( )
- Parameters:
aLocale- The locale to generate the file with.aFilename- The filename to generate the file around.- Returns:
- String The localized version of the String.
Supported API: true
-
getLocalizedResourceName
Returns the Localized name of a Resource, with a specified Locale and a filename. This method supports localized backoff. The locale is 'backed off' to attempt a best guess. For example, given the locale of "en_US" and the resourceName of "resource.xxx", if resource_en_US.xxx is not found, it will attempt to find resource_en.xxx. If that in turn is not found, resource.xxx is looked for. If no best match is found, an attempt to find a best match on the server's locale is attempted.Replaces LocaleHelper.translateURLString( )
- Parameters:
aLocale- The locale to generate the file with.aFilename- The filename to generate the file around.- Returns:
- String The localized version of the String.
Supported API: true
-
setDebug
public static void setDebug(boolean value) Sets the debug value which controls logging from this class.
Supported API: true -
init
Look for the given resource for the given locale. If the resource is not found, the locale is 'backed off' to attempt a best guess. For example, given the locale of "en_US" and the resourceName of "resource.xxx", if resource_en_US.xxx is not found, it will attempt to find resource_en.xxx. If that in turn is not found, resource.xxx is looked for. If no best match is found, an attempt to find a best match on the server's locale is attempted.
Supported API: true- Parameters:
locale- The locale to search on.- Throws:
WTException- Thrown if an IO exception occurs.
-
init
Look for the given resource for the server's locale. If the resource is not found, the locale is 'backed off' to attempt a best guess. For example, given the locale of "en_US" and the resourceName of "resource.xxx", if resource_en_US.xxx is not found, it will attempt to find resource_en.xxx. If that in turn is not found, resource.xxx is looked for.
Supported API: true- Throws:
WTException- Thrown if an IO exception occurs.
-
init
Look for the given resource for the given locales. If the resource is not found, the locale is 'backed off' to attempt a best guess. For example, given the locale of "en_US" and the resourceName of "resource.xxx", if resource_en_US.xxx is not found, it will attempt to find resource_en.xxx. If that in turn is not found, resource.xxx is looked for. If no best match is found, an attempt to find a best match on the server's locale is attempted.
Supported API: true- Parameters:
preferences- Vector containing the locales to search on.- Throws:
WTException- Thrown if an IO exception occurs.
-
getInputStream
Return input stream of best matching resource. Instance must be initialized or opened prior to call.
Supported API: true- Returns:
- BufferedInputStream.
- Throws:
WTException- Thrown if an IO exception occurs.
-
closeInputStream
protected void closeInputStream()Close input stream of this instance. Supported API: true -
openResource
Look for the given resource for the given locale. If the resource is not found, the locale is 'backed off' to attempt a best guess. For example, given the locale of "en_US" and the resourceName of "resource.xxx", if resource_en_US.xxx is not found, it will attempt to find resource_en.xxx. If that in turn is not found, resource.xxx is looked for. If no best match is found, an attempt to find a best match on the server's locale is attempted. If a best match is found, the returned input stream is already buffered for efficient reading.
Supported API: true- Parameters:
locale- The locale to search on.- Returns:
- InputStream.
- Throws:
WTException- Thrown if an IO exception occurs.
-
openResource
Look for the given resource for the server's locale. If the resource is not found, the locale is 'backed off' to attempt a best guess. For example, given the locale of "en_US" and the resourceName of "resource.xxx", if resource_en_US.xxx is not found, it will attempt to find resource_en.xxx. If that in turn is not found, resource.xxx is looked for. If a best match is found, load the resource into a BufferedInputStream.
Supported API: true- Returns:
- BufferedInputStream.
- Throws:
WTException- Thrown if an IO exception occurs.
-
openResource
Look for the given resource for the given locales. If the resource is not found, the locale is 'backed off' to attempt a best guess. For example, given the locale of "en_US" and the resourceName of "resource.xxx", if resource_en_US.xxx is not found, it will attempt to find resource_en.xxx. If that in turn is not found, resource.xxx is looked for. If no best match is found, an attempt to find a best match on the server's locale is attempted. If a best match is found, load the resource into a BufferedInputStream.
Supported API: true- Parameters:
preferences- Vector containing the locales to search on.- Returns:
- BufferedInputStream.
- Throws:
WTException- Thrown if an IO exception occurs.
-