Package javax.help

# Class HelpUtilities

java.lang.Object
javax.help.HelpUtilities

public class HelpUtilities extends Object
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.

## Constructor Summary

Constructors
Constructor
Description
`HelpUtilities()`

## Method Summary

Modifier and Type
Method
Description
`static Enumeration`
`getCandidates(Locale locale)`
This returns an enumeration of String tails.
`static String`
`getDefaultQueryEngine()`
Default for the search engine
`static String`
`getHelpSetNameFromBean(Class beanClass)`
Given the class for a bean, get its HelpSet.
`static String`
`getIDStringFromBean(Class beanClass)`
Given the class for a bean, get its ID string.
`static Locale`
`getLocale(Component c)`
Gets the locale of a component.
`static URL`
`getLocalizedResource(ClassLoader cl, String front, String back, Locale locale)`
Locate a resource relative to a given classloader CL.
`static URL`
`getLocalizedResource(ClassLoader cl, String front, String back, Locale locale, boolean tryRead)`
Locate a resource relative to a given classloader CL.
`static String`
`getString(String key)`
Get the Text message for the default locale.
`static String`
`getString(Locale l, String key)`
Versions with an explicit locale.
`static String[]`
`getStringArray(Locale l, String key)`
`static String`
`getText(String key)`
`static String`
`getText(String key, String s1)`
`static String`
`getText(String key, String s1, String s2)`
`static String`
`getText(String key, String s1, String s2, String s3)`
`static String`
`getText(Locale l, String key)`
`static String`
`getText(Locale l, String key, String s1)`
`static String`
`getText(Locale l, String key, String s1, String s2)`
`static String`
`getText(Locale l, String key, String s1, String s2, String s3)`
`static boolean`
`isStringInString(RuleBasedCollator rbc, String source, String target)`
Returns information about whether a string is contained in another string.
`static Locale`
`localeFromLang(String lang)`
Convenient method for creating a locale from a `lang` string.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### HelpUtilities

public HelpUtilities()

## Method Details

### 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.

Parameters:
  `beanClass` - The Class
Returns:
  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.

Parameters:
  `beanClass` - the Class
Returns:
  A String with the ID to use

### getDefaultQueryEngine

public static String getDefaultQueryEngine()
Default for the search engine

### 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

Parameters:
  `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

Parameters:
  `cl` - The ClassLoader to get the resource from. If cl is null the default ClassLoader is used.

### 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.

### 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.

### getString

public static String getString(String key)
Get the Text message for the default locale. The getString version does not involve a format.

### getText

public static String getText(String key)

### getText

public static String getText(String key, String s1)

Parameters:
  `s1` - The first parameter of a string. A null is valid for s1.

### getText

public static String getText(String key, String s1, String s2)

Parameters:
  `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)

Parameters:
  `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.

### getString

public static String getString(Locale l, String key)
Versions with an explicit locale.

### getStringArray

public static String[] getStringArray(Locale l, String key)

### getText

public static String getText(Locale l, String key)

Parameters:
  `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(Locale l, String key, String s1)

Parameters:
  `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)

Parameters:
  `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)

Parameters:
  `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.

### 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.

Parameters:
  `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

### 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.