public class PropertyClassChanges extends MoMLFilterSimple
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.
Red (cxh) |
Red (cxh) |
Constructor and Description |
---|
PropertyClassChanges() |
Modifier and Type | Method and 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.
|
filterAttributeValue, filterEndElement
public static void clear()
public java.lang.String filterAttributeValue(NamedObj container, java.lang.String element, java.lang.String attributeName, java.lang.String attributeValue, java.lang.String xmlFile)
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.public void filterEndElement(NamedObj container, java.lang.String elementName, java.lang.StringBuffer currentCharData, java.lang.String xmlFile) throws java.lang.Exception
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.java.lang.Exception
- if there is a problem substituting
in the new value.public void put(java.lang.String className, java.util.HashMap propertyClassMap)
remove(String)
, calling
"new PropertyClassChanges()" will not remove a class that was
added with this method.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.remove(String)
public void remove(java.lang.String className)
className
- The name of the class to be filtered
out, for example "ptolemy.copernicus.kernel.GeneratorAttribute".put(String, HashMap)
public java.lang.String toString()
toString
in interface MoMLFilter
toString
in class java.lang.Object