Package ptolemy.moml.filter
Class PropertyClassChanges
- java.lang.Object
-
- ptolemy.moml.filter.MoMLFilterSimple
-
- ptolemy.moml.filter.PropertyClassChanges
-
- All Implemented Interfaces:
MoMLFilter
public class PropertyClassChanges extends MoMLFilterSimple
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 properties where the class name has changed.
For example, after Ptolemy II 2.0.1, the Expression actor changed in such a way that the expression property changed from being a Parameter to being a StringAttribute. To add this change to this filter, we add a code to the static section at the bottom of the file.
// Expression: After 2.0.1, expression // property is now a StringAttribute HashMap expressionClassChanges = new HashMap(); // Key = property name, Value = new class name expressionClassChanges.put("expression", "ptolemy.kernel.util.StringAttribute");
The expressionClassChange HashMap maps property names to the new classname_actorsWithPropertyClassChanges .put("ptolemy.actor.lib.Expression", expressionClassChanges);
The _actorsWithPropertyClassChanges HashMap contains all the classes such as Expression that have changes and each class has a map of the property 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 _actorsWithPropertyClassChanges. 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.0
- Version:
- $Id$
- Author:
- Christopher Hylands, Edward A. Lee
- Pt.AcceptedRating:
- Red (cxh)
- Pt.ProposedRating:
- Red (cxh)
-
-
Constructor Summary
Constructors Constructor Description PropertyClassChanges()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
clear()
Clear the map of actors with property class changes.java.lang.String
filterAttributeValue(NamedObj container, java.lang.String element, java.lang.String attributeName, java.lang.String attributeValue, java.lang.String xmlFile)
Return new class names for properties that have been registered as having changed classes.void
filterEndElement(NamedObj container, java.lang.String elementName, java.lang.StringBuffer currentCharData, java.lang.String xmlFile)
Reset private variables.void
put(java.lang.String className, java.util.HashMap propertyClassMap)
Add a class to be filtered and the old and new property class types.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 ptolemy.moml.filter.MoMLFilterSimple
filterAttributeValue, filterEndElement
-
-
-
-
Method Detail
-
clear
public static void clear()
Clear the map of actors with property class 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)
Return new class names for properties that have been registered as having changed classes. This filter may also return null to remove the element.- 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 or a new value if the value has changed.
-
filterEndElement
public void filterEndElement(NamedObj container, java.lang.String elementName, java.lang.StringBuffer currentCharData, java.lang.String xmlFile) throws java.lang.Exception
Reset private variables.- Parameters:
container
- The object created by this element.elementName
- The element name.currentCharData
- The character data, which appears only in the doc and configure elementsxmlFile
- The file currently being parsed.- Throws:
java.lang.Exception
- if there is a problem substituting in the new value.
-
put
public void put(java.lang.String className, java.util.HashMap propertyClassMap)
Add a class to be filtered and the old and new property class types. Note that if you add a class with this method, then you must remove it withremove(String)
, calling "new PropertyClassChanges()" 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".propertyClassMap
- The HashMap that has the property name as a key and the new class name as a value. 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 interfaceMoMLFilter
- Overrides:
toString
in classjava.lang.Object
- Returns:
- the description of the filter that ends with a newline.
-
-