FileDocCategorySizeDatePackage
CollationAbstractionLayer.javaAPI DocphoneME MR2 API (J2ME)6858Wed May 02 18:00:46 BST 2007com.sun.j2me.global

CollationAbstractionLayer

public abstract class CollationAbstractionLayer extends Object
The CollationAbstractionLayer class provides a layer of abstraction for {@link javax.microedition.global.StringComparator} realization. Sub-classes of CollationAbstractionLayer correspond to individual implementations of string comparison.

Fields Summary
private static final String
ABSTRACTION_LAYER_PROPERTY
Constant name of collation abstraction layer class property.
private static final String
DEFAULT_ABSTRACTION_LAYER
Constant name of default collation abstraction layer class.
private static CollationAbstractionLayer
abstractionLayer
An instance of CollationAbstractionLayer, which is used in the {@link #getInstance() getInstance} method.
Constructors Summary
Methods Summary
public static com.sun.j2me.global.CollationAbstractionLayergetInstance()
Returns an instance CollationAbstractionLayer. This instance is created only once (singleton) and then it is reused when the method is called again.

return
the instance of the AbstractionLayer sub-class, null if unable to get sub-class instance



                                                           
        
        if (abstractionLayer == null) {
            String alClsName =
                    Configuration.getProperty(ABSTRACTION_LAYER_PROPERTY);
            if (alClsName != null) {
                try {
                    abstractionLayer = (CollationAbstractionLayer)
                            Class.forName(alClsName).newInstance();
                } catch (ClassNotFoundException cnf_ignore) {
                    /* intentionally ignored */
                    if (Logging.REPORT_LEVEL <= Logging.WARNING) {
                        Logging.report(Logging.WARNING, LogChannels.LC_JSR238,
                            "default Collation handler class does not exist:"
                            + alClsName);
                    }
                } catch (InstantiationException ie_ignore) {
                    /* intentionally ignored */
                    if (Logging.REPORT_LEVEL <= Logging.WARNING) {
                        Logging.report(Logging.WARNING, LogChannels.LC_JSR238,
                            "default Collation handler class missing constructor:"
                            + alClsName);
                    }
                } catch (IllegalAccessException iae_ignore) {
                    /* intentionally ignored */
                    if (Logging.REPORT_LEVEL <= Logging.WARNING) {
                        Logging.report(Logging.WARNING, LogChannels.LC_JSR238,
                            "default Collation handler class incorrect type:"
                            + alClsName);
                    }
                }
            }
            if (abstractionLayer == null) {
                // try default abstraction layer
                try {
                    abstractionLayer = (CollationAbstractionLayer)Class.forName(
                            DEFAULT_ABSTRACTION_LAYER).newInstance();
                } catch (ClassNotFoundException cnf_ignore) {
                    /* intentionally ignored */
                    if (Logging.REPORT_LEVEL <= Logging.WARNING) {
                        Logging.report(Logging.WARNING, LogChannels.LC_JSR238,
                            "Default Collation handler class does not exist:"
                            + DEFAULT_ABSTRACTION_LAYER);
                    }
                } catch (InstantiationException ie_ignore) {
                    /* intentionally ignored */
                    if (Logging.REPORT_LEVEL <= Logging.WARNING) {
                        Logging.report(Logging.WARNING, LogChannels.LC_JSR238,
                            "Collation handler class missing constructor:"
                            + DEFAULT_ABSTRACTION_LAYER);
                    }
                } catch (IllegalAccessException iae_ignore) {
                    /* intentionally ignored */
                    if (Logging.REPORT_LEVEL <= Logging.WARNING) {
                        Logging.report(Logging.WARNING, LogChannels.LC_JSR238,
                            "Collation handler class incorrect type:"
                            + DEFAULT_ABSTRACTION_LAYER);
                    }
                }
            }
        }

        return abstractionLayer;
    
public abstract CommonStringComparatorgetStringComparator(java.lang.String locale, int level)
Returns an instance of the StringComparator sub-class, which realizes platform-specific StringComparator methods.

param
locale the locale to use with this StringComparator
param
level level of collation, as defined in {@link javax.microedition.global.StringComparator}
return
the instance of the StringComparator realization
see
CommonStringComparator

public abstract java.lang.String[]getSupportedLocales()
Gets the locales for which a StringComparator is available in individual implementation. If no locales are supported, the returned array must be empty, not null. As the value null is not technically a valid locale, but a special value to trigger the generic collation algorithm, it must not appear in the array.

return
an array of valid microedition.locale values