Package ptolemy.moml.filter
Class RemoveClasses
- java.lang.Object
-
- ptolemy.moml.filter.MoMLFilterSimple
-
- ptolemy.moml.filter.RemoveClasses
-
- All Implemented Interfaces:
MoMLFilter
public class RemoveClasses extends MoMLFilterSimple
When this class is registered with the MoMLParser.addMoMLFilter() method, it will cause MoMLParser to remove or replace classes.Note that that in the default, this class has an empty list of classes to be removed or replaced. To add classes to be removed, call put("my.class.to.be.removed", null).
This class is not added to the list of filters in BackwardCompatibility, it must be added by calling {#link ptolemy.moml.MoMLParser.addMoMLFilter(MoMLFilter)
- Since:
- Ptolemy II 8.0
- Version:
- $Id$
- Author:
- Edward A. Lee, Christopher Hylands
- Pt.AcceptedRating:
- Red (cxh)
- Pt.ProposedRating:
- Red (cxh)
-
-
Constructor Summary
Constructors Constructor Description RemoveClasses()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
clear()
Clear the map of graphical classes to be removed.java.lang.String
filterAttributeValue(NamedObj container, java.lang.String element, java.lang.String attributeName, java.lang.String attributeValue, java.lang.String xmlFile)
Filter for graphical classes and return new values if a graphical class is found.void
filterEndElement(NamedObj container, java.lang.String elementName, java.lang.StringBuffer currentCharData, java.lang.String xmlFile)
In this class, do nothing.void
put(java.lang.String className, java.lang.String replacement)
Add a class to be filtered for and its replacement if the class is found.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 graphical classes to be removed.
-
filterAttributeValue
public java.lang.String filterAttributeValue(NamedObj container, java.lang.String element, java.lang.String attributeName, java.lang.String attributeValue, java.lang.String xmlFile)
Filter for graphical classes and return new values if a graphical class is found. An internal HashMap maps names of graphical entities to new names. The HashMap can also map a graphical entity to null, which means the entity is removed from the model. All class attributeValues that start with "ptolemy.domains.gr" are deemed to be graphical elements and null is always returned. For example, if the attributeValue is "ptolemy.vergil.icon.ValueIcon", or "ptolemy.vergil.basic.NodeControllerFactory" then return "ptolemy.kernel.util.Attribute"; if the attributeValue is "ptolemy.vergil.icon.AttributeValueIcon" or "ptolemy.vergil.icon.BoxedValueIcon" then return null, which will cause the MoMLParser to skip the rest of the element; otherwise return the original value of the attributeValue.- Parameters:
container
- The container for this attribute, ignored in this method.element
- The XML element name.attributeName
- The name of the attribute, ignored in this method.attributeValue
- The value of the attribute.xmlFile
- The file currently being parsed.- Returns:
- the filtered attributeValue.
-
filterEndElement
public void filterEndElement(NamedObj container, java.lang.String elementName, java.lang.StringBuffer currentCharData, java.lang.String xmlFile) throws java.lang.Exception
In this class, do nothing.- 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
- Not thrown in this base class.
-
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, String)
-
put
public void put(java.lang.String className, java.lang.String replacement)
Add a class to be filtered for and its replacement if the class is found. If the replacement is null, then the rest of the attribute is skipped. Note that if you add a class with this method, then you must remove it withremove(String)
, calling 'new RemoveClasses' 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".replacement
- The name of the class to be used if className is found. If this argument is null then the rest of the attribute is skipped.- See Also:
remove(String)
-
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.
-
-