001/* 002 * Copyright (c) 2010 The Regents of the University of California. 003 * All rights reserved. 004 * 005 * 006 * Permission is hereby granted, without written agreement and without 007 * license or royalty fees, to use, copy, modify, and distribute this 008 * software and its documentation for any purpose, provided that the above 009 * copyright notice and the following two paragraphs appear in all copies 010 * of this software. 011 * 012 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY 013 * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 014 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 015 * THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF 016 * SUCH DAMAGE. 017 * 018 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, 019 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 020 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE 021 * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF 022 * CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, 023 * ENHANCEMENTS, OR MODIFICATIONS. 024 * 025 */ 026 027package org.kepler.util; 028 029import java.io.IOException; 030import java.io.Writer; 031 032import ptolemy.kernel.util.IllegalActionException; 033import ptolemy.kernel.util.NameDuplicationException; 034import ptolemy.kernel.util.NamedObj; 035import ptolemy.kernel.util.Settable; 036import ptolemy.kernel.util.StringAttribute; 037import ptolemy.kernel.util.Workspace; 038 039/** 040 * This is a string attribute that overrides the exportMoML method to 041 * effectively remove it (and any children) from MoML generated by the parent 042 * NamedObj. Also, the visibility is set to NONE by default. 043 * 044 * @author Aaron Schultz 045 */ 046public class TransientStringAttribute extends StringAttribute { 047 /** 048 * Construct an attribute in the default workspace with an empty string as 049 * its name. The object is added to the directory of the workspace. 050 * Increment the version number of the workspace. 051 */ 052 public TransientStringAttribute() { 053 super(); 054 setVisibility(Settable.NONE); 055 } 056 057 /** 058 * Construct an attribute in the specified workspace with an empty string as 059 * a name. The object is added to the directory of the workspace. Increment 060 * the version number of the workspace. 061 * 062 * @param workspace 063 * The workspace that will list the attribute. 064 */ 065 public TransientStringAttribute(Workspace workspace) { 066 super(workspace); 067 setVisibility(Settable.NONE); 068 } 069 070 /** 071 * Construct an attribute with the given name contained by the specified 072 * container. The container argument must not be null, or a 073 * NullPointerException will be thrown. This attribute will use the 074 * workspace of the container for synchronization and version counts. If the 075 * name argument is null, then the name is set to the empty string. The 076 * object is added to the directory of the workspace if the container is 077 * null. Increment the version of the workspace. 078 * 079 * @param container 080 * The container. 081 * @param name 082 * The name of this attribute. 083 * @exception IllegalActionException 084 * If the attribute is not of an acceptable class for the 085 * container, or if the name contains a period. 086 * @exception NameDuplicationException 087 * If the name coincides with an attribute already in the 088 * container. 089 */ 090 public TransientStringAttribute(NamedObj container, String name) 091 throws IllegalActionException, NameDuplicationException { 092 super(container, name); 093 setVisibility(Settable.NONE); 094 } 095 096 /** 097 * Here we override the exportMoML method so this attribute and any children 098 * of this attribute are not included in the MoML. 099 */ 100 @Override 101 public void exportMoML(Writer output, int depth, String name) 102 throws IOException { 103 // super.exportMoML(output, depth, name); 104 } 105 106}