001/* Filter MoML without using a MoMLParser to parse xml. 002 003 Copyright (c) 2011-2014 The Regents of the University of California. 004 All rights reserved. 005 Permission is hereby granted, without written agreement and without 006 license or royalty fees, to use, copy, modify, and distribute this 007 software and its documentation for any purpose, provided that the above 008 copyright notice and the following two paragraphs appear in all copies 009 of this software. 010 011 IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY 012 FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 013 ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 014 THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF 015 SUCH DAMAGE. 016 017 THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, 018 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 019 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE 020 PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF 021 CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, 022 ENHANCEMENTS, OR MODIFICATIONS. 023 024 PT_COPYRIGHT_VERSION_2 025 COPYRIGHTENDKEY 026 027 */ 028package ptolemy.moml.filter; 029 030import ptolemy.kernel.util.NamedObj; 031import ptolemy.moml.MoMLFilter; 032import ptolemy.moml.MoMLParser; 033 034/////////////////////////////////////////////////////////////////// 035//// MoMLFilterSimple 036 037/** Filter MoML without using a MoMLParser to parse xml generated by the filter. 038 039 @author Christopher Brooks 040 @version $Id$ 041 @since Ptolemy II 10.0 042 @Pt.ProposedRating Red (cxh) 043 @Pt.AcceptedRating Red (cxh) 044 */ 045public abstract class MoMLFilterSimple implements MoMLFilter { 046 047 /** Return the old attribute value for properties that are not registered 048 * to be removed. Otherwise, return null to remove the property. 049 * @param container The container for this attribute. 050 * @param element The XML element name. 051 * @param attributeName The name of the attribute. 052 * @param attributeValue The value of the attribute. 053 * @param xmlFile The file currently being parsed. 054 * @param parser The parser in which MoML is optionally evaluated. Ignored 055 * in this method. 056 * @return The value of the attributeValue argument. 057 */ 058 @Override 059 public String filterAttributeValue(NamedObj container, String element, 060 String attributeName, String attributeValue, String xmlFile, 061 MoMLParser parser) { 062 // Ignore the MoMLParser argument for backward compatibility. 063 return filterAttributeValue(container, element, attributeName, 064 attributeValue, xmlFile); 065 } 066 067 /** Reset private variables. 068 * @param container The object created by this element. 069 * @param elementName The element name. 070 * @param currentCharData The character data, which appears 071 * only in the doc and configure elements 072 * @param xmlFile The file currently being parsed. 073 * @param parser The parser in which MoML is optionally evaluated. 074 * @exception Exception if there is a problem substituting 075 * in the new value. 076 */ 077 @Override 078 public void filterEndElement(NamedObj container, String elementName, 079 StringBuffer currentCharData, String xmlFile, MoMLParser parser) 080 throws Exception { 081 filterEndElement(container, elementName, currentCharData, xmlFile); 082 } 083}