Class LocaleStringConverter

  • All Implemented Interfaces:
    Serializable, ColumnLengthDefiningTypeConverter, TypeConverter<Locale,​String>

    public class LocaleStringConverter
    extends Object
    implements TypeConverter<Locale,​String>, ColumnLengthDefiningTypeConverter
    Class to handle the conversion between java.util.Locale and a String form. Locale should be stored in columns from 2 to 20 characters. Normally, we will have a string no longer than 5 characters, but variants, in general, are vendor specific and can be longer than expected. The Variant codes are vendor and browser-specific. For example, use WIN for Windows, MAC for Macintosh, and POSIX for POSIX. Where there are two variants, separate them with an underscore, and put the most important one first. For example, a Traditional Spanish collation might construct a locale with parameters for language, country and variant as: "es", "ES", "Traditional_WIN". language_country_variant Examples: "en", "de_DE", "_GB", "en_US_WIN", "de__POSIX", "fr_MAC"
    See Also:
    Locale, Serialized Form
    • Constructor Detail

      • LocaleStringConverter

        public LocaleStringConverter()
    • Method Detail

      • toMemberType

        public Locale toMemberType​(String str)
        Description copied from interface: TypeConverter
        Method to convert the passed datastore value to the member type.
        Specified by:
        toMemberType in interface TypeConverter<Locale,​String>
        str - Value from the datastore
        Value for the member
      • toDatastoreType

        public String toDatastoreType​(Locale loc)
        Description copied from interface: TypeConverter
        Method to convert the passed member value to the datastore type.
        Specified by:
        toDatastoreType in interface TypeConverter<Locale,​String>
        loc - Value from the member
        Value for the datastore
      • getDefaultColumnLength

        public int getDefaultColumnLength​(int columnPosition)
        Description copied from interface: ColumnLengthDefiningTypeConverter
        Accessor for the default column length to use for the datastore column at the specified position.
        Specified by:
        getDefaultColumnLength in interface ColumnLengthDefiningTypeConverter
        columnPosition - Position of the column being enquired about (0 = first)
        The column length (-1 if no preference)
      • getLocaleFromString

        public static Locale getLocaleFromString​(String localeString)
        Convert a string based locale into a Locale Object. Assumes the string has form "{language}_{country}_{variant}" (same as the output from Locale.toString()). Examples: "en", "de_DE", "_GB", "en_US_WIN", "de__POSIX", "fr_MAC"
        localeString - The String
        the Locale