exception;
SQLUtils.cleanup(statement); SQLUtils.cleanup(conn); throw exception; }
EAS的两大异常--BOSException EASBizException 2005年12月
BOSException EASBizException
BOSException是系统级别的异常,比如,创建远程连接的时候,都会声明可能抛出这个异常 EASBizException是业务异常,基本上所有的业务异常都要求继承于这个异常,所以一般情况下服务段的业务方法都会实现先声明可能会这个异常
public class EASBizException extends NumericException {
private static final String MAINCODE = "10";
public static final NumericExceptionSubItem CHECKTEXTLENGTH1 = new NumericExceptionSubItem("10", "CHECKTEXTLENGTH1");
public static final NumericExceptionSubItem CHECKTEXTLENGTH2 = new NumericExceptionSubItem("11", "CHECKTEXTLENGTH2"); public static final NumericExceptionSubItem CHECKINT = new NumericExceptionSubItem("20", "CHECKINT"); public static final NumericExceptionSubItem CHECKBLANK = new NumericExceptionSubItem("22", "CHECKBLANK");
public static final NumericExceptionSubItem CHECKDUPLICATED = new NumericExceptionSubItem("23", "CHECKDUPLICATED");
public static final NumericExceptionSubItem CHECKDUPNUMBER = new NumericExceptionSubItem("31", "CHECKDupNumber");
public static final NumericExceptionSubItem CHECKPARENTDELETED = new NumericExceptionSubItem("41", "CHECKPARENTDELETED");
public static final NumericExceptionSubItem CHECKPARENTUNEFFECTED = new NumericExceptionSubItem("42", "CHECKPARENTUNEFFECTED");
public static final NumericExceptionSubItem CHECKPARENTBEUSED = new NumericExceptionSubItem("43", "CHECKPARENTBEUSED");
public static final NumericExceptionSubItem CHECKNAMEBLANK = new NumericExceptionSubItem("221", "CHECKNAMEBLANK");
public static final NumericExceptionSubItem CHECKNUMBLANK = new
NumericExceptionSubItem("222", "CHECKNUMBLANK");
public static final NumericExceptionSubItem CHECKNAMEDUP = new NumericExceptionSubItem("231", "CHECKNAMEDUP");
public static final NumericExceptionSubItem CHECKNUMDUP = new NumericExceptionSubItem("232", "CHECKNUMDUP"); public static final NumericExceptionSubItem CHECKEXIST = new NumericExceptionSubItem("321", "CHECKEXIST"); public static final NumericExceptionSubItem DBDEADLOCK = new NumericExceptionSubItem("400", "DBDEADLOCK"); public static final NumericExceptionSubItem RPCCOMMERR = new NumericExceptionSubItem("401", "RPCCOMMERR");
public static final NumericExceptionSubItem OLDNEWACCOUNTSTART = new NumericExceptionSubItem("402", "OLDNEWACCOUNTSTART"); /**
* construct function
* @param NumericExceptionSubItem info * @param Throwable cause * @param Object[] params */
public EASBizException(NumericExceptionSubItem info, Throwable cause, Object[] params) {
super(info, cause, params); } /**
* construct function
* @param NumericExceptionSubItem info,Object[] params */
public EASBizException(NumericExceptionSubItem info, Object[] params) {
this(info, null, params); } /**
* construct function
* @param NumericExceptionSubItem info,Throwable cause */
public EASBizException(NumericExceptionSubItem info, Throwable cause) {
this(info, cause, null); } /**
* construct function
* @param NumericExceptionSubItem info */
public EASBizException(NumericExceptionSubItem info) {
this(info, null, null); } /**
* getMainCode function */
public String getMainCode() {
return MAINCODE; } }
EAS学习-EAS的枚举 2006/2/23
下边是一个典型的EAS枚举
public class BillStatusEnum extends IntEnum {
public static final int TEMPSAVED_VALUE = 1; public static final int SUBMITED_VALUE = 2; public static final BillStatusEnum TempSaved = new BillStatusEnum("TempSaved", TEMPSAVED_VALUE); public static final BillStatusEnum Submited = new BillStatusEnum("Submited", SUBMITED_VALUE); /**
注意到了么,枚举类的构造方法修饰为private,也就是说我们无法在外部构造一个BillStatusEnum类的实例,只能通过BillStatusEnum.TempSaved或BillStatusEnum.Submited来获取已定义好的实例,这样我们就保证了枚举的选择范围始终是我们预期的,这个就是所谓的typesafe enum模式 * construct function
* @param integer billStatusEnum */
private BillStatusEnum(String name, int billStatusEnum) {
super(name, billStatusEnum); } /**
* getEnum function
* @param String arguments
*/
public static BillStatusEnum getEnum(String billStatusEnum) {
return (BillStatusEnum)getEnum(BillStatusEnum.class, billStatusEnum); } /**
* getEnum function
* @param String arguments */
public static BillStatusEnum getEnum(int billStatusEnum) {
return (BillStatusEnum)getEnum(BillStatusEnum.class, billStatusEnum); } /**
* getEnumMap function */
public static Map getEnumMap() {
return getEnumMap(BillStatusEnum.class); } /**
* getEnumList function */
public static List getEnumList() {
return getEnumList(BillStatusEnum.class); } /**
* getIterator function */
public static Iterator iterator() {
return iterator(BillStatusEnum.class); } }
早期非Typesafe Enum的方式 public class Season {
public static final int SPRING = 0; public static final int SUMMER = 1; public static final int AUTUMN = 2; public static final int WINTER = 3; }