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 * NOTE: This should eventually be more generic, i.e., specify a conversion 039 * across multiple ports involed in a mapping. This would require "lifting" this 040 * attribute to a similar level as a SimpleMergeMapping attribute. 041 * 042 * @author Shawn Bowers 043 * @created October 17, 2005 044 */ 045 046public class SimpleMergeConversion extends StringAttribute { 047 048 /** 049 * Constructor 050 */ 051 public SimpleMergeConversion(NamedObj container, String name) 052 throws IllegalActionException, NameDuplicationException { 053 super(container, name); 054 } 055 056 /** 057 * @return The name of the conversion used 058 */ 059 public String getConversion() { 060 return getExpression(); 061 } 062 063 /** 064 * Set the conversion to use 065 */ 066 public void setConversion(String name) throws IllegalActionException { 067 setExpression(name); 068 } 069 070 /** 071 * Set the container of the virtual port to the given container. This method 072 * fails, in addition to the normal ptolemy constraints for setting 073 * containers, if the given container is not a ptolemy.kernel.Entity object. 074 * 075 * @param container 076 * The container for this virtual port. 077 */ 078 public void setContainer(NamedObj container) throws IllegalActionException, 079 NameDuplicationException { 080 if (!(container instanceof SimpleMergeMapping)) { 081 String msg = "This attribute can only be applied to " 082 + "org.Kepler.sms.actor.SimpleMergeMapping instances."; 083 throw new IllegalActionException(this, msg); 084 } 085 super.setContainer(container); 086 } 087 088} // SimpleMergeConversion