java中的枚举可以有方法和属性,举例如下:
public enum Authorization{
AUTHORIZATION{
@override
public abstract int getErrorCode()
{
return 501;
}
@override
public abstract String getErrorCondition()
{
return null;
}
@override
public abstrct String getErrorType()
{
return ERR_TYPE_AUTH;
}
}
public abstract int getErrorCode();
public abstract String getErrorCondition();
publci abstrct String getErrorType();
public static final String ERR_TYPE_AUTH="auth";
public static final String ERR_TYPE_CANCEL="cancel";
public Packet getResponseMessage(Packet packet,String text,boolean includeOriginalXML)
{
packet.errorResult(getErrorCode(),getErrorType(),getErrorCondition(),text,includeOriginalXML);
}
};
阅读(1135) | 评论(0) | 转发(0) |