com.ca.jcs.validator
Class ErrorMessages

java.lang.Object
  extended by com.ca.jcs.validator.ErrorMessages

public class ErrorMessages
extends Object

VirtualContainer for ErrorMessages relating to a single operation on the same object.


Field Summary
static ResourceBundle BUNDLE
           
 
Constructor Summary
ErrorMessages()
           
 
Method Summary
 void addMessage(ErrorMessage msg)
           
static ErrorMessages fromXML(String xml)
          Decodes object from xml (which resulted from a call to toXML() } using XMLDecoder and returns the resulting object.
 List<ErrorMessage> getMessages()
           
 String getObjectClass()
           
 String getObjectName()
           
 String getObjHeaderMsgFormatId()
           
 void merge(ErrorMessages msgs)
           
static ErrorMessages merge(ErrorMessages msgsA, ErrorMessages msgsB)
           
static ErrorMessages oneMessage(String msgFormatId, String value)
          Helper method that handles the most common case of creating a new ErrorMessages object and populating it with a single message.
static ErrorMessages oneMessage(String msgFormatId, String[] msgArgs)
          See oneMessage(String, String) for description.
static ErrorMessages oneMessage(String msgFormatId, String[] msgArgs, int[] resolvableArgIndexes)
          See oneMessage(String, String[]) for description, where this method allows you to specify that one or more of the provided msgArgs may need to resolved (looked up as keys in the resource bundle).
 void setAttributeIds(String attributeId)
           
 void setHeaderInfo(String headerMsgFormatId, String objectClass, String objectName, String attrFormatId)
           
 void setMessages(List<ErrorMessage> messages)
           
 void setObjectClass(String objectClass)
           
 void setObjectName(String objectName)
           
 void setObjHeaderMsgFormatId(String objHeaderMsgFormatId)
           
 String toResolvedString(org.springframework.context.MessageSource msgSrc)
          Calls toResolvedString(org.springframework.context.MessageSource, java.util.Locale) with null locale.
 String toResolvedString(org.springframework.context.MessageSource msgSrc, Locale locale)
          Resolve all contained messages using resource bundles referred to by msgSrc and provided locale, and return it.
 String toString()
           
 String toXML()
          Encode object using XMLEncoder and returns resulting text.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BUNDLE

public static ResourceBundle BUNDLE
Constructor Detail

ErrorMessages

public ErrorMessages()
Method Detail

getObjHeaderMsgFormatId

public String getObjHeaderMsgFormatId()

setObjHeaderMsgFormatId

public void setObjHeaderMsgFormatId(String objHeaderMsgFormatId)

getObjectClass

public String getObjectClass()

setObjectClass

public void setObjectClass(String objectClass)

getObjectName

public String getObjectName()

setObjectName

public void setObjectName(String objectName)

addMessage

public void addMessage(ErrorMessage msg)

setHeaderInfo

public void setHeaderInfo(String headerMsgFormatId,
                          String objectClass,
                          String objectName,
                          String attrFormatId)

setAttributeIds

public void setAttributeIds(String attributeId)

getMessages

public List<ErrorMessage> getMessages()
Returns:
List[ErrorMessage].

setMessages

public void setMessages(List<ErrorMessage> messages)

merge

public void merge(ErrorMessages msgs)

merge

public static ErrorMessages merge(ErrorMessages msgsA,
                                  ErrorMessages msgsB)

toXML

public String toXML()
Encode object using XMLEncoder and returns resulting text.


fromXML

public static ErrorMessages fromXML(String xml)
Decodes object from xml (which resulted from a call to toXML() } using XMLDecoder and returns the resulting object.


toResolvedString

public String toResolvedString(org.springframework.context.MessageSource msgSrc,
                               Locale locale)
                        throws org.springframework.context.NoSuchMessageException
Resolve all contained messages using resource bundles referred to by msgSrc and provided locale, and return it.

Parameters:
msgSrc - Spring MessageSource acting as container for one or more resource bundles (which are possibly hierarchically chained), against which this message's format id key will be resolved.
locale - Locale to be used for resolution; if null then Locale.getDefault() will be used.
Returns:
Resolved text.
Throws:
org.springframework.context.NoSuchMessageException - If this error message's format id key can't be resolved.

toResolvedString

public String toResolvedString(org.springframework.context.MessageSource msgSrc)
                        throws org.springframework.context.NoSuchMessageException
Calls toResolvedString(org.springframework.context.MessageSource, java.util.Locale) with null locale.

Throws:
org.springframework.context.NoSuchMessageException

toString

public String toString()
Overrides:
toString in class Object
Returns:
Simply calls toXML().

oneMessage

public static ErrorMessages oneMessage(String msgFormatId,
                                       String value)
Helper method that handles the most common case of creating a new ErrorMessages object and populating it with a single message.

Parameters:
msgFormatId - Id which can ultimately be used to look up a message format string in a resource bundle.
value - Value which caused an error.
Returns:
ErrorMessages object containing a single message.

oneMessage

public static ErrorMessages oneMessage(String msgFormatId,
                                       String[] msgArgs)
See oneMessage(String, String) for description.

Parameters:
msgFormatId - Id which can ultimately be used to look up a message format string in a resource bundle.
msgArgs - Arguments to message format, where first argument is always the value which caused the error.
Returns:
ErrorMessages object containing a single message.

oneMessage

public static ErrorMessages oneMessage(String msgFormatId,
                                       String[] msgArgs,
                                       int[] resolvableArgIndexes)
See oneMessage(String, String[]) for description, where this method allows you to specify that one or more of the provided msgArgs may need to resolved (looked up as keys in the resource bundle). Where such args do not resolve, their literal text will be used.

Parameters:
msgFormatId - Id which can ultimately be used to look up a message format string in a resource bundle.
msgArgs - Arguments to message format, where first argument is always the value which caused the error.
resolvableArgIndexes - Array containing indexes into msgArgs which should be the framework should attempt to resolve.
Returns:
ErrorMessages object containing a single message.


Created 2011-07-14 13:27 EST