ptolemy.moml.filter
Class RemoveGraphicalClasses

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

public class RemoveGraphicalClasses
extends java.lang.Object
implements MoMLFilter

When this class is registered with the MoMLParser.setMoMLFilter() method, it will cause MoMLParser to filter out graphical classes.

This is very useful for running applets with out requiring files like diva.jar to be downloaded. It is also used by the nightly build to run tests when there is no graphical display present.

Since:
Ptolemy II 2.0
Version:
$Id: RemoveGraphicalClasses.java,v 1.32.2.1 2004/06/18 00:49:24 cxh Exp $
Author:
Edward A. Lee, Christopher Hylands
Accepted Rating:
Red (cxh)
Proposed Rating:
Red (cxh)

Constructor Summary
RemoveGraphicalClasses()
           
 
Method Summary
 void clear()
          Clear the map of graphical classes to be removed.
 java.lang.String filterAttributeValue(NamedObj container, java.lang.String attributeName, java.lang.String attributeValue)
          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.
 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.
 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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RemoveGraphicalClasses

public RemoveGraphicalClasses()
Method Detail

clear

public void clear()
Clear the map of graphical classes to be removed.


filterAttributeValue

public java.lang.String filterAttributeValue(NamedObj container,
                                             java.lang.String attributeName,
                                             java.lang.String attributeValue)
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.

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

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

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 with remove(String), calling 'new RemoveGraphicalClasses' 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 interface MoMLFilter
Returns:
the description of the filter that ends with a newline.