org.opencms.main
Class CmsMultiException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by org.opencms.main.CmsException
              extended by org.opencms.main.CmsMultiException
All Implemented Interfaces:
java.io.Serializable, I_CmsThrowable

public class CmsMultiException
extends CmsException

A multi exception is a container for several exception messages that may be caused by an internal operation.

This is provided so that the user can see a full picuture of all the issues that have been caused in an operation, rather then only one (usually the first) issue.

Since:
2.0.0
Version:
$Revision: 1.8 $
Author:
Alexander Kandzior
See Also:
Serialized Form

Field Summary
protected  java.util.List m_exceptions
          The list of internal exceptions.
protected  boolean m_individualMessage
          Indicates if the message has been set as individual message.
 
Fields inherited from class org.opencms.main.CmsException
m_message
 
Constructor Summary
CmsMultiException()
          Creates a new multi exception, a container for several exception messages.
CmsMultiException(CmsMessageContainer message)
          Creates a new multi exception using the given base message.
CmsMultiException(java.util.List exceptions)
          Creates a new multi exception for the given list of CmsException instances.
 
Method Summary
 void addException(CmsException exception)
          Adds an Exception to the list of Exceptions kept in this multi Exception.
 void addExceptions(java.util.List exceptions)
          Adds all Exceptions in the given List to the list of Exceptions kept in this multi Exception.
 CmsException createException(CmsMessageContainer container, java.lang.Throwable cause)
          Creates a copied instance of this localized exception.
 java.util.List getExceptions()
          Returns the (unmodifiable) List of exceptions that are tored in this multi exception.
 java.lang.String getLocalizedMessage()
          Returns a localized message composed of all contained exceptions.
 java.lang.String getLocalizedMessage(java.util.Locale locale)
          Returns a localized message for the given locale composed of all contained exceptions.
 java.lang.String getMessage(java.util.Locale locale)
          Returns the individual message (if set) or an empty String.
 boolean hasExceptions()
          Returns true if this multi exceptions contains at last one individual Exception.
 boolean hasIndividualMessage()
          Returns true if this multi message has an individual base message set.
protected  void setExceptions(java.util.List exceptions)
          Updates the internal list of stored exceptions.
 void setMessage(CmsMessageContainer message)
          Sets an individual message for the multi exception base message.
protected  void updateMessage()
          Updates the intenal message for the Exception.
 
Methods inherited from class org.opencms.main.CmsException
getFormattedErrorstack, getMessage, getMessageContainer, getStackTraceAsString
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_exceptions

protected java.util.List m_exceptions
The list of internal exceptions.


m_individualMessage

protected boolean m_individualMessage
Indicates if the message has been set as individual message.

Constructor Detail

CmsMultiException

public CmsMultiException()
Creates a new multi exception, a container for several exception messages.


CmsMultiException

public CmsMultiException(CmsMessageContainer message)
Creates a new multi exception using the given base message.

Parameters:
message - the basic message to use

CmsMultiException

public CmsMultiException(java.util.List exceptions)
Creates a new multi exception for the given list of CmsException instances.

Parameters:
exceptions - a list of CmsException instances
Method Detail

addException

public void addException(CmsException exception)
Adds an Exception to the list of Exceptions kept in this multi Exception.

Parameters:
exception - the Exception to add

addExceptions

public void addExceptions(java.util.List exceptions)
Adds all Exceptions in the given List to the list of Exceptions kept in this multi Exception.

Parameters:
exceptions - the Exceptions to add

createException

public CmsException createException(CmsMessageContainer container,
                                    java.lang.Throwable cause)
Description copied from class: CmsException
Creates a copied instance of this localized exception.

Overrides:
createException in class CmsException
Parameters:
container - the message container
cause - the root cause
Returns:
a copied instance of this localized exception
See Also:
CmsException.createException(org.opencms.i18n.CmsMessageContainer, java.lang.Throwable)

getExceptions

public java.util.List getExceptions()
Returns the (unmodifiable) List of exceptions that are tored in this multi exception.

Returns:
the (unmodifiable) List of exceptions that are tored in this multi exception

getLocalizedMessage

public java.lang.String getLocalizedMessage()
Returns a localized message composed of all contained exceptions.

Specified by:
getLocalizedMessage in interface I_CmsThrowable
Overrides:
getLocalizedMessage in class CmsException
Returns:
a localized exception message based on the OpenCms default locale
See Also:
Throwable.getLocalizedMessage()

getLocalizedMessage

public java.lang.String getLocalizedMessage(java.util.Locale locale)
Returns a localized message for the given locale composed of all contained exceptions.

Specified by:
getLocalizedMessage in interface I_CmsThrowable
Overrides:
getLocalizedMessage in class CmsException
Parameters:
locale - the Locale to get the message for
Returns:
a localized exception message based on the given Locale
See Also:
I_CmsThrowable.getLocalizedMessage(java.util.Locale)

getMessage

public java.lang.String getMessage(java.util.Locale locale)
Returns the individual message (if set) or an empty String.

Parameters:
locale - the locale for the message to generate
Returns:
the individual message (if set) or an empty String

hasExceptions

public boolean hasExceptions()
Returns true if this multi exceptions contains at last one individual Exception.

Returns:
true if this multi exceptions contains at last one individual Exception

hasIndividualMessage

public boolean hasIndividualMessage()
Returns true if this multi message has an individual base message set.

Returns:
true if this multi message has an individual base message set
See Also:
setMessage(CmsMessageContainer)

setMessage

public void setMessage(CmsMessageContainer message)
Sets an individual message for the multi exception base message.

If no individual message has been set, a default message using the key Messages.ERR_MULTI_EXCEPTION_1 will be used.

If null is given as parameter, any individual message that has been set is reset to the default message.

Parameters:
message - the message to set

setExceptions

protected void setExceptions(java.util.List exceptions)
Updates the internal list of stored exceptions.

Parameters:
exceptions - the exceptions to use (will replace the current exception list)

updateMessage

protected void updateMessage()
Updates the intenal message for the Exception.