ptolemy.moml
Class LibraryAttribute
java.lang.Object
ptolemy.kernel.util.NamedObj
ptolemy.kernel.util.Attribute
ptolemy.kernel.util.ConfigurableAttribute
ptolemy.moml.LibraryAttribute
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, Changeable, Configurable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable, Settable
public class LibraryAttribute
- extends ConfigurableAttribute
This class is a configurable singleton attribute that associates a
component library with a model. By convention, it is typically named
"_library". A visual editor that opens a model containing this attribute
will offer the contents of its library as the component library for editing
the model. "Singleton" means that if this attribute is placed in a model,
it will replace any previous singleton attribute that has the same name.
"Configurable" means that the contents of the library can be set in
a configure element in MoML, or via the configure() method.
The library can also be set by calling setLibrary(); this will override
any library specified by configure.
When creating a library to associate with this attribute, the
library should be created in the same workspace as this attribute
(as returned by the workspace() method). Normally, it will have no
container. The text specified in the configure element (or a call
to the configure() method) is not parsed until the getLibrary()
method is called. Thus, the overhead of creating the library is
avoided if the library is not used.
- Since:
- Ptolemy II 1.0
- Version:
- $Id: LibraryAttribute.java 57040 2010-01-27 20:52:32Z cxh $
- Author:
- Edward A. Lee
- See Also:
- Serialized Form
- Accepted Rating:
- Proposed Rating:
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 |
LibraryAttribute()
Construct a new attribute with no
container and an empty string as its name. |
LibraryAttribute(NamedObj container,
java.lang.String name)
Construct an attribute with the given container and name. |
LibraryAttribute(Workspace workspace)
Construct a new attribute with
no container and an empty string as a name. |
Method Summary |
CompositeEntity |
getLibrary()
Return the library specified by the configure() method or the
setLibrary() method, or null if it has not been set. |
void |
setLibrary(CompositeEntity library)
Specify the library, overriding any library that might have been
or might later be specified by a call to configure(). |
Methods inherited from class ptolemy.kernel.util.ConfigurableAttribute |
_exportMoMLContents, _propagateValue, addValueListener, clone, configure, getBase, getConfigureSource, getConfigureText, getDefaultExpression, getDisplayName, getExpression, getValueAsString, getVisibility, removeValueListener, setDisplayName, setExpression, setVisibility, validate, value |
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, _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, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, 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 |
_library
private CompositeEntity _library
_librarySet
private boolean _librarySet
LibraryAttribute
public LibraryAttribute()
- Construct a new attribute with no
container and an empty string as its name. Add the attribute to the
workspace directory.
Increment the version number of the workspace.
LibraryAttribute
public LibraryAttribute(Workspace workspace)
- Construct a new attribute with
no container and an empty string as a name. You can then change
the name with setName(). If the workspace argument is null, then
use the default workspace.
Add the attribute to the workspace directory.
Increment the version number of the workspace.
- Parameters:
workspace
- The workspace that will list the attribute.
LibraryAttribute
public LibraryAttribute(NamedObj container,
java.lang.String name)
throws NameDuplicationException,
IllegalActionException
- Construct an attribute with the given container and name.
If an attribute already exists with the same name as the one
specified here, that is an instance of class
LibraryAttribute (or a derived class), then that
attribute is removed before this one is inserted in the container.
- Parameters:
container
- The container.name
- The name of this attribute.
- Throws:
IllegalActionException
- If the attribute cannot be contained
by the proposed container.
NameDuplicationException
- If the container already has an
attribute with this name, and the class of that container is not
LibraryAttribute.
getLibrary
public CompositeEntity getLibrary()
throws java.lang.Exception
- Return the library specified by the configure() method or the
setLibrary() method, or null if it has not been set. If the
configure() method has defined the library, then calling this
method will parse the MoML in specified in the configure() call
to create the library. The parser for the top-level container
of this attribute will be used, if there is one. Otherwise,
a new parser will be used. Note that the library will be
reparsed each time this is called. This method ensures that
the library that is returned contains an attribute called
"_libraryMarker" so that a user interface recognizes it as
a library.
- Returns:
- The library, or null if none.
- Throws:
java.lang.Exception
- If the library specification
is invalid, for example because the MoML cannot be parsed, or
because it does not define an instance of CompositeEntity.- See Also:
setLibrary(CompositeEntity)
setLibrary
public void setLibrary(CompositeEntity library)
- Specify the library, overriding any library that might have been
or might later be specified by a call to configure(). This method
ensures that the library contains an attribute named "_libraryMarker"
by creating one if it is not there.
- Parameters:
library
- The library.- See Also:
getLibrary()