at.spardat.enterprise.exc.AppException Maven / Gradle / Ivy
/*******************************************************************************
* Copyright (c) 2003, 2007 s IT Solutions AT Spardat GmbH .
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* s IT Solutions AT Spardat GmbH - initial API and implementation
*******************************************************************************/
// @(#) $Id: AppException.java 2093 2007-11-28 14:23:36Z s3460 $
package at.spardat.enterprise.exc;
/**
* This class is used to throw application-level exceptions. Application-exceptions
* inform the outside world from abnormal application-level conditions, such as
* illegal arguments to business methods or illegal state of data a business method
* is operating on.
*
* Application-exception are most often caused by the end-user (in online applications)
* who triggers business logic in a particular way that results in abnormal conditions.
*
* Application-exceptions are not used to indicate system-level problems. For that
* purpose a separate class {@link SysException} may be used.
*
* This class may be subclassed with the restriction, that only methods may
* be added in the subclass, not instance variables. The reason: This class
* is used in remote communications and arbitrarely subclassing would require
* the remote clients to be also able to load the subclasses.
*
* @author YSD, 21.05.2003 19:29:23
*/
public class AppException extends BaseException {
/**
* Increase this if u make non compatible changes
*/
private static final long serialVersionUID = 1L;
/**
* Constructs and sets the message of this from a one
* parameter java.text.MessageFormat compatible string.
*
* @param messageFmt format string as defined in java.text.MessageFormat.
* @param params the message parameters
*/
public AppException (String messageFmt, Object[] params) {
super (null, messageFmt, null, params);
showToEndUser_ = true;
}
/**
* Constructs and sets the message of this from a two
* parameter java.text.MessageFormat compatible string.
*
* @param messageFmt format string as defined in java.text.MessageFormat.
* @param param1 first message parameter
* @param param2 second message parameter
*/
public AppException (String messageFmt, Object param1, Object param2) {
super (null, messageFmt, null, new Object[]{param1,param2});
showToEndUser_ = true;
}
/**
* Constructs and sets the message of this from a one
* parameter java.text.MessageFormat compatible string.
*
* @param messageFmt format string as defined in java.text.MessageFormat.
* @param param1 message parameter
*/
public AppException (String messageFmt, Object param1) {
super (null, messageFmt, null, new Object[]{param1});
showToEndUser_ = true;
}
/**
* Constructs and sets the message to the provided value.
*
* @param message text to set
*/
public AppException (String message) {
super (null, message, null, null);
showToEndUser_ = true;
}
/**
* Constructs and sets the message and the detail exception to the provided value.
*
* @param detail the detail throwable to set.
* @param message text to set
*/
public AppException (Throwable detail, String message) {
super (detail, message, null, null);
showToEndUser_ = true;
}
/**
* Constructs with a detail exception and an empty message.
*
* @param detail the detail throwable to set.
*/
public AppException (Throwable detail) {
super (detail, "", null, null);
showToEndUser_ = true;
}
/**
* Constructs and sets the message of this from a one
* parameter java.text.MessageFormat compatible string.
*
* @param detail detail throwable.
* @param messageFmt format string as defined in java.text.MessageFormat.
* @param params the message parameters
*/
public AppException (Throwable detail, String messageFmt, Object[] params) {
super (detail, messageFmt, null, params);
showToEndUser_ = true;
}
/**
* Constructs and sets the message of this from a two
* parameter java.text.MessageFormat compatible string.
*
* @param detail the detail throwable.
* @param messageFmt format string as defined in java.text.MessageFormat.
* @param param1 first message parameter
* @param param2 second message parameter
*/
public AppException (Throwable detail, String messageFmt, Object param1, Object param2) {
super (detail, messageFmt, null, new Object[]{param1,param2});
showToEndUser_ = true;
}
/**
* Constructs and sets the message of this from a one
* parameter java.text.MessageFormat compatible string.
*
* @param detail detail throwable.
* @param messageFmt format string as defined in java.text.MessageFormat.
* @param param1 message parameter
*/
public AppException (Throwable detail, String messageFmt, Object param1) {
super (detail, messageFmt, null, new Object[]{param1});
showToEndUser_ = true;
}
/**
* Sets the code. The code should be used to discrimitate among
* different kinds of exceptions/notifications.
*
* @see INotification
*/
public AppException setCode (int code) {
notification_.setCode(code);
return this;
}
/**
* Sets one or a bit-or combination of the reaction constants
* of INotification.
*
* @see INotification#getReaction()
* @return this
*/
public AppException setReaction (int reaction) {
notification_.setReaction(reaction);
return this;
}
/**
* Sets the short message.
*
* @see INotification#getShortMessage()
*/
public AppException setShortMessage (String shortMessage) {
notification_.setShortMessage(shortMessage);
return this;
}
/**
* Sets the type which may be one of the T_-constants in
* {@link INotification}.
*
* @see INotification#getType()
* @return this
*/
public AppException setType (int type) {
notification_.setType(type);
return this;
}
/**
* Sets if this exception may be directly displayed to the end user or not. If
* not called, this property defaults to true.
*/
public AppException setShowToEndUser (boolean what) {
showToEndUser_ = what;
return this;
}
}