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

FormatAbstractionLayer

public abstract class FormatAbstractionLayer extends Object
The FormatAbstractionLayer class provides a layer of abstraction for {@link javax.microedition.global.Formatter} realization. Sub-classes of FormatAbstractionLayer correspond to individual implementations of data formatting.

Fields Summary
private static final String
ABSTRACTION_LAYER_PROPERTY
Constant name of formatting abstraction layer class property.
private static final String
DEFAULT_ABSTRACTION_LAYER
Constant name of default formatting abstraction layer class.
private static FormatAbstractionLayer
abstractionLayer
An instance of FormatAbstractionLayer, which is used in the {@link #getInstance} method.
private static CommonFormatter
neutralFormatter
An instance of NeutralFormatterImpl, which is used in the {@link #getNeutralFormatter} method.
Constructors Summary
Methods Summary
public abstract CommonFormattergetFormatter(java.lang.String locale)
Returns an instance of the Formatter sub-class, which realizes platform-specific Formatter methods.

param
locale the locale to use with this Formatter
return
the instance of the Formatter sub-class
see
javax.microedition.global.Formatter

public static com.sun.j2me.global.FormatAbstractionLayergetInstance()
Returns an instance FormatAbstractionLayer. 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 = (FormatAbstractionLayer)
                            Class.forName(alClsName).newInstance();
                } catch (ClassNotFoundException cnf_ignore) {
                    /* intentionally ignored */
                    Logging.report(Logging.WARNING, LogChannels.LC_JSR238,
                        "Formatter handler class does not exist or renamed: " + alClsName);
                } catch (InstantiationException ie_ignore) {
                    /* intentionally ignored */
                    Logging.report(Logging.WARNING, LogChannels.LC_JSR238,
                        "Formatter handler class missing constructor: "
                        + alClsName);
                } catch (IllegalAccessException iae_ignore) {
                    /* intentionally ignored */
                    Logging.report(Logging.WARNING, LogChannels.LC_JSR238,
                        "Formatter handler class incorrect type: "
                        + alClsName);
                }
            }
            if (abstractionLayer == null) {
                // try default abstraction layer
                try {
                    abstractionLayer = (FormatAbstractionLayer)Class.forName(
                            DEFAULT_ABSTRACTION_LAYER).newInstance();
                } catch (ClassNotFoundException cnf_ignore) {
                    /* intentionally ignored */
                    Logging.report(Logging.WARNING, LogChannels.LC_JSR238,
                        "Default Formatter handler class does not exist or renamed: "
                        + DEFAULT_ABSTRACTION_LAYER);
                } catch (InstantiationException ie_ignore) {
                    /* intentionally ignored */
                    Logging.report(Logging.WARNING, LogChannels.LC_JSR238,
                        "Formatter handler class missing constructor: "
                        + DEFAULT_ABSTRACTION_LAYER);
                } catch (IllegalAccessException iae_ignore) {
                    /* intentionally ignored */
                    Logging.report(Logging.WARNING, LogChannels.LC_JSR238,
                        "Formatter handler class incorrect type: "
                        + DEFAULT_ABSTRACTION_LAYER);
                }
            }
        }

        return abstractionLayer;
    
public static CommonFormattergetNeutralFormatter()
Returns an instance NeutralFormatterImpl. This instance is created only once (singleton) and then it is reused when the method is called again.

return
the instance of the NeutralFormatterImpl class

        if (neutralFormatter == null) {
            neutralFormatter = new NeutralFormatterImpl();
        }
        return neutralFormatter;
    
public abstract java.lang.String[]getSupportedLocales()
Gets the list of the locales supported by the formatter, as an array of valid microedition.locale values.

If no locales are supported, the list MUST be empty. It MUST NOT be null. As the value null is not technically a valid locale, but a special value to trigger locale-neutral formatting, it MUST NOT appear in the array.

return
an array of strings containing the locale values