multex
Class Exc
java.lang.Object
|
+--java.lang.Throwable
|
+--java.lang.Exception
|
+--multex.Exc
- Direct Known Subclasses:
- Copy.StartedExc
- public abstract class Exc
- extends java.lang.Exception
- implements MultexException
Problem-related exception with named parameters and internationalizable
message text.
This class serves for the framework user as a base class for defining
problem-related exceptions.
Naming convention:
All user-defined exception classes derived from Exc should have a name
ending in Exc. The pattern is:
class ErrorconditionExc extends Exc { ... }
Named parameters
All public non-static fields of an exception object are
considered named parameters of it. The corresponding placeholders in the
message text patterns have the syntax: {name}
with name being the name of the parameter.
This way of providing parameters is the recommended one for the following
reasons: Firstly it is
easier to translate a message text pattern into another language, if in the
message text pattern there is an indication, for which purpose the
message parameter is. The parameter name usually is a good hint to this.
Secondly naming parameters is safer when adding or removing a parameter
to/from an exception.
Thirdly named parameters, for which a placeholder in the corresponding
message text is missing, will not be suppressed. They will be appended
in a standard format along with their name to the end of the message text.
The exception parameters can
be substituted into the corresponding message text pattern in a desired locale
format by class MsgText, which itself makes use of class
java.text.MessageFormat.
See the usage examples Copy, AwtCopy, SwingCopy in directory demo.
Relation to Standards
Class java.text.MesageFormat expects the message parameters
to be stored in an Object[]. So they are indexed parameters.
We did not follow this way in order to be able to name parameters.
All the rest of parameter formatting is done by and like
java.text.MesageFormat, e.g. formatting a parameter of type java.util.Date
with name today could be done by the following parameter formatting directive:
{today,date}.
- See Also:
- Serialized Form
|
Constructor Summary |
Exc(java.lang.String i_defaultMessageTextPattern)
Constructs an Exc with a default message text pattern.
|
|
Method Summary |
java.lang.String |
getDefaultMessageTextPattern()
Returns the default message text pattern for i_throwable or null.
|
java.lang.String |
getMessage()
Returns the exception parameters of this object or null.
|
| Methods inherited from class java.lang.Throwable |
fillInStackTrace,
getLocalizedMessage,
printStackTrace,
printStackTrace,
printStackTrace,
toString |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Exc
public Exc(java.lang.String i_defaultMessageTextPattern)
- Constructs an Exc with a default message text pattern.
All public nonstatic fields are considered as named
parameters of this exception object.
getMessage
public java.lang.String getMessage()
- Returns the exception parameters of this object or null.
They are in a compact, human readable format, e.g.:
{name}=myfile.dat {directory}=C:\temp\data
- Overrides:
- getMessage in class java.lang.Throwable
getDefaultMessageTextPattern
public java.lang.String getDefaultMessageTextPattern()
- Description copied from interface: MultexException
- Returns the default message text pattern for i_throwable or null.
Inserting the exception parameters into the message text pattern is
done by class
MsgText.
Locale specific message text patterns are handled by MsgText, too.
- Specified by:
- getDefaultMessageTextPattern in interface MultexException