ptolemy.moml.filter
Class PortNameChanges

java.lang.Object
  extended by ptolemy.moml.filter.PortNameChanges
All Implemented Interfaces:
MoMLFilter

public class PortNameChanges
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 actors that have had port name changes.

NOTE: This class and ParameterNameChange might conflict if a port and parameter have the same name.

Since:
Ptolemy II 2.0
Version:
$Id: PortNameChanges.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Christopher Hylands, Edward A. Lee
Accepted Rating:
Red (cxh)
Proposed Rating:
Red (cxh)

Field Summary
private static java.util.HashMap _actorsWithPortNameChanges
           
private static java.util.HashMap _containerPortMap
           
private  java.lang.String _currentActorFullName
           
private  boolean _currentlyProcessingActorWithPortNameChanges
           
private  boolean _doneProcessingActorWithPortNameChanges
           
private  java.lang.String _lastNameSeen
           
private static java.util.HashMap _portMap
           
 
Constructor Summary
PortNameChanges()
           
 
Method Summary
static void clear()
          Clear the map of actors with port name changes.
 java.lang.String filterAttributeValue(NamedObj container, java.lang.String element, java.lang.String attributeName, java.lang.String attributeValue, java.lang.String xmlFile)
          If the attributeName is "class" and attributeValue names a class that has had its port names changed between releases, then substitute in the new port names.
 void filterEndElement(NamedObj container, java.lang.String elementName, java.lang.StringBuffer currentCharData, java.lang.String xmlFile)
          Clear recorded state for this element so that it does not interfere with the next element.
 void put(java.lang.String className, java.util.HashMap portNameMap)
          Add a class to be filtered and the old and new port names.
 void remove(java.lang.String className)
          Remove a class to be filtered.
 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
 

Field Detail

_actorsWithPortNameChanges

private static java.util.HashMap _actorsWithPortNameChanges

_containerPortMap

private static java.util.HashMap _containerPortMap

_currentActorFullName

private java.lang.String _currentActorFullName

_currentlyProcessingActorWithPortNameChanges

private boolean _currentlyProcessingActorWithPortNameChanges

_doneProcessingActorWithPortNameChanges

private boolean _doneProcessingActorWithPortNameChanges

_lastNameSeen

private java.lang.String _lastNameSeen

_portMap

private static java.util.HashMap _portMap
Constructor Detail

PortNameChanges

public PortNameChanges()
Method Detail

clear

public static void clear()
Clear the map of actors with port name changes.


filterAttributeValue

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

Specified by:
filterAttributeValue in interface MoMLFilter
Parameters:
container - The container for this attribute. in this method.
element - The XML element name.
attributeName - The name of the attribute.
attributeValue - The value of the attribute.
xmlFile - The file currently being parsed.
Returns:
the value of the attributeValue argument.

filterEndElement

public void filterEndElement(NamedObj container,
                             java.lang.String elementName,
                             java.lang.StringBuffer currentCharData,
                             java.lang.String xmlFile)
                      throws java.lang.Exception
Clear recorded state for this element so that it does not interfere with the next element.

Specified by:
filterEndElement in interface MoMLFilter
Parameters:
container - The object created by this element.
elementName - The element name.
currentCharData - The character data, which appears only in the doc and configure elements
xmlFile - The file currently being parsed, ignored by this method.
Throws:
java.lang.Exception - Not thrown in this base class.

put

public void put(java.lang.String className,
                java.util.HashMap portNameMap)
Add a class to be filtered and the old and new port names. Note that if you add a class with this method, then you must remove it with remove(String), calling "new PortNameChanges()" will not remove a class that was added with this method.

Parameters:
className - The name of the class to be filtered out, for example "ptolemy.copernicus.kernel.GeneratorAttribute".
portNameMap - The HashMap that contains the old port names as keys and the new port names as a values. If the value of the HashMap is null then the rest of the attribute is skipped.
See Also:
remove(String)

remove

public void remove(java.lang.String className)
Remove a class to be filtered.

Parameters:
className - The name of the class to be filtered out, for example "ptolemy.copernicus.kernel.GeneratorAttribute".
See Also:
put(String, HashMap)

toString

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

Specified by:
toString in interface MoMLFilter
Overrides:
toString in class java.lang.Object
Returns:
the description of the filter that ends with a newline.