Class MemberInitialsManager

  • All Implemented Interfaces:
    JPropertiesListener

    public class MemberInitialsManager
    extends java.lang.Object
    implements JPropertiesListener
    Utility class to produce a Member photo using member's initials.
    Since:
    jcms-10.0.4 JCMS-6025
    Author:
    Sylvain Devaux
    • Field Detail

      • COLOR_PROP_SEPARATOR

        protected static final java.lang.String COLOR_PROP_SEPARATOR
        See Also:
        Constant Field Values
      • COLORS_PROP

        public static final java.lang.String COLORS_PROP
        List of custom hexadecimal color codes.
        See Also:
        Constant Field Values
      • colorCacheMap

        protected java.util.Map<java.lang.String,​java.lang.String> colorCacheMap
    • Method Detail

      • getInstance

        public static MemberInitialsManager getInstance()
        Get the manager.
        Returns:
        MemberInitialsManager the singleton instance
      • reloadProperties

        protected void reloadProperties()
      • propertiesChange

        public void propertiesChange​(JProperties arg0)
        Description copied from interface: JPropertiesListener
        Invoked after properties have been modified in JCMS and save on disk.

        You cannot alter the value received in parameters.

        Note that properties parameter may be null, a limited set of site properties, or all site properties.

        To check that a property has been modified, reload the "current" property instead using channel.getProperties or channel.getProperty.

        Specified by:
        propertiesChange in interface JPropertiesListener
        Parameters:
        arg0 - the properties which have been submitted to change
      • getInitials

        public java.lang.String getInitials​(java.lang.String firstName,
                                            java.lang.String name,
                                            java.util.Locale userLocale)
        Returns letters initials.
        Parameters:
        firstName - the firstname
        name - the name
        userLocale - the locale to use with String.toUpperCase(Locale)
        Returns:
        First letter of name + First letter of firstname if available
        Since:
        jcms-10.0.4 JCMS-6025
      • getInitials

        public java.lang.String getInitials​(Member member,
                                            java.util.Locale userLocale)
        Returns letters initials.
        Parameters:
        member - the member to compute its initials
        userLocale - the locale to use with String.toUpperCase(Locale)
        Returns:
        member's initials
        Since:
        jcms-10.0.4 JCMS-6025
      • getInitialsColor

        public java.lang.String getInitialsColor​(Member member)
        Returns an hexadecimal color code based on Member metaDatas.
        Parameters:
        member - the member to compute a color from
        Returns:
        a color hex hexadecimal code
        Since:
        jcms-10.0.4 JCMS-6025
      • getInitialsColorFromEmail

        public java.lang.String getInitialsColorFromEmail​(java.lang.String email)
        Parameters:
        email - the email to get a color.

        Extracts name and firstname from email.

        Returns:
        a color hex hexadecimal code
        Since:
        jcms-10.0.8
      • getInitialsFromEmail

        public java.lang.String getInitialsFromEmail​(java.lang.String email)
        Parameters:
        email - the email to get initials.

        Extracts name and firstname from email.

        Returns:
        a color hex hexadecimal code
        Since:
        jcms-10.0.8
      • resetInitialsColor

        public void resetInitialsColor​(Member member)
        Reset the cached color code based on Member metaDatas.
        Parameters:
        member - the member to reset its cached color
        Since:
        jcms-10.0.5
      • getAvailableColors

        protected java.util.List<java.lang.String> getAvailableColors()