Package ptolemy.copernicus.kernel
Class GeneratorAttribute
- java.lang.Object
 - 
- ptolemy.kernel.util.NamedObj
 - 
- ptolemy.kernel.util.Attribute
 - 
- ptolemy.kernel.util.SingletonAttribute
 - 
- ptolemy.copernicus.kernel.GeneratorAttribute
 
 
 
 
 
- 
- All Implemented Interfaces:
 java.lang.Cloneable,Changeable,ChangeListener,Debuggable,DebugListener,Derivable,ModelErrorHandler,MoMLExportable,Moveable,Nameable,Singleton
- Direct Known Subclasses:
 GeneratorTableauAttribute
public class GeneratorAttribute extends SingletonAttribute implements ChangeListener
This is an attribute that stores the configuration of a code generator.The initial default parameters, their values and their documentation are read in from a MoML file specified by the initialParametersURL. Having the parameters defined in a MoML file allows us to easily add and modify parameters without lots of bookkeeping.
To view the initial default parameters, either call toString(), or run:
java -classpath $PTII ptolemy.copernicus.kernel.Copernicus -help
- Since:
 - Ptolemy II 2.0
 - Version:
 - $Id$
 - Author:
 - Edward A. Lee, Christopher Hylands
 - Pt.AcceptedRating:
 - Red (johnr)
 - Pt.ProposedRating:
 - Red (eal)
 
 
- 
- 
Nested Class Summary
- 
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator 
 - 
 
- 
Field Summary
Fields Modifier and Type Field Description StringParameterinitialParametersURLMoML file that contains other parameters.- 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS 
 - 
 
- 
Constructor Summary
Constructors Constructor Description GeneratorAttribute(NamedObj container, java.lang.String name)Construct an attribute with the given name contained by the specified entity. 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidchangeExecuted(ChangeRequest change)React to a change request has been successfully executed.voidchangeFailed(ChangeRequest change, java.lang.Exception exception)React to a change request has resulted in an exception.java.lang.StringgetParameter(java.lang.String name)Get the string for the argument with the given name from this GeneratorAttribute.booleanhasParameter(java.lang.String name)Return true if a parameter with the given name is defined in this GeneratorAttribute.voidinitialize()If this GeneratorAttribute has not yet been initialized, the initialized it by reading the moml file named by the initialParametersURL and creating Parameters and Variables accordingly.static java.lang.StringlookupClassAsResource(java.lang.String necessaryClass)Deprecated.Call ptolemy.util.ClassUtilities.lookupClassAsResource() instead;voidsanityCheckAndUpdateParameters(java.lang.String modelPathOrURL)voidsetParameter(java.lang.String name, java.lang.String value)Set the string for the argument with the given name from this GeneratorAttribute to be the given value.java.lang.StringtoString()Return a String representation of this object.voidupdateModelAttributes(java.lang.String modelPathOrURL)Update the modelPath, modelName and iterations parameters in the GeneratorAttribute.- 
Methods inherited from class ptolemy.kernel.util.SingletonAttribute
setContainer 
- 
Methods inherited from class ptolemy.kernel.util.Attribute
_checkContainer, _getContainedObject, _propagateExistence, clone, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent 
- 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _description, _executeChangeRequests, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeChanged, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, uniqueName, validateSettables, workspace 
 - 
 
 - 
 
- 
- 
Field Detail
- 
initialParametersURL
public StringParameter initialParametersURL
MoML file that contains other parameters. The default value is the string "ptolemy/copernicus/kernel/Generator.xml". 
 - 
 
- 
Constructor Detail
- 
GeneratorAttribute
public GeneratorAttribute(NamedObj container, java.lang.String name) throws IllegalActionException, NameDuplicationException
Construct an attribute with the given name contained by the specified entity. The container argument must not be null, or a NullPointerException will be thrown. This attribute will use the workspace of the container for synchronization and version counts. If the name argument is null, then the name is set to the empty string. Increment the version of the workspace.- Parameters:
 container- The container.name- The name of this attribute.- Throws:
 IllegalActionException- If the attribute is not of an acceptable class for the container, or if the name contains a period.NameDuplicationException- If the name coincides with an attribute already in the container.
 
 - 
 
- 
Method Detail
- 
changeExecuted
public void changeExecuted(ChangeRequest change)
Description copied from interface:ChangeListenerReact to a change request has been successfully executed. This method is called after a change request has been executed successfully.- Specified by:
 changeExecutedin interfaceChangeListener- Parameters:
 change- The change that has been executed, or null if the change was not done via a ChangeRequest.
 
- 
changeFailed
public void changeFailed(ChangeRequest change, java.lang.Exception exception)
Description copied from interface:ChangeListenerReact to a change request has resulted in an exception. This method is called after a change request was executed, but during the execution an exception was thrown.- Specified by:
 changeFailedin interfaceChangeListener- Parameters:
 change- The change that was attempted or null if the change was not done via a ChangeRequest.exception- The exception that resulted.
 
- 
getParameter
public java.lang.String getParameter(java.lang.String name) throws IllegalActionExceptionGet the string for the argument with the given name from this GeneratorAttribute.- Throws:
 IllegalActionException- If no Settable object with the given name exists in this GeneratorAttribute.
 
- 
hasParameter
public boolean hasParameter(java.lang.String name) throws IllegalActionExceptionReturn true if a parameter with the given name is defined in this GeneratorAttribute.- Throws:
 IllegalActionException
 
- 
initialize
public void initialize() throws IllegalActionException, NameDuplicationExceptionIf this GeneratorAttribute has not yet been initialized, the initialized it by reading the moml file named by the initialParametersURL and creating Parameters and Variables accordingly. 
- 
lookupClassAsResource
@Deprecated public static java.lang.String lookupClassAsResource(java.lang.String necessaryClass)
Deprecated.Call ptolemy.util.ClassUtilities.lookupClassAsResource() instead;Given a dot separated classname, return the jar file or directory where the class can be found.- Parameters:
 necessaryClass- The dot separated class name, for example "ptolemy.kernel.util.NamedObj"- Returns:
 - If the class can be found as a resource, return the directory or jar file where the necessary class can be found. otherwise, return null.
 
 
- 
sanityCheckAndUpdateParameters
public void sanityCheckAndUpdateParameters(java.lang.String modelPathOrURL) throws IllegalActionException, NameDuplicationException 
- 
setParameter
public void setParameter(java.lang.String name, java.lang.String value) throws IllegalActionExceptionSet the string for the argument with the given name from this GeneratorAttribute to be the given value.- Throws:
 IllegalActionException- If no Settable object with the given name exists in this GeneratorAttribute.
 
- 
toString
public java.lang.String toString()
Return a String representation of this object. 
- 
updateModelAttributes
public void updateModelAttributes(java.lang.String modelPathOrURL) throws IllegalActionExceptionUpdate the modelPath, modelName and iterations parameters in the GeneratorAttribute. This method parses the model and updates all GeneratorAttribute parameters that are determined by the model itself.- Parameters:
 modelPathOrURL- The file pathname or URL to the model.- Throws:
 IllegalActionException
 
 - 
 
 -