Class InternationalStringImpl

  • All Implemented Interfaces:
    Serializable, InternationalString

    public class InternationalStringImpl
    extends Object
    implements InternationalString, Serializable
    Implementation of JAXR InternationalString. "default locale" in comments below refers to the locale given by Locale.getDefault() at runtime. Class contains a java.util.HashMap that maps locales to LocalizedString instances. Unless specified for a given method, the behavior for null locales and values is the same as for null keys and objects in HashMap.
    Author:
    Bobby Bissett
    See Also:
    Serialized Form
    • Constructor Detail

      • InternationalStringImpl

        public InternationalStringImpl()
        Default constructor creates empty hash map for holding LocalizedStrings.
      • InternationalStringImpl

        public InternationalStringImpl​(LocalizedString lString)
                                throws JAXRException
        Utility constructor used with a given LocalizedString.
        Parameters:
        string - LocalizedString to store
        Throws:
        JAXRException
      • InternationalStringImpl

        public InternationalStringImpl​(Locale locale,
                                       String value)
        Utility constructor used with given locale and string.
        Parameters:
        locale -
        value - String value for given locale
      • InternationalStringImpl

        public InternationalStringImpl​(String value)
        Utility constructor used to set a string value for the default locale.
        Parameters:
        value - Store this value for the default locale
    • Method Detail

      • getValue

        public String getValue()
                        throws JAXRException
        Returns the string value for default locale
        Specified by:
        getValue in interface InternationalString
        Returns:
        the String value for the Locale returned by Locale.getDefault()
        Throws:
        JAXRException - If the JAXR provider encounters an internal error
      • getValue

        public String getValue​(Locale locale)
                        throws JAXRException
        Returns the string value for the given locale. If locale is null or there is no localized string for the given locale, the method will return null.
        Specified by:
        getValue in interface InternationalString
        Parameters:
        locale - The Locale for the desired value
        Returns:
        the String value for the specified Locale
        Throws:
        JAXRException - If the JAXR provider encounters an internal error
      • setValue

        public void setValue​(String string)
                      throws JAXRException
        Sets string value for default locale
        Specified by:
        setValue in interface InternationalString
        Parameters:
        string - the String value for the Locale returned by Locale.getDefault()
        Throws:
        JAXRException - If the JAXR provider encounters an internal error
      • setValue

        public void setValue​(Locale locale,
                             String string)
                      throws JAXRException
        Sets the string value for the specified locale
        Specified by:
        setValue in interface InternationalString
        Parameters:
        locale - The locale for this value being set
        string - The value being set
        Throws:
        JAXRException - If the JAXR provider encounters an internal error
      • addLocalizedString

        public void addLocalizedString​(LocalizedString localizedString)
                                throws JAXRException
        Adds given localized string to collection. LocalizedString parameter cannot be null.
        Specified by:
        addLocalizedString in interface InternationalString
        Parameters:
        localizedString - the LocalizedString being added to this object
        Throws:
        JAXRException - If the JAXR provider encounters an internal error
      • addLocalizedStrings

        public void addLocalizedStrings​(Collection strings)
                                 throws JAXRException
        Adds localized strings to the collection. If there are multiple localized strings for the same locale, it is unspecified which one will be set for this international string.
        Specified by:
        addLocalizedStrings in interface InternationalString
        Parameters:
        strings - the Collection of LocalizedStrings being added to this object
        Throws:
        JAXRException - If the JAXR provider encounters an internal error
      • removeLocalizedString

        public void removeLocalizedString​(LocalizedString lString)
                                   throws JAXRException
        Removes given localized string. If the localized string is not in this international string, nothing happens. Parameter localized string cannot be null.
        Specified by:
        removeLocalizedString in interface InternationalString
        Parameters:
        lString - the LocalizedString being removed from this object
        Throws:
        JAXRException - If the JAXR provider encounters an internal error
      • removeLocalizedStrings

        public void removeLocalizedStrings​(Collection lStrings)
                                    throws JAXRException
        Removes localized strings from the international string if they are present.
        Specified by:
        removeLocalizedStrings in interface InternationalString
        Parameters:
        lStrings - the Collection of LocalizedStrings being removed from this object
        Throws:
        JAXRException - If the JAXR provider encounters an internal error
      • getLocalizedString

        public LocalizedString getLocalizedString​(Locale locale,
                                                  String charsetName)
                                           throws JAXRException
        Gets the localized string for the given locale, if one exists.
        Specified by:
        getLocalizedString in interface InternationalString
        Parameters:
        locale - The loacle for the desired LocalizedStrings
        charsetName - The character set name for the desired LocalizedStrings
        Returns:
        the LocalizedString that matches specified locale and character set
        Throws:
        JAXRException - If the JAXR provider encounters an internal error
      • getLocalizedStrings

        public Collection getLocalizedStrings()
                                       throws JAXRException
        Get the localized strings contained in this international string. This method creates a new collection to return rather than the one that backs the hash map.
        Specified by:
        getLocalizedStrings in interface InternationalString
        Returns:
        Collection of LocalizedString instances. The Collection may be empty but not null.
        Throws:
        JAXRException - If the JAXR provider encounters an internal error
        See Also:
        LocalizedString