org.gvsig.tools.exception
Class BaseRuntimeException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.lang.RuntimeException
              extended by org.gvsig.tools.exception.BaseRuntimeException
All Implemented Interfaces:
Serializable, IBaseException
Direct Known Subclasses:
DynClassImportHelper.ImportDynClassesException, DynObjectRuntimeException, LibraryException, LocatorException, NotYetImplemented, PersistenceRuntimeException

public abstract class BaseRuntimeException
extends RuntimeException
implements IBaseException

Esta clase esta pensada para actuar como clase base para las excepciones que se lanzan dentro del proyecto de gvSIG. AƱade la implementacion necesaria para disponer de mensajes de error internacionalizables, a traves del metodo getLocalizedMessage, asi como una serie de metodos que nos permiten obtener los mesanes de error de la cadena de excepciones enlazadas a traves de su "causa", asi como utilidades que permitan recorrer de forma comoda esta cadena de excepciones por medio de un Iterador. TODO: extract common code with the BaseException class to a common helper

Author:
Equipo de desarrollo de gvSIG.
See Also:
Serialized Form

Field Summary
protected  long code
          Unique code of error.
protected  String formatString
          TODO: remove the variable, use the Exception get/setMessage() instead.
protected  String messageKey
           
 
Constructor Summary
BaseRuntimeException(BaseException exception)
           
BaseRuntimeException(String message, String key, long code)
          Constructs a BaseException with a default message format, a key to find a localized message format, and a unique code to identify the exception.
BaseRuntimeException(String message, Throwable cause, String key, long code)
          Constructs a BaseException with a default message format, a key to find a localized message format, and a unique code to identify the exception.
 
Method Summary
 long getCode()
           
 String getFormatString()
           
 String getLocalizedMessage()
          Returns the translated message that describes the exception.
 String getLocalizedMessage(ExceptionTranslator translator, int indent)
          Returns the translated message that describes the exception with indentation.
 String getLocalizedMessageStack()
          Crosses the exceptions chained through cause to conform the compound message in the corresponding language.
 String getLocalizedMessageStack(ExceptionTranslator translator, int indent)
          Crosses the exceptions chained through cause to conform the compound message in the corresponding language.
 String getMessage()
          Returns the message that describes the exception.
 String getMessage(int indent)
          Returns the message that describes the exception, with indentation.
 String getMessageKey()
           
 String getMessageStack()
          Crosses the exceptions chained through cause to conform the message.
 String getMessageStack(int indent)
          Crosses the exceptions chained through cause to conform the compound message with indentation.
 Iterator iterator()
           
 void setCode(long code)
          Sets the exception's code.
 void setFormatString(String formatString)
          Sets the format string.
 void setMessageKey(String messageKey)
          Sets the property messageKey.
protected  void setValue(String name, Object value)
           
 String toString()
           
protected  Map values()
           
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

messageKey

protected String messageKey

formatString

protected String formatString
TODO: remove the variable, use the Exception get/setMessage() instead.


code

protected long code
Unique code of error.

Constructor Detail

BaseRuntimeException

public BaseRuntimeException(BaseException exception)

BaseRuntimeException

public BaseRuntimeException(String message,
                            String key,
                            long code)
Constructs a BaseException with a default message format, a key to find a localized message format, and a unique code to identify the exception.

Parameters:
message - the default messageFormat to describe the exception
key - the key to use to search a localized messageFormnata
code - the unique code to identify the exception

BaseRuntimeException

public BaseRuntimeException(String message,
                            Throwable cause,
                            String key,
                            long code)
Constructs a BaseException with a default message format, a key to find a localized message format, and a unique code to identify the exception.

Parameters:
message - the default messageFormat to describe the exception
cause - the original cause of the exception
key - the key to use to search a localized messageFormnata
code - the unique code to identify the exception
Method Detail

getMessage

public String getMessage()
Description copied from interface: IBaseException
Returns the message that describes the exception.

Specified by:
getMessage in interface IBaseException
Overrides:
getMessage in class Throwable
Returns:
The message.

getMessage

public String getMessage(int indent)
Description copied from interface: IBaseException
Returns the message that describes the exception, with indentation.

Specified by:
getMessage in interface IBaseException
Parameters:
indent - Quantity of blanks to insert at the start of the message.
Returns:
The message with indentation.

getLocalizedMessage

public String getLocalizedMessage()
Description copied from interface: IBaseException
Returns the translated message that describes the exception.

Specified by:
getLocalizedMessage in interface IBaseException
Overrides:
getLocalizedMessage in class Throwable
Returns:
The translated message with indentation.

getLocalizedMessage

public String getLocalizedMessage(ExceptionTranslator translator,
                                  int indent)
Description copied from interface: IBaseException
Returns the translated message that describes the exception with indentation.

Specified by:
getLocalizedMessage in interface IBaseException
Parameters:
translator - Instance of a class that fulfills the IExceptionTranslator interface. His method "getText" takes charge returning the expression, correspondent to the key that delivers him, translated into the configured language.
indent - Quantity of blanks to insert at the start of the message.
Returns:
The translated message with indentation.

getMessageStack

public String getMessageStack()
Description copied from interface: IBaseException
Crosses the exceptions chained through cause to conform the message.

Specified by:
getMessageStack in interface IBaseException
Returns:
The compound message with all the messages of the stack of exceptions.

getMessageStack

public String getMessageStack(int indent)
Description copied from interface: IBaseException
Crosses the exceptions chained through cause to conform the compound message with indentation.

Specified by:
getMessageStack in interface IBaseException
Parameters:
indent - Quantity of blanks to insert at the start of the messages.
Returns:
The compound message with all the messages of the stack of exceptions.

getLocalizedMessageStack

public String getLocalizedMessageStack()
Description copied from interface: IBaseException
Crosses the exceptions chained through cause to conform the compound message in the corresponding language.

Specified by:
getLocalizedMessageStack in interface IBaseException
Returns:
The translated compound message.

getLocalizedMessageStack

public String getLocalizedMessageStack(ExceptionTranslator translator,
                                       int indent)
Description copied from interface: IBaseException
Crosses the exceptions chained through cause to conform the compound message in the corresponding language.

Specified by:
getLocalizedMessageStack in interface IBaseException
Parameters:
translator - Instance of a class that fulfills the IExceptionTranslator interface. His method "getText" takes charge returning the expression, correspondent to the key that delivers him, translated into the configured language.
indent - Quantity of blanks to insert at the start of the messages.
Returns:
The translated message with indentation.

getCode

public long getCode()
Specified by:
getCode in interface IBaseException
Returns:
The exception's code.

setCode

public void setCode(long code)
Sets the exception's code.


getFormatString

public String getFormatString()
Specified by:
getFormatString in interface IBaseException
Returns:
The format string.

setFormatString

public void setFormatString(String formatString)
Sets the format string.

Parameters:
formatString -

getMessageKey

public String getMessageKey()
Specified by:
getMessageKey in interface IBaseException
Returns:
The message key associated to the exception.

setMessageKey

public void setMessageKey(String messageKey)
Sets the property messageKey.

Parameters:
messageKey -

iterator

public Iterator iterator()
Specified by:
iterator in interface IBaseException
Returns:
A iterator for the chained exceptions.

values

protected Map values()
Returns:
A map that serves to replace in the format string the keys with the corresponding values.

setValue

protected void setValue(String name,
                        Object value)

toString

public String toString()
Overrides:
toString in class Throwable


Copyright © 2004-2011 gvSIG. All Rights Reserved.