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 |
|
|
18 |
|
|
19 |
package com.nokia.helium.signal.ant.types;
|
|
20 |
|
|
21 |
|
|
22 |
import java.util.Vector;
|
|
23 |
|
628
|
24 |
import org.apache.tools.ant.BuildException;
|
587
|
25 |
import org.apache.tools.ant.types.DataType;
|
|
26 |
|
|
27 |
|
|
28 |
/**
|
|
29 |
* SignalInput class which is a type to store input for signals
|
|
30 |
* Signals..
|
|
31 |
* <targetCondition>
|
|
32 |
* <hasSeverity severity="error" file="${build.cache.log.dir}/signals/prep_work_status.xml" />
|
|
33 |
* </targetCondition>
|
|
34 |
*
|
|
35 |
*/
|
|
36 |
public class SignalNotifierInput extends DataType
|
|
37 |
{
|
|
38 |
private Vector<SignalInput> signalInputs = new Vector<SignalInput>();
|
|
39 |
|
|
40 |
private Vector<NotifierInput> notifierInputList = new Vector<NotifierInput>();
|
|
41 |
|
|
42 |
/**
|
|
43 |
* Helper function called by ant to create a new notifier for
|
|
44 |
* this input.
|
|
45 |
* @return ReferenceType created ReferenceType.
|
|
46 |
*/
|
|
47 |
public NotifierInput createNotifierInput() {
|
|
48 |
NotifierInput notifierInput = new NotifierInput();
|
|
49 |
add(notifierInput);
|
|
50 |
return notifierInput;
|
|
51 |
}
|
|
52 |
|
|
53 |
/**
|
|
54 |
* Adds the created notifier to the list
|
|
55 |
* @param ReferenceType notifier to be added to the list.
|
|
56 |
*/
|
|
57 |
public void add(NotifierInput notifierInput) {
|
|
58 |
if (notifierInput != null) {
|
|
59 |
notifierInputList.add(notifierInput);
|
|
60 |
}
|
|
61 |
}
|
|
62 |
|
|
63 |
/**
|
|
64 |
* Helper function to add the created signalinput
|
|
65 |
* @param filter to be added to the filterset
|
|
66 |
*/
|
|
67 |
public void add(SignalInput input) {
|
|
68 |
signalInputs.add(input);
|
|
69 |
}
|
|
70 |
|
|
71 |
/**
|
|
72 |
* Helper function called by ant to create the new signalinput
|
|
73 |
*/
|
|
74 |
public SignalInput createSignalInput() {
|
|
75 |
SignalInput input = new SignalInput();
|
|
76 |
add(input);
|
|
77 |
return input;
|
|
78 |
}
|
|
79 |
|
|
80 |
public NotifierInput getNotifierInput() {
|
|
81 |
NotifierInput input = null;
|
|
82 |
if (notifierInputList.size() > 1) {
|
|
83 |
throw new BuildException("One and only signal input can be defined");
|
|
84 |
}
|
|
85 |
if (!notifierInputList.isEmpty()) {
|
|
86 |
input = notifierInputList.elementAt(0);
|
|
87 |
}
|
|
88 |
return input;
|
|
89 |
}
|
|
90 |
|
|
91 |
/**
|
|
92 |
* Gets the signal input of this config.
|
|
93 |
* @return signal input stored in the config, by dereferencing the input ref.
|
|
94 |
*/
|
|
95 |
public SignalInput getSignalInput() {
|
|
96 |
if (signalInputs.isEmpty()) {
|
|
97 |
throw new BuildException("No signal input in signal config, failed: ");
|
|
98 |
}
|
|
99 |
if (signalInputs.size() > 1) {
|
|
100 |
throw new BuildException("One and only signal input can be defined");
|
|
101 |
}
|
|
102 |
|
|
103 |
Object refObject = signalInputs.elementAt(0).getRefid().getReferencedObject();
|
|
104 |
if (refObject == null) {
|
|
105 |
throw new BuildException("Signal Input Reference not exists");
|
|
106 |
}
|
|
107 |
|
|
108 |
SignalInput signalInput = (SignalInput)refObject;
|
|
109 |
return signalInput;
|
|
110 |
}
|
|
111 |
} |