com.sdm.quasar.client.core.common.util
Class AbstractNamedRuntimeException

java.lang.Object
  extended byjava.lang.Throwable
      extended byjava.lang.Exception
          extended byjava.lang.RuntimeException
              extended bycom.sdm.quasar.client.core.common.util.AbstractNamedRuntimeException
All Implemented Interfaces:
NamedException, java.io.Serializable

public abstract class AbstractNamedRuntimeException
extends java.lang.RuntimeException
implements NamedException

A base class that implements com.dcag.s55.gool.err.NamedException and extends RuntimeException (for runtime exceptions).

Version:
1.$Revision: 1.5 $
Author:
Thomas Wolf
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface com.sdm.quasar.client.core.common.util.NamedException
EXCEPTION_TYPE_EXCEPTION, EXCEPTION_TYPE_INFO, EXCEPTION_TYPE_WARNING
 
Constructor Summary
AbstractNamedRuntimeException(java.lang.String id)
          Creates a new AbstractNamedRuntimeException.
AbstractNamedRuntimeException(java.lang.String id, java.lang.Throwable cause)
          Creates a new AbstractNamedRuntimeException.
 
Method Summary
protected static void assertIsContained(java.lang.String id, java.lang.String[] valid_ids)
          Throws an IllegalArgumentException, if the given id is not contained in the list of valid id's given.
 java.util.Map getArgs()
          Returns all arguments of the exception.
protected static int getArrayIndex(java.lang.String id, java.lang.String[] valid_ids)
          Returns the index of the given identifier in the array of valid id's.
protected static java.lang.String getClassName(java.lang.Class cls)
          Returns the class name only (without the package name) of the given Class.
 java.lang.String getID()
          Returns the exception identifier of the exception (never null).
protected static java.lang.String getIDFromIndex(int id_index, java.lang.String[] valid_ids)
          Returns the string identifier for the given integer identifier.
 java.lang.String getMessage()
           
 java.lang.String getName()
          Returns the full name of this exception (never null).
 int getType()
          Returns the exception type.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.sdm.quasar.client.core.common.util.NamedException
getUnlocalizedMessagePattern
 

Constructor Detail

AbstractNamedRuntimeException

public AbstractNamedRuntimeException(java.lang.String id,
                                     java.lang.Throwable cause)
Creates a new AbstractNamedRuntimeException.

Parameters:
id - the exception identifier (not null)

AbstractNamedRuntimeException

public AbstractNamedRuntimeException(java.lang.String id)
Creates a new AbstractNamedRuntimeException.

Parameters:
id - the exception identifier(not null)
Method Detail

getID

public java.lang.String getID()
Description copied from interface: NamedException
Returns the exception identifier of the exception (never null). The exception identifier is a string that differs between various instances of the same exception class.

Specified by:
getID in interface NamedException

getName

public java.lang.String getName()
Description copied from interface: NamedException
Returns the full name of this exception (never null). The name should be unique for all implementations (??instances??) of NamedException. The first part should be the class name (without package name) followed by a dot (".") and the exception name. This name will be used to localize the exception.

Specified by:
getName in interface NamedException

getArgs

public java.util.Map getArgs()
Description copied from interface: NamedException
Returns all arguments of the exception. The keys of the arguments have to be strings in order to use them to format error messages. The argument map might be used to format a (localized) error message.

Specified by:
getArgs in interface NamedException
Returns:
the argument map for the error (never null).

getType

public int getType()
Returns the exception type. This implementation returns always NamedException.EXCEPTION_TYPE_EXCEPTION as exception type.

Specified by:
getType in interface NamedException
Returns:
the exception type.

getMessage

public java.lang.String getMessage()

getClassName

protected static final java.lang.String getClassName(java.lang.Class cls)
Returns the class name only (without the package name) of the given Class.

Parameters:
cls - the Class to extract class name of
Returns:
the class name without the package name of the class.

getIDFromIndex

protected static final java.lang.String getIDFromIndex(int id_index,
                                                       java.lang.String[] valid_ids)
Returns the string identifier for the given integer identifier. If the integer identifier is not valid, a IllegalArgumentException is thrown

Parameters:
id_index - the id as integer
valid_ids - the array with all valid string identifiers. The integer is treated as index of this array
Returns:
the string identifier for the given integer identifier
Throws:
java.lang.IllegalArgumentException - if the integer id is not valid

assertIsContained

protected static final void assertIsContained(java.lang.String id,
                                              java.lang.String[] valid_ids)
Throws an IllegalArgumentException, if the given id is not contained in the list of valid id's given. This method might be used by subclass to ensure, that their constructor will be called only with valid id's (in the case subclasses do not hardcode the id per constructor).

Parameters:
id - the identifier to check
valid_ids - the array of valid identifiers
Throws:
java.lang.IllegalArgumentException - if the given name is not contained in the list of valid names

getArrayIndex

protected static final int getArrayIndex(java.lang.String id,
                                         java.lang.String[] valid_ids)
Returns the index of the given identifier in the array of valid id's. This method might be used by subclass to switch over exception id's.

Parameters:
id - the identifier to get the index for
valid_ids - the array of valid identifiers to search index in
Returns:
the index of id in the array or -1 if the is is not contained (or null)