Class ResourceBundleMessageFactory

  • All Implemented Interfaces:
    MessageFactory

    public class ResourceBundleMessageFactory
    extends java.lang.Object
    implements MessageFactory
    Since:
    2.0
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getFieldErrorMessage​(java.lang.String recordName, java.lang.String fieldName, java.lang.String rule)
      Returns a field level error message.
      java.lang.String getFieldLabel​(java.lang.String recordName, java.lang.String fieldName)
      Returns the localized label for a field.
      protected java.lang.String getLabel​(java.lang.String key)
      Returns a label from the configured resource bundle.
      java.lang.String getRecordErrorMessage​(java.lang.String recordName, java.lang.String rule)
      Returns a record level error message.
      java.lang.String getRecordLabel​(java.lang.String recordName)
      Returns the localized label for a record.
      void setDefaultResourceBundle​(java.util.ResourceBundle defaultResourceBundle)
      Sets the default resource bundle to check of messages not found in the primary resource bundle.
      void setResourceBundle​(java.util.ResourceBundle resourceBundle)
      Sets the primary resource bundle to check for messages.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ResourceBundleMessageFactory

        public ResourceBundleMessageFactory()
    • Method Detail

      • getRecordLabel

        public java.lang.String getRecordLabel​(java.lang.String recordName)
        Description copied from interface: MessageFactory
        Returns the localized label for a record.
        Specified by:
        getRecordLabel in interface MessageFactory
        Parameters:
        recordName - the name of the record
        Returns:
        the record label, or null if no label was found
      • getFieldLabel

        public java.lang.String getFieldLabel​(java.lang.String recordName,
                                              java.lang.String fieldName)
        Description copied from interface: MessageFactory
        Returns the localized label for a field.
        Specified by:
        getFieldLabel in interface MessageFactory
        Parameters:
        recordName - the name of the record the field belongs to
        fieldName - the name of the field
        Returns:
        the field label, or null if no label was found
      • getLabel

        protected java.lang.String getLabel​(java.lang.String key)
        Returns a label from the configured resource bundle.
        Parameters:
        key - the resource bundle key
        Returns:
        the label, or null if not found
      • getFieldErrorMessage

        public java.lang.String getFieldErrorMessage​(java.lang.String recordName,
                                                     java.lang.String fieldName,
                                                     java.lang.String rule)
        Description copied from interface: MessageFactory
        Returns a field level error message.
        Specified by:
        getFieldErrorMessage in interface MessageFactory
        Parameters:
        recordName - the name of the record
        fieldName - the name of the field
        rule - the name of the validation rule
        Returns:
        the error message, or null if no message was configured
      • getRecordErrorMessage

        public java.lang.String getRecordErrorMessage​(java.lang.String recordName,
                                                      java.lang.String rule)
        Description copied from interface: MessageFactory
        Returns a record level error message.
        Specified by:
        getRecordErrorMessage in interface MessageFactory
        Parameters:
        recordName - the name of the record
        rule - the name of the validation rule
        Returns:
        the error message, or null if no message was configured
      • setResourceBundle

        public void setResourceBundle​(java.util.ResourceBundle resourceBundle)
        Sets the primary resource bundle to check for messages.
        Parameters:
        resourceBundle - the resource bundle
      • setDefaultResourceBundle

        public void setDefaultResourceBundle​(java.util.ResourceBundle defaultResourceBundle)
        Sets the default resource bundle to check of messages not found in the primary resource bundle.
        Parameters:
        defaultResourceBundle - the default resource bundle