Java tutorial
/** * @(#)ErrorCoder.java 2013-4-1 * * Copyright 2013 Neusoft Group Ltd. All rights reserved. * Neusoft PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ package com.huasoft.entity; import javax.xml.bind.annotation.XmlElement; import org.apache.commons.lang.StringUtils; import com.huasoft.tools.JacksonUtils; /** * ?? * * @author <a href="mailto:yi_liu@neusoft.com">yi_liu </a> * @version $Revision 1.0 $ 2013-4-1 ?8:57:40 */ public final class ErrorBean { /** * ? */ @XmlElement(name = "error_code") private String errorCode = ""; /** * ?? */ @XmlElement(name = "error_des") private String errorDes = ""; /** * * * @param errorCode * ? * @param errorDes * ?? */ public ErrorBean(String errorCode, String errorDes) { errorCode = StringUtils.strip(errorCode); errorDes = StringUtils.strip(errorDes); // ?jackson?json if (StringUtils.isEmpty(errorCode) || StringUtils.isEmpty(errorDes)) { this.errorCode = "99999"; this.errorDes = "Uknow Exception"; } else { this.errorCode = errorCode; this.errorDes = errorDes; } } /** * @return Returns the errorCode. */ public String getErrorCode() { return errorCode; } /** * @param errorCode * The errorCode to set. */ public void setErrorCode(String errorCode) { this.errorCode = errorCode; } /** * @return Returns the errorDes. */ public String getErrorDes() { return errorDes; } /** * @param errorDes * The errorDes to set. */ public void setErrorDes(String errorDes) { this.errorDes = errorDes; } /** * ErrorBean?json * * @return json */ public String toJson() { return JacksonUtils.toJsonRuntimeException(this); } /* * (non-Javadoc) * * @see java.lang.Object#toString() */ @Override public String toString() { return "[ errorCode=" + errorCode + ", errorDes=" + errorDes + " ]"; } }