01: /**
02: * Copyright 2004-2005 jManage.org
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */package org.jmanage.core.data;
16:
17: import org.jmanage.core.management.data.DataFormatUtil;
18:
19: import java.io.StringWriter;
20: import java.io.PrintWriter;
21:
22: /**
23: *
24: * date: Jan 23, 2005
25: * @author Rakesh Kalra
26: */
27: public class OperationResultData implements java.io.Serializable {
28:
29: public static final int RESULT_OK = 0;
30: public static final int RESULT_ERROR = 1;
31:
32: private String appName;
33: private Object output;
34: private int result = RESULT_OK;
35: private String errorString;
36: private String stackTrace;
37:
38: public OperationResultData(String appName) {
39: this .appName = appName;
40: }
41:
42: public String getApplicationName() {
43: return appName;
44: }
45:
46: public Object getOutput() {
47: return output;
48: }
49:
50: public String getDisplayOutput() {
51: return DataFormatUtil.format(getOutput());
52: }
53:
54: public void setOutput(Object output) {
55: this .output = output;
56: }
57:
58: public int getResult() {
59: return result;
60: }
61:
62: public void setResult(int result) {
63: this .result = result;
64: }
65:
66: public String getErrorString() {
67: return errorString;
68: }
69:
70: public void setErrorString(String errorString) {
71: this .errorString = errorString;
72: }
73:
74: public void setException(Throwable e) {
75: setErrorString(e.getMessage());
76: StringWriter writer = new StringWriter();
77: e.printStackTrace(new PrintWriter(writer));
78: this .stackTrace = writer.toString();
79: }
80:
81: public String getStackTrace() {
82: return stackTrace;
83: }
84:
85: public boolean isError() {
86: return result == RESULT_ERROR;
87: }
88: }
|