Package javax.help

Class HelpUtilities


  • public class HelpUtilities
    extends java.lang.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

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Enumeration getCandidates​(java.util.Locale locale)
      This returns an enumeration of String tails.
      static java.lang.String getDefaultQueryEngine()
      Default for the search engine
      static java.lang.String getHelpSetNameFromBean​(java.lang.Class beanClass)
      Given the class for a bean, get its HelpSet.
      static java.lang.String getIDStringFromBean​(java.lang.Class beanClass)
      Given the class for a bean, get its ID string.
      static java.util.Locale getLocale​(java.awt.Component c)
      Gets the locale of a component.
      static java.net.URL getLocalizedResource​(java.lang.ClassLoader cl, java.lang.String front, java.lang.String back, java.util.Locale locale)
      Locate a resource relative to a given classloader CL.
      static java.net.URL getLocalizedResource​(java.lang.ClassLoader cl, java.lang.String front, java.lang.String back, java.util.Locale locale, boolean tryRead)
      Locate a resource relative to a given classloader CL.
      static java.lang.String getString​(java.lang.String key)
      Get the Text message for the default locale.
      static java.lang.String getString​(java.util.Locale l, java.lang.String key)
      Versions with an explicit locale.
      static java.lang.String[] getStringArray​(java.util.Locale l, java.lang.String key)  
      static java.lang.String getText​(java.lang.String key)  
      static java.lang.String getText​(java.lang.String key, java.lang.String s1)  
      static java.lang.String getText​(java.lang.String key, java.lang.String s1, java.lang.String s2)  
      static java.lang.String getText​(java.lang.String key, java.lang.String s1, java.lang.String s2, java.lang.String s3)  
      static java.lang.String getText​(java.util.Locale l, java.lang.String key)  
      static java.lang.String getText​(java.util.Locale l, java.lang.String key, java.lang.String s1)  
      static java.lang.String getText​(java.util.Locale l, java.lang.String key, java.lang.String s1, java.lang.String s2)  
      static java.lang.String getText​(java.util.Locale l, java.lang.String key, java.lang.String s1, java.lang.String s2, java.lang.String s3)  
      static boolean isStringInString​(java.text.RuleBasedCollator rbc, java.lang.String source, java.lang.String target)
      Returns information about whether a string is contained in another string.
      static java.util.Locale localeFromLang​(java.lang.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 Detail

      • HelpUtilities

        public HelpUtilities()
    • Method Detail

      • getHelpSetNameFromBean

        public static java.lang.String getHelpSetNameFromBean​(java.lang.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 java.lang.String getIDStringFromBean​(java.lang.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 java.lang.String getDefaultQueryEngine()
        Default for the search engine
      • getLocalizedResource

        public static java.net.URL getLocalizedResource​(java.lang.ClassLoader cl,
                                                        java.lang.String front,
                                                        java.lang.String back,
                                                        java.util.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 java.net.URL getLocalizedResource​(java.lang.ClassLoader cl,
                                                        java.lang.String front,
                                                        java.lang.String back,
                                                        java.util.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 java.util.Enumeration getCandidates​(java.util.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 java.util.Locale getLocale​(java.awt.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 java.lang.String getString​(java.lang.String key)
        Get the Text message for the default locale. The getString version does not involve a format.
      • getText

        public static java.lang.String getText​(java.lang.String key)
      • getText

        public static java.lang.String getText​(java.lang.String key,
                                               java.lang.String s1)
        Parameters:
        s1 - The first parameter of a string. A null is valid for s1.
      • getText

        public static java.lang.String getText​(java.lang.String key,
                                               java.lang.String s1,
                                               java.lang.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 java.lang.String getText​(java.lang.String key,
                                               java.lang.String s1,
                                               java.lang.String s2,
                                               java.lang.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 java.lang.String getString​(java.util.Locale l,
                                                 java.lang.String key)
        Versions with an explicit locale.
      • getStringArray

        public static java.lang.String[] getStringArray​(java.util.Locale l,
                                                        java.lang.String key)
      • getText

        public static java.lang.String getText​(java.util.Locale l,
                                               java.lang.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 java.lang.String getText​(java.util.Locale l,
                                               java.lang.String key,
                                               java.lang.String s1)
        Parameters:
        s1 - The first parameter of a string. A null is valid for s1.
      • getText

        public static java.lang.String getText​(java.util.Locale l,
                                               java.lang.String key,
                                               java.lang.String s1,
                                               java.lang.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 java.lang.String getText​(java.util.Locale l,
                                               java.lang.String key,
                                               java.lang.String s1,
                                               java.lang.String s2,
                                               java.lang.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 java.util.Locale localeFromLang​(java.lang.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​(java.text.RuleBasedCollator rbc,
                                               java.lang.String source,
                                               java.lang.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.