ptolemy.domains.properties.kernel
Class ModelAttribute

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.util.Attribute
          extended by ptolemy.domains.properties.kernel.ModelAttribute
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Changeable, Configurable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable
Direct Known Subclasses:
OntologyAttribute, PropertyLatticeAttribute

public class ModelAttribute
extends Attribute
implements Configurable

A base class for attributes that contain a refinement model graph.

Note that this class expects that ptolemy.vergil.properties.ModelAttributeControllerFactory will be used as the _controllerFactory of this class. Instead of having an explicit compile-time dependency between this class and ModelAttributeControllerFactory, derived classes should use MoML to set up the containment relationship. For example, ptII/ptolemy/configs/properties/propertiesConfigurableSolvers.xml contains:

 
     
     
 
 
All classes that derive from this class should use a similar pattern.

Since:
Ptolemy II 7.1
Version:
$Id: ModelAttribute.java 56282 2009-11-24 05:36:56Z cxh $
Author:
Man-Kit Leung
See Also:
Serialized Form
Accepted Rating:
Red (tfeng)
Proposed Rating:
Red (tfeng)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
 
Field Summary
private  Configurer _configurer
           
private  java.lang.String _configureSource
           
private  CompositeEntity _model
           
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Constructor Summary
ModelAttribute(NamedObj container, java.lang.String name)
          Create a model attribute with the specified container and name.
ModelAttribute(Workspace workspace)
          Construct an attribute in the specified workspace with an empty string as a name.
ModelAttribute(Workspace workspace, java.lang.String name)
          Construct an attribute in the specified workspace with the specified name.
 
Method Summary
private static void _clearURI(NamedObj object)
           
protected  void _exportMoMLContents(java.io.Writer output, int depth)
          Write a MoML description of the contents of this object.
protected  java.lang.String _getContainedModelClassName()
          Return the class name of the contained model.
private  void _init()
           
 java.lang.Object clone(Workspace workspace)
          Return a clone of this model attribute.
 void configure(java.net.URL base, java.lang.String source, java.lang.String text)
          Construct and configure the contained model with the specified source and text.
 java.lang.String getConfigureSource()
          Return the configure source.
 java.lang.String getConfigureText()
          Return the configure text.
 CompositeEntity getContainedModel()
          Return the contained model.
 
Methods inherited from class ptolemy.kernel.util.Attribute
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setContainer, setName, updateContent
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _description, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, 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, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_configureSource

private java.lang.String _configureSource

_configurer

private Configurer _configurer

_model

private CompositeEntity _model
Constructor Detail

ModelAttribute

public ModelAttribute(NamedObj container,
                      java.lang.String name)
               throws NameDuplicationException,
                      IllegalActionException
Create a model attribute with the specified container and name.

Parameters:
container - The specified container.
name - The specified name.
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.

ModelAttribute

public ModelAttribute(Workspace workspace)
Construct an attribute in the specified workspace with an empty string as a name. If the workspace argument is null, then use the default workspace. The object is added to the directory of the workspace.

Parameters:
workspace - The workspace that will list the attribute.

ModelAttribute

public ModelAttribute(Workspace workspace,
                      java.lang.String name)
Construct an attribute in the specified workspace with the specified name. If the workspace argument is null, then use the default workspace. The object is added to the directory of the workspace.

Parameters:
workspace - The workspace that will list the attribute.
name - The specified name.
Method Detail

clone

public java.lang.Object clone(Workspace workspace)
                       throws java.lang.CloneNotSupportedException
Return a clone of this model attribute. This also creates a clone for the contained model.

Overrides:
clone in class Attribute
Parameters:
workspace - The workspace for the cloned object.
Returns:
A clone.
Throws:
java.lang.CloneNotSupportedException - Thrown if an error occurs while cloning the attribute or the contained model.
See Also:
NamedObj.exportMoML(Writer, int, String), NamedObj.setDeferringChangeRequests(boolean)

configure

public void configure(java.net.URL base,
                      java.lang.String source,
                      java.lang.String text)
               throws java.lang.Exception
Construct and configure the contained model with the specified source and text. It parses the specified MoML text and clear clears the URI information from the constructed model.

Specified by:
configure in interface Configurable
Parameters:
base - The base URL for relative references, or null if not known.
source - The URI of the document.
text - The MoML description.
Throws:
java.lang.Exception - If the parsing fails or the URI info cannot be cleared.

getConfigureSource

public java.lang.String getConfigureSource()
Return the configure source.

Specified by:
getConfigureSource in interface Configurable
Returns:
The configure source.

getConfigureText

public java.lang.String getConfigureText()
Return the configure text. In this base class, this returns null.

Specified by:
getConfigureText in interface Configurable
Returns:
The configure text.

getContainedModel

public CompositeEntity getContainedModel()
Return the contained model.

Returns:
The contained model.

_exportMoMLContents

protected void _exportMoMLContents(java.io.Writer output,
                                   int depth)
                            throws java.io.IOException
Write a MoML description of the contents of this object. This wraps the MoML description of the contained model within the <configure> tag.

Overrides:
_exportMoMLContents in class NamedObj
Parameters:
output - The output stream to write to.
depth - The depth in the hierarchy, to determine indenting.
Throws:
java.io.IOException - If an I/O error occurs.
See Also:
NamedObj.exportMoML(Writer, int)

_getContainedModelClassName

protected java.lang.String _getContainedModelClassName()
Return the class name of the contained model. The class name is used to instantiate the contained model. By default, this returns the string "ptolemy.actor.CompositeActor". If base classes can override this method to instantiate a different type of top-level for the contained model.

Returns:
the class name of the contained model.

_clearURI

private static void _clearURI(NamedObj object)
                       throws IllegalActionException,
                              NameDuplicationException
Throws:
IllegalActionException
NameDuplicationException

_init

private void _init()
            throws IllegalActionException,
                   NameDuplicationException
Throws:
IllegalActionException
NameDuplicationException