buildframework/helium/sf/java/signaling/src/com/nokia/helium/signal/ant/types/SignalNotifierInput.java
author wbernard
Fri, 13 Aug 2010 14:59:05 +0300
changeset 628 7c4a911dc066
parent 587 85df38eb4012
child 645 b8d81fa19e7d
permissions -rw-r--r--
helium_11.0.0-e00f171ca185
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     1
/*
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     2
* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     3
* All rights reserved.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     4
* This component and the accompanying materials are made available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     6
* which accompanies this distribution, and is available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     8
*
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     9
* Initial Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    11
*
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    12
* Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    13
*
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    14
* Description:  
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    15
*
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    16
*/
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    17
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    18
 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    19
package com.nokia.helium.signal.ant.types;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    20
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    21
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    22
import java.util.Vector;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    23
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    24
import org.apache.tools.ant.BuildException;
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    25
import org.apache.tools.ant.types.DataType;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    26
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    27
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    28
/**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    29
 * SignalInput class which is a type to store input for signals
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    30
 * Signals..
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    31
 * <targetCondition>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    32
 *    <hasSeverity severity="error" file="${build.cache.log.dir}/signals/prep_work_status.xml" />
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    33
 * </targetCondition>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    34
 * 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    35
 */
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    36
public class SignalNotifierInput extends DataType
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    37
{
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    38
    private Vector<SignalInput> signalInputs = new Vector<SignalInput>();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    39
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    40
    private Vector<NotifierInput> notifierInputList = new Vector<NotifierInput>();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    41
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    42
    /**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    43
     * Helper function called by ant to create a new notifier for
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    44
     * this input.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    45
     * @return ReferenceType created ReferenceType.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    46
     */    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    47
    public NotifierInput createNotifierInput() {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    48
        NotifierInput notifierInput =  new NotifierInput();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    49
        add(notifierInput);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    50
        return notifierInput;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    51
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    52
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    53
    /**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    54
     * Adds the created notifier to the list
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    55
     * @param ReferenceType notifier to be added to the list.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    56
     */    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    57
    public void add(NotifierInput notifierInput) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    58
        if (notifierInput != null) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    59
            notifierInputList.add(notifierInput);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    60
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    61
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    62
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    63
    /**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    64
     * Helper function to add the created signalinput
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    65
     * @param filter to be added to the filterset
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    66
     */
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    67
    public void add(SignalInput input) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    68
        signalInputs.add(input);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    69
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    70
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    71
    /**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    72
     * Helper function called by ant to create the new signalinput
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    73
     */
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    74
    public SignalInput createSignalInput() {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    75
        SignalInput input =  new SignalInput();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    76
        add(input);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    77
        return input;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    78
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    79
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    80
    public NotifierInput getNotifierInput() {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    81
        NotifierInput input = null;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    82
        if (notifierInputList.size() > 1) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    83
            throw new BuildException("One and only signal input can be defined");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    84
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    85
        if (!notifierInputList.isEmpty()) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    86
            input = notifierInputList.elementAt(0);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    87
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    88
        return input;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    89
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    90
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    91
    /**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    92
     * Gets the signal input of this config.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    93
     * @return signal input stored in the config, by dereferencing the input ref. 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    94
     */    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    95
    public SignalInput getSignalInput() {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    96
        if (signalInputs.isEmpty()) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    97
            throw new BuildException("No signal input in signal config, failed: ");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    98
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    99
        if (signalInputs.size() > 1) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   100
            throw new BuildException("One and only signal input can be defined");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   101
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   102
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   103
        Object refObject =  signalInputs.elementAt(0).getRefid().getReferencedObject();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   104
        if (refObject == null) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   105
            throw new BuildException("Signal Input Reference not exists");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   106
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   107
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   108
        SignalInput signalInput = (SignalInput)refObject;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   109
        return signalInput;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   110
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   111
}