001/*
002 * Copyright (c) 2005-2010 The Regents of the University of California.
003 * All rights reserved.
004 *
005 * '$Author: welker $'
006 * '$Date: 2010-05-06 05:21:26 +0000 (Thu, 06 May 2010) $' 
007 * '$Revision: 24234 $'
008 * 
009 * Permission is hereby granted, without written agreement and without
010 * license or royalty fees, to use, copy, modify, and distribute this
011 * software and its documentation for any purpose, provided that the above
012 * copyright notice and the following two paragraphs appear in all copies
013 * of this software.
014 *
015 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
016 * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
017 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
018 * THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
019 * SUCH DAMAGE.
020 *
021 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
022 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
023 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
024 * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
025 * CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
026 * ENHANCEMENTS, OR MODIFICATIONS.
027 *
028 */
029
030package org.kepler.sms.actors;
031
032import ptolemy.kernel.util.IllegalActionException;
033import ptolemy.kernel.util.NameDuplicationException;
034import ptolemy.kernel.util.NamedObj;
035import ptolemy.kernel.util.StringAttribute;
036
037/**
038 * 
039 * @author Shawn Bowers
040 * @created October 17, 2005
041 */
042
043public class SimpleMergeTargetPort extends StringAttribute {
044
045        /**
046         * Constructor
047         * 
048         * @param container
049         *            Description of the Parameter
050         * @param name
051         *            The value of the property
052         * @exception IllegalActionException
053         *                Description of the Exception
054         * @exception NameDuplicationException
055         *                Description of the Exception
056         */
057        public SimpleMergeTargetPort(NamedObj container, String name)
058                        throws IllegalActionException, NameDuplicationException {
059                super(container, name);
060        }
061
062        /**
063         * @return The target port name
064         */
065        public String getTargetPort() {
066                return getExpression();
067        }
068
069        /**
070         * Sets the target port name
071         */
072        public void setTargetPort(String name) throws IllegalActionException {
073                setExpression(name);
074        }
075
076        /**
077         * Set the container of the virtual port to the given container. This method
078         * fails, in addition to the normal ptolemy constraints for setting
079         * containers, if the given container is not a ptolemy.kernel.Entity object.
080         * 
081         * @param container
082         *            The container for this virtual port.
083         */
084        public void setContainer(NamedObj container) throws IllegalActionException,
085                        NameDuplicationException {
086                if (!(container instanceof SimpleMergeMapping)) {
087                        String msg = "This attribute can only be applied to "
088                                        + "org.Kepler.sms.actor.SimpleMergeMapping instances.";
089                        throw new IllegalActionException(this, msg);
090                }
091                super.setContainer(container);
092        }
093
094} // SimpleMergeTargetPort