Provides a number of utility functions:
Support for Beans, mapping from a Bean class to its HelpSet and to
its ID.
Support for finding localized resources.
Support for getting the default Query Engine
This class has no public constructor.
getCandidates
public static Enumeration getCandidates(Locale locale)
This returns an enumeration of String tails.
The core functionality on which getLocalizedResource is based.
The suffixes are based on (1) the desired locale and (2) the default locale
in the following order from lower-level (more specific) to parent-level
(less specific):
"_" + language1 + "_" + country1 + "_" + variant1
"_" + language1 + "_" + country1
"_" + language1
""
"_" + language2 + "_" + country2 + "_" + variant2
"_" + language2 + "_" + country2
"_" + language2
The enumeration is of StringBuffer.
We pay some attention to efficiency in case a method like this is promoted,
hence we cache per locale.
getDefaultQueryEngine
public static String getDefaultQueryEngine()
Default for the search engine
getHelpSetNameFromBean
public static String getHelpSetNameFromBean(Class beanClass)
Given the class for a bean, get its HelpSet.
Returns the helpSetName property of the BeanDescriptor if defined.
Otherwise it returns a name as follows:
If the class is in the unnamed package, it returns beanClassNameHelp.hs.
Otherwise if it's in the form package.ClassName it returns
package/Help.hs after replacing "." with "/" in package.
- A String with the name of the HelpSet
getIDStringFromBean
public static String getIDStringFromBean(Class beanClass)
Given the class for a bean, get its ID string.
Returns the helpID property of the BeanDescriptor if defined,
otherwise it returns beanName.topID.
- A String with the ID to use
getLocale
public static Locale getLocale(Component c)
Gets the locale of a component. If the component is null
it returns the defaultLocale. If the call to component.getLocale
returns an IllegalComponentStateException, the defaultLocale is
returned.
getLocalizedResource
public static URL getLocalizedResource(ClassLoader cl,
String front,
String back,
Locale locale)
Locate a resource relative to a given classloader CL.
The name of the resource is composed by using FRONT,
adding _LANG _COUNTRY _VARIANT (with the usual rules)
and ending with BACK, which will usually be an extension
like ".hs" for a HelpSet, or ".class" for a class
This method is a convenience method for getLocalizedResource() with
a tryRead parameter set to false.
This functionality should likely be exposed as part of JDK1.2
cl
- The ClassLoader to get the resource from. If cl is null the default
ClassLoader is used.
getLocalizedResource
public static URL getLocalizedResource(ClassLoader cl,
String front,
String back,
Locale locale,
boolean tryRead)
Locate a resource relative to a given classloader CL.
The name of the resource is composed by using FRONT,
adding _LANG _COUNTRY _VARIANT (with the usual rules)
and ending with BACK, which is usually an extension
like ".hs" for a HelpSet, or ".class" for a class
This version accepts an explicit argument to work around some browser bugs.
This functionality should likely be exposed as part of JDK1.2
cl
- The ClassLoader to get the resource from. If cl is null the default
ClassLoader is used.
getString
public static String getString(Locale l,
String key)
Versions with an explicit locale.
getString
public static String getString(String key)
Get the Text message for the default locale.
The getString version does not involve a format.
getStringArray
public static String[] getStringArray(Locale l,
String key)
getText
public static String getText(Locale l,
String key)
getText
public static String getText(Locale l,
String key,
String s1)
s1
- The first parameter of a string. A null is valid for s1.
getText
public static String getText(Locale l,
String key,
String s1,
String s2)
s1
- The first parameter of a string. A null is valid for s1.s2
- The first parameter of a string. A null is valid for s2.
getText
public static String getText(Locale l,
String key,
String s1,
String s2,
String s3)
s1
- The first parameter of a string. A null is valid for s1.s2
- The first parameter of a string. A null is valid for s2.s3
- The first parameter of a string. A null is valid for s3.
getText
public static String getText(String key)
getText
public static String getText(String key,
String s1)
s1
- The first parameter of a string. A null is valid for s1.
getText
public static String getText(String key,
String s1,
String s2)
s1
- The first parameter of a string. A null is valid for s1.s2
- The first parameter of a string. A null is valid for s2.
getText
public static String getText(String key,
String s1,
String s2,
String s3)
s1
- The first parameter of a string. A null is valid for s1.s2
- The first parameter of a string. A null is valid for s2.s3
- The first parameter of a string. A null is valid for s3.
isStringInString
public static boolean isStringInString(RuleBasedCollator rbc,
String source,
String target)
Returns information about whether a string is
contained in another string. Compares the character data stored in two
different strings based on the collation rules.
localeFromLang
public static Locale localeFromLang(String lang)
Convenient method for creating a locale from a lang string.
Takes the lang string in the form of "language_country_variant"
or "language-country-variant" and
parses the string and creates an appropriate locale.
lang
- A String representation of a locale, with the language,
country and variant separated by underbars. Language is always lower
case, and country is always upper case. If the language is missing the
String begins with an underbar. If both language and country fields are
missing, a null Locale is returned. If lang is null a null Locale is
returned