KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jmanage > core > data > OperationResultData


1 /**
2  * Copyright 2004-2005 jManage.org
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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  */

16 package org.jmanage.core.data;
17
18 import org.jmanage.core.management.data.DataFormatUtil;
19
20 import java.io.StringWriter JavaDoc;
21 import java.io.PrintWriter JavaDoc;
22
23 /**
24  *
25  * date: Jan 23, 2005
26  * @author Rakesh Kalra
27  */

28 public class OperationResultData implements java.io.Serializable JavaDoc {
29
30     public static final int RESULT_OK = 0;
31     public static final int RESULT_ERROR =1;
32
33     private String JavaDoc appName;
34     private Object JavaDoc output;
35     private int result = RESULT_OK;
36     private String JavaDoc errorString;
37     private String JavaDoc stackTrace;
38
39     public OperationResultData(String JavaDoc appName){
40         this.appName = appName;
41     }
42
43     public String JavaDoc getApplicationName(){
44         return appName;
45     }
46
47     public Object JavaDoc getOutput() {
48         return output;
49     }
50
51     public String JavaDoc getDisplayOutput(){
52         return DataFormatUtil.format(getOutput());
53     }
54
55     public void setOutput(Object JavaDoc 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 JavaDoc getErrorString() {
68         return errorString;
69     }
70
71     public void setErrorString(String JavaDoc errorString) {
72         this.errorString = errorString;
73     }
74
75     public void setException(Throwable JavaDoc e){
76         setErrorString(e.getMessage());
77         StringWriter JavaDoc writer = new StringWriter JavaDoc();
78         e.printStackTrace(new PrintWriter JavaDoc(writer));
79         this.stackTrace = writer.toString();
80     }
81
82     public String JavaDoc getStackTrace(){
83         return stackTrace;
84     }
85
86     public boolean isError(){
87         return result == RESULT_ERROR;
88     }
89 }
90
Popular Tags