Class ResourceBundleMessageFactory
- java.lang.Object
-
- org.beanio.internal.parser.message.ResourceBundleMessageFactory
-
- All Implemented Interfaces:
MessageFactory
public class ResourceBundleMessageFactory extends java.lang.Object implements MessageFactory
- Since:
- 2.0
-
-
Constructor Summary
Constructors Constructor Description ResourceBundleMessageFactory()
-
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.
-
-
-
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 interfaceMessageFactory
- 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 interfaceMessageFactory
- Parameters:
recordName
- the name of the record the field belongs tofieldName
- 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 interfaceMessageFactory
- Parameters:
recordName
- the name of the recordfieldName
- the name of the fieldrule
- 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 interfaceMessageFactory
- Parameters:
recordName
- the name of the recordrule
- 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
-
-