587
|
1 |
/*
|
|
2 |
* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
package com.nokia.helium.signal;
|
|
18 |
|
|
19 |
import java.util.Vector;
|
|
20 |
|
|
21 |
import org.apache.log4j.Logger;
|
|
22 |
|
|
23 |
/**
|
|
24 |
* This class implements at storage for SignalStatus object.
|
|
25 |
* It cannot be instantiated, it must be used through the typed list:
|
|
26 |
* getDeferredSignalList, getNowSignalList, getNeverSignalList
|
|
27 |
*
|
|
28 |
*/
|
|
29 |
public final class SignalStatusList {
|
|
30 |
|
|
31 |
private static SignalStatusList deferSignalList = new SignalStatusList();
|
|
32 |
private static SignalStatusList nowSignalList = new SignalStatusList();
|
|
33 |
private static SignalStatusList neverSignalList = new SignalStatusList();
|
|
34 |
|
|
35 |
private Vector<SignalStatus> signals = new Vector<SignalStatus>();
|
|
36 |
|
|
37 |
private Logger log = Logger.getLogger(this.getClass());
|
|
38 |
|
|
39 |
|
|
40 |
private SignalStatusList() { }
|
|
41 |
|
|
42 |
/**
|
|
43 |
* Get the list of stored SignalStatus object.
|
|
44 |
* @return a Vector of SignalStatus instances.
|
|
45 |
*/
|
628
|
46 |
public Vector<SignalStatus> getSignalStatusList() {
|
587
|
47 |
return new Vector<SignalStatus>(signals);
|
|
48 |
}
|
|
49 |
|
|
50 |
/**
|
|
51 |
* Add a SignalStatus object to the list.
|
|
52 |
*
|
|
53 |
* @param status
|
|
54 |
* a signal
|
|
55 |
*/
|
|
56 |
public void addSignalStatus(SignalStatus status) {
|
|
57 |
log.debug("SignalStatusList:addSignalStatus:msg:" + status);
|
|
58 |
signals.add(status);
|
|
59 |
}
|
|
60 |
|
|
61 |
/**
|
|
62 |
* Converts the error list into a user readable message.
|
|
63 |
*
|
|
64 |
* @return the error message.
|
|
65 |
*/
|
|
66 |
public String getErrorMsg() {
|
|
67 |
StringBuffer statusBuffer = new StringBuffer();
|
|
68 |
for (SignalStatus signalStatus : signals) {
|
|
69 |
statusBuffer.append(signalStatus);
|
|
70 |
statusBuffer.append("\n");
|
|
71 |
}
|
|
72 |
log.debug("getErrorMsg:msg:" + statusBuffer.toString());
|
|
73 |
return statusBuffer.toString();
|
|
74 |
}
|
|
75 |
|
|
76 |
/**
|
|
77 |
* Check if it has any pending signals stored.
|
|
78 |
*
|
|
79 |
* @return true if any signal are pending.
|
|
80 |
*/
|
|
81 |
public boolean hasSignalInList() {
|
|
82 |
log.debug("asDeferMsgInList:size:"
|
|
83 |
+ signals.size());
|
|
84 |
return signals.size() > 0;
|
|
85 |
}
|
|
86 |
|
|
87 |
/**
|
|
88 |
* Clear all deferred signals.
|
|
89 |
*/
|
|
90 |
public void clearStatusList() {
|
|
91 |
log.debug("clearStatusList:size1:"
|
|
92 |
+ signals.size());
|
|
93 |
signals.clear();
|
|
94 |
log.debug("clearStatusList:size2:"
|
|
95 |
+ signals.size());
|
|
96 |
}
|
|
97 |
|
|
98 |
/*
|
|
99 |
* Returns the deferred signal list.
|
|
100 |
*/
|
|
101 |
public static SignalStatusList getDeferredSignalList() {
|
|
102 |
return deferSignalList;
|
|
103 |
}
|
|
104 |
|
|
105 |
/*
|
|
106 |
* Returns the now signal list.
|
|
107 |
*/
|
|
108 |
public static SignalStatusList getNowSignalList() {
|
|
109 |
return nowSignalList;
|
|
110 |
}
|
|
111 |
|
|
112 |
/*
|
|
113 |
* Returns the never signal list.
|
|
114 |
*/
|
|
115 |
public static SignalStatusList getNeverSignalList() {
|
|
116 |
return neverSignalList;
|
|
117 |
}
|
|
118 |
|
|
119 |
}
|