ptolemy.moml.filter
Class ParameterNameChanges

java.lang.Object
  extended byptolemy.moml.filter.ParameterNameChanges
All Implemented Interfaces:
MoMLFilter

public class ParameterNameChanges
extends java.lang.Object
implements MoMLFilter

When this class is registered with the MoMLParser.setMoMLFilter() method, it will cause MoMLParser to filter so that models from earlier releases will run in the current release.

This class will filter for classes with Parameters where the parameter name has changed.

For example, after Ptolemy II 2.2, the PNDirector changed in such a way that the 'Initial_queue_capacity' parameter is now 'initialQueueCapacity'.

To add this change to this filter, we add a code to the static section at the bottom of the file.

    // PNDirectory: After 2.2, 'Initial_queue_capacity'
    // property is now 'initialQueueCapacity'

    HashMap pnDirectorChanges = new HashMap();
    // Key = property name, Value = new class name
    pnDirectorChanges.put("Initial_queue_capacity",
    "initialQueueCapacity");
    
The pnDirectorChange HashMap maps property names to the new name

    _classesWithParameterNameChanges
    .put("ptolemy.domains.pn.PNDirectory",
    pnDirectorChanges);
    
The _classesWithParameterNameChanges HashMap contains all the classes such as PNDirectory that have changes and each class has a map of the Parameter changes that are to be made.

Conceptually, how the code works is that when we see a class while parsing, we check to see if the class is in _classesWithParameterNameChanges. If the class was present in the HashMap, then as we go through the code, we look for property names that need to have their classes changed.

Since:
Ptolemy II 2.2
Version:
$Id: ParameterNameChanges.java,v 1.9 2004/04/23 03:22:56 cxh Exp $
Author:
Christopher Hylands
Accepted Rating:
Red (cxh)
Proposed Rating:
Red (cxh)

Constructor Summary
ParameterNameChanges()
           
 
Method Summary
 java.lang.String filterAttributeValue(NamedObj container, java.lang.String attributeName, java.lang.String attributeValue)
          If the attributeName is "class" and attributeValue names a class that has had a Parameter names changed between releases, then substitute in the new Parameter names.
 java.lang.String filterEndElement(NamedObj container, java.lang.String elementName)
          Given the elementName, perform any filter operations that are appropriate for the MOMLParser.endElement() method.
 java.lang.String toString()
          Return a string that describes what the filter does.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ParameterNameChanges

public ParameterNameChanges()
Method Detail

filterAttributeValue

public java.lang.String filterAttributeValue(NamedObj container,
                                             java.lang.String attributeName,
                                             java.lang.String attributeValue)
If the attributeName is "class" and attributeValue names a class that has had a Parameter names changed between releases, then substitute in the new Parameter names.

Specified by:
filterAttributeValue in interface MoMLFilter
Parameters:
container - The container for this attribute. in this method.
attributeName - The name of the attribute.
attributeValue - The value of the attribute.
Returns:
the value of the attributeValue argument.

filterEndElement

public java.lang.String filterEndElement(NamedObj container,
                                         java.lang.String elementName)
                                  throws java.lang.Exception
Given the elementName, perform any filter operations that are appropriate for the MOMLParser.endElement() method.

Specified by:
filterEndElement in interface MoMLFilter
Parameters:
container - The container for this attribute. in this method.
elementName - The element type name.
Returns:
the filtered element name, or null if MoMLParser.endElement() should immediately return.
Throws:
java.lang.Exception

toString

public java.lang.String toString()
Return a string that describes what the filter does.

Specified by:
toString in interface MoMLFilter
Returns:
the description of the filter that ends with a newline.