Class StringToLocalizedStringConverter

  • All Implemented Interfaces:
    org.springframework.core.convert.converter.Converter<String,​LocalizedString>

    public class StringToLocalizedStringConverter
    extends Object
    implements org.springframework.core.convert.converter.Converter<String,​LocalizedString>
    Utility class for transforming strings into OpenSAML LocalizedStrings.

    The strings being converted MUST start with the language identifier followed by a hyphen. For example, the string "en-Hello" will be translated to the localized string "Hello" in English. If no language indicator is given, a LocalizedString with no language tag will be created.

    Author:
    Martin Lindström (martin.lindstrom@litsec.se)
    • Constructor Detail

      • StringToLocalizedStringConverter

        public StringToLocalizedStringConverter()
    • Method Detail

      • convert

        public LocalizedString convert​(String source)
        Converts strings on the format <lang-tag>-<string according to language>. The string "en-Hello" will give a LocalizedString where:
        
         ls.getLanguage() => "en"
         ls.getLocalString() => "Hello"
         
        Specified by:
        convert in interface org.springframework.core.convert.converter.Converter<String,​LocalizedString>