1 16 package org.jmanage.core.data; 17 18 import org.jmanage.core.management.data.DataFormatUtil; 19 20 import java.io.StringWriter ; 21 import java.io.PrintWriter ; 22 23 28 public class OperationResultData implements java.io.Serializable { 29 30 public static final int RESULT_OK = 0; 31 public static final int RESULT_ERROR =1; 32 33 private String appName; 34 private Object output; 35 private int result = RESULT_OK; 36 private String errorString; 37 private String stackTrace; 38 39 public OperationResultData(String appName){ 40 this.appName = appName; 41 } 42 43 public String getApplicationName(){ 44 return appName; 45 } 46 47 public Object getOutput() { 48 return output; 49 } 50 51 public String getDisplayOutput(){ 52 return DataFormatUtil.format(getOutput()); 53 } 54 55 public void setOutput(Object output) { 56 this.output = output; 57 } 58 59 public int getResult() { 60 return result; 61 } 62 63 public void setResult(int result) { 64 this.result = result; 65 } 66 67 public String getErrorString() { 68 return errorString; 69 } 70 71 public void setErrorString(String errorString) { 72 this.errorString = errorString; 73 } 74 75 public void setException(Throwable e){ 76 setErrorString(e.getMessage()); 77 StringWriter writer = new StringWriter (); 78 e.printStackTrace(new PrintWriter (writer)); 79 this.stackTrace = writer.toString(); 80 } 81 82 public String getStackTrace(){ 83 return stackTrace; 84 } 85 86 public boolean isError(){ 87 return result == RESULT_ERROR; 88 } 89 } 90 | Popular Tags |