KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > vfs > status > AbstractStatusData


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19 package org.openharmonise.vfs.status;
20
21 import java.util.*;
22
23 /**
24  *
25  * @author Matthew Large
26  * @version $Revision: 1.1 $
27  *
28  */

29 public abstract class AbstractStatusData implements StatusData {
30
31     private List m_CONFIRMLevelStatusData = new ArrayList();
32     private List m_WARNINGLevelStatusData = new ArrayList();
33     private List m_ERRORLevelStatusData = new ArrayList();
34     
35     private int m_nWorstLevel = 0;
36
37     private int m_nLevel = 0;
38     private int m_nStatus = 0;
39     
40     private String JavaDoc m_sMethodName = "UNKNOWN_METHOD";
41     
42     private StatusData m_parentStatus = null;
43     
44     public AbstractStatusData() {
45         super();
46     }
47     
48     public AbstractStatusData(StatusData parentStatus) {
49         super();
50         this.m_parentStatus = parentStatus;
51     }
52
53     /* (non-Javadoc)
54      * @see com.simulacramedia.vfs.status.StatusData#getStatusCode()
55      */

56     public int getStatusCode() {
57         return this.m_nStatus;
58     }
59     /* (non-Javadoc)
60      * @see com.simulacramedia.vfs.status.StatusData#getStatusLevel()
61      */

62     public int getStatusLevel() {
63         return this.m_nLevel;
64     }
65     
66     protected void setStatusCode(int nStatus) {
67         this.m_nStatus = nStatus;
68     }
69     
70     public void setStatusLevel(int nLevel) {
71         if(this.m_parentStatus!=null && this.m_parentStatus.getWorstLevel()<nLevel) {
72             this.m_parentStatus.setStatusLevel(nLevel);
73         }
74         this.m_nLevel = nLevel;
75         this.m_nWorstLevel = nLevel;
76     }
77
78     /* (non-Javadoc)
79      * @see com.simulacramedia.vfs.status.StatusData#isOK()
80      */

81     public boolean isOK() {
82         return (this.m_nStatus==StatusData.STATUS_OK && this.m_nLevel==StatusData.LEVEL_CONFIRM && this.m_nWorstLevel==StatusData.LEVEL_CONFIRM);
83     }
84     
85     public void addStatusData(StatusData status) {
86         if(status.getWorstLevel()==StatusData.LEVEL_CONFIRM) {
87             this.m_CONFIRMLevelStatusData.add(status);
88         } else if(status.getWorstLevel()==StatusData.LEVEL_WARNING) {
89             if(this.m_nWorstLevel<StatusData.LEVEL_WARNING) {
90                 this.m_nWorstLevel=StatusData.LEVEL_WARNING;
91             }
92             if(this.m_parentStatus!=null && this.m_parentStatus.getWorstLevel()<StatusData.LEVEL_WARNING) {
93                 this.m_nWorstLevel=StatusData.LEVEL_WARNING;
94             }
95             this.m_WARNINGLevelStatusData.add(status);
96         } else if(status.getWorstLevel()==StatusData.LEVEL_ERROR) {
97             if(this.m_nWorstLevel<StatusData.LEVEL_ERROR) {
98                 this.m_nWorstLevel=StatusData.LEVEL_ERROR;
99             }
100             if(this.m_parentStatus!=null && this.m_parentStatus.getWorstLevel()<StatusData.LEVEL_ERROR) {
101                 this.m_nWorstLevel=StatusData.LEVEL_ERROR;
102             }
103             this.m_ERRORLevelStatusData.add(status);
104         }
105     }
106     
107     public int getWorstLevel() {
108         return this.m_nWorstLevel;
109     }
110     
111     public List getStatusData(int nLevel) {
112         List aRetn = null;
113         
114         if(nLevel==StatusData.LEVEL_CONFIRM) {
115             aRetn = this.m_CONFIRMLevelStatusData;
116         } else if(nLevel==StatusData.LEVEL_WARNING) {
117             aRetn = this.m_WARNINGLevelStatusData;
118         } else if(nLevel==StatusData.LEVEL_ERROR) {
119             aRetn = this.m_ERRORLevelStatusData;
120         }
121         
122         return aRetn;
123     }
124     
125     
126     /* (non-Javadoc)
127      * @see com.simulacramedia.vfs.status.StatusData#getMethodName()
128      */

129     public String JavaDoc getMethodName() {
130         return this.m_sMethodName;
131     }
132     /* (non-Javadoc)
133      * @see com.simulacramedia.vfs.status.StatusData#setMethodName(java.lang.String)
134      */

135     public void setMethodName(String JavaDoc sMethodName) {
136         this.m_sMethodName = sMethodName;
137     }
138 }
139
Popular Tags