com.ca.jcs.validator
Class ErrorMessage

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

public class ErrorMessage
extends Object

Representation of a validation failure, which can either be passed around in abstract string form (separate components) or converted to an concrete error message given a ResourceBundle.


Constructor Summary
ErrorMessage()
           
ErrorMessage(String msgFormatId)
           
ErrorMessage(String msgFormatId, String value)
           
ErrorMessage(String msgFormatId, String[] msgArgs)
           
ErrorMessage(String msgFormatId, String[] msgArgs, int[] msgResolvableIndexes)
          Create an error message storing the provided arguments.
 
Method Summary
static ErrorMessage fromXML(String xml)
           
 String getAttrHeaderMsgFormatId()
           
 String getAttributeId()
           
 String[] getMsgArgs()
           
 String getMsgFormatId()
           
 void setAttrHeaderMsgFormatId(String attrFmtId)
           
 void setAttributeId(String attributeId)
           
 void setMsgArgs(String[] msgArgs)
           
 void setMsgFormatId(String msgFormatId)
           
 String toResolvedString(org.springframework.context.MessageSource msgSrc)
          Resolve message using resource bundles referred to by msgSrc and default locale, and return it.
 String toResolvedString(org.springframework.context.MessageSource msgSrc, Locale locale)
          Resolve this message using resource bundles referred to by msgSrc and provided locale, and return it.
 void toResolvedString(org.springframework.context.MessageSource msgSrc, StringBuilder sb, Locale locale)
          Resolve this message using resource bundles referred to by msgSrc and provided locale, and put results into sb.
 String toString()
           
 String toXML()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ErrorMessage

public ErrorMessage()

ErrorMessage

public ErrorMessage(String msgFormatId)

ErrorMessage

public ErrorMessage(String msgFormatId,
                    String value)

ErrorMessage

public ErrorMessage(String msgFormatId,
                    String[] msgArgs)

ErrorMessage

public ErrorMessage(String msgFormatId,
                    String[] msgArgs,
                    int[] msgResolvableIndexes)
Create an error message storing the provided arguments.

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.
msgResolvableIndexes - Array containing indexes into msgArgs which should be the framework should attempt to resolve.
Method Detail

getAttributeId

public String getAttributeId()

setAttributeId

public void setAttributeId(String attributeId)

getAttrHeaderMsgFormatId

public String getAttrHeaderMsgFormatId()
Returns:
Message format id for attribute header, eventually resolved against a resource bundle

setAttrHeaderMsgFormatId

public void setAttrHeaderMsgFormatId(String attrFmtId)

getMsgArgs

public String[] getMsgArgs()

setMsgArgs

public void setMsgArgs(String[] msgArgs)

getMsgFormatId

public String getMsgFormatId()

setMsgFormatId

public void setMsgFormatId(String msgFormatId)

toXML

public String toXML()

fromXML

public static ErrorMessage fromXML(String xml)

toString

public String toString()
Overrides:
toString in class Object

toResolvedString

public void toResolvedString(org.springframework.context.MessageSource msgSrc,
                             StringBuilder sb,
                             Locale locale)
                      throws org.springframework.context.NoSuchMessageException
Resolve this message using resource bundles referred to by msgSrc and provided locale, and put results into sb.

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.
sb - Resolved text is appended to it.
locale - Locale to be used for resolution; if null then Locale.getDefault() will be used.
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,
                               Locale locale)
Resolve this message 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)
Resolve message using resource bundles referred to by msgSrc and default 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.
Returns:
Resolved text.
Throws:
org.springframework.context.NoSuchMessageException - If this error message's format id key can't be resolved.


Created 2011-07-14 13:27 EST