001: /*
002: * The contents of this file are subject to the
003: * Mozilla Public License Version 1.1 (the "License");
004: * you may not use this file except in compliance with the License.
005: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006: *
007: * Software distributed under the License is distributed on an "AS IS"
008: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
009: * See the License for the specific language governing rights and
010: * limitations under the License.
011: *
012: * The Initial Developer of the Original Code is Simulacra Media Ltd.
013: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014: *
015: * All Rights Reserved.
016: *
017: * Contributor(s):
018: */
019: package org.openharmonise.vfs.status;
020:
021: import java.util.*;
022:
023: /**
024: *
025: * @author Matthew Large
026: * @version $Revision: 1.1 $
027: *
028: */
029: public abstract class AbstractStatusData implements StatusData {
030:
031: private List m_CONFIRMLevelStatusData = new ArrayList();
032: private List m_WARNINGLevelStatusData = new ArrayList();
033: private List m_ERRORLevelStatusData = new ArrayList();
034:
035: private int m_nWorstLevel = 0;
036:
037: private int m_nLevel = 0;
038: private int m_nStatus = 0;
039:
040: private String m_sMethodName = "UNKNOWN_METHOD";
041:
042: private StatusData m_parentStatus = null;
043:
044: public AbstractStatusData() {
045: super ();
046: }
047:
048: public AbstractStatusData(StatusData parentStatus) {
049: super ();
050: this .m_parentStatus = parentStatus;
051: }
052:
053: /* (non-Javadoc)
054: * @see com.simulacramedia.vfs.status.StatusData#getStatusCode()
055: */
056: public int getStatusCode() {
057: return this .m_nStatus;
058: }
059:
060: /* (non-Javadoc)
061: * @see com.simulacramedia.vfs.status.StatusData#getStatusLevel()
062: */
063: public int getStatusLevel() {
064: return this .m_nLevel;
065: }
066:
067: protected void setStatusCode(int nStatus) {
068: this .m_nStatus = nStatus;
069: }
070:
071: public void setStatusLevel(int nLevel) {
072: if (this .m_parentStatus != null
073: && this .m_parentStatus.getWorstLevel() < nLevel) {
074: this .m_parentStatus.setStatusLevel(nLevel);
075: }
076: this .m_nLevel = nLevel;
077: this .m_nWorstLevel = nLevel;
078: }
079:
080: /* (non-Javadoc)
081: * @see com.simulacramedia.vfs.status.StatusData#isOK()
082: */
083: public boolean isOK() {
084: return (this .m_nStatus == StatusData.STATUS_OK
085: && this .m_nLevel == StatusData.LEVEL_CONFIRM && this .m_nWorstLevel == StatusData.LEVEL_CONFIRM);
086: }
087:
088: public void addStatusData(StatusData status) {
089: if (status.getWorstLevel() == StatusData.LEVEL_CONFIRM) {
090: this .m_CONFIRMLevelStatusData.add(status);
091: } else if (status.getWorstLevel() == StatusData.LEVEL_WARNING) {
092: if (this .m_nWorstLevel < StatusData.LEVEL_WARNING) {
093: this .m_nWorstLevel = StatusData.LEVEL_WARNING;
094: }
095: if (this .m_parentStatus != null
096: && this .m_parentStatus.getWorstLevel() < StatusData.LEVEL_WARNING) {
097: this .m_nWorstLevel = StatusData.LEVEL_WARNING;
098: }
099: this .m_WARNINGLevelStatusData.add(status);
100: } else if (status.getWorstLevel() == StatusData.LEVEL_ERROR) {
101: if (this .m_nWorstLevel < StatusData.LEVEL_ERROR) {
102: this .m_nWorstLevel = StatusData.LEVEL_ERROR;
103: }
104: if (this .m_parentStatus != null
105: && this .m_parentStatus.getWorstLevel() < StatusData.LEVEL_ERROR) {
106: this .m_nWorstLevel = StatusData.LEVEL_ERROR;
107: }
108: this .m_ERRORLevelStatusData.add(status);
109: }
110: }
111:
112: public int getWorstLevel() {
113: return this .m_nWorstLevel;
114: }
115:
116: public List getStatusData(int nLevel) {
117: List aRetn = null;
118:
119: if (nLevel == StatusData.LEVEL_CONFIRM) {
120: aRetn = this .m_CONFIRMLevelStatusData;
121: } else if (nLevel == StatusData.LEVEL_WARNING) {
122: aRetn = this .m_WARNINGLevelStatusData;
123: } else if (nLevel == StatusData.LEVEL_ERROR) {
124: aRetn = this .m_ERRORLevelStatusData;
125: }
126:
127: return aRetn;
128: }
129:
130: /* (non-Javadoc)
131: * @see com.simulacramedia.vfs.status.StatusData#getMethodName()
132: */
133: public String getMethodName() {
134: return this .m_sMethodName;
135: }
136:
137: /* (non-Javadoc)
138: * @see com.simulacramedia.vfs.status.StatusData#setMethodName(java.lang.String)
139: */
140: public void setMethodName(String sMethodName) {
141: this.m_sMethodName = sMethodName;
142: }
143: }
|