用Java根据错误值解析出错误类型和错误码
来源:互联网 发布:开淘宝店铺怎么描述 编辑:程序博客网 时间:2024/05/22 00:37
public class ErrorParser {public static void main(String[] args) {int ret = encodeDepError(Constants.ELEM_POOL, ErrorCode.STATUS| ErrorCode.LACK | ErrorCode.PROBED_FAILED);String retString = decodeDepError(ret);System.out.println(retString);}public static int encodeDepError(int type, int errorCode) {return -(type << 16 | errorCode);}public static String decodeDepError(int error) {int type;int errorCode;int positiveError = -error;type = positiveError >> 16;errorCode = positiveError & 0xFFFF;System.out.println("type = " + type);System.out.println("errorCode = " + errorCode);return "";}}interface ErrorCode {public static final int DUP = 1 << 0;public static final int STATUS = 1 << 1;public static final int LACK = 1 << 2;public static final int PROBED_FAILED = 1 << 3;}interface Constants {public static final int ELEM_CLUSTER = 0;public static final int ELEM_HOST = 1;public static final int ELEM_MON = 2;public static final int ELEM_DISK = 3;public static final int ELEM_OSD = 4;public static final int ELEM_MDS = 5;public static final int ELEM_POOL = 6;public static final int ELEM_ACCS = 7;public static final int ELEM_NTYPES = 8;}
输出为:
type =6
errorCode = 14
0 0
- 用Java根据错误值解析出错误类型和错误码
- java类型转化错误
- Java的错误类型
- Java错误类型
- 十四、java程序错误类型和异常
- 根据前序和中序重建二叉树的代码,出了错误 请指教
- 根据错误码获取错误信息
- 错误类型
- debug错误码解析
- 错误解析
- java.lang.ClassCastException: 错误解析
- oracle netca出错误
- @Override 时出错误:
- databinding 出错误
- java错误和异常
- Java 错误和异常
- python 错误和异常解析
- 【总结】错误解析和字符集
- 1.2.5对指针使用const限定符
- 关于图像特征提取
- 《健康时报》:请不要随便输液
- 二维图形变换
- IO
- 用Java根据错误值解析出错误类型和错误码
- android之旅4: XML方式读写数据与文件创建
- Android监听软键盘弹出与收起
- Linux下配置Caffe及其Python接口全过程记录(Ubuntu15.10_amd64+CUDA7.5)及训练mnist数据集
- 窗口刷新问题(WMPAINT、BeginPaint、EndPaint的说明)
- C51中变量的存储器类型有
- 心上莲花:见闻两则——杀业的果报
- C读取和写入一个二维数组
- 一个程序员工作三年的思考