public class NamedObj extends java.lang.Object implements Changeable, java.lang.Cloneable, Debuggable, DebugListener, Derivable, MoMLExportable, ModelErrorHandler, Moveable
This class supports a naming scheme, change requests, a persistent file format (MoML), a mutual exclusion mechanism for models (the workspace), an error handler, and a hierarchical class mechanism with inheritance.
An instance of this class can also be parameterized by attaching
instances of the Attribute class.
Instances of Attribute can be attached by calling their setContainer()
method and passing this object as an argument. Those instances will
then be reported by the getAttribute(String)
,
getAttribute(String, Class)
, attributeList()
and attributeList(Class)
methods.
Classes derived from NamedObj may constrain attributes to be a
subclass of Attribute. To do that, they should override the protected
_addAttribute(Attribute) method to throw an exception if
the object provided is not of the right class.
An instance of this class has a name. A name is an arbitrary string with no periods. If no name is provided, the name is taken to be an empty string (not a null reference). An instance also has a full name, which is a concatenation of the container's full name and the simple name, separated by a period. If there is no container, then the full name begins with a period. The full name is used for error reporting throughout Ptolemy II.
Instances of this class are associated with a workspace, specified as a constructor argument. The reference to the workspace is immutable. It cannot be changed during the lifetime of this object. It is used for synchronization of methods that depend on or modify the state of objects within it. If no workspace is specified, then the default workspace is used. Note that the workspace should not be confused with the container. The workspace never serves as a container.
In this base class, the container is null by default, and no method is provided to change it. Derived classes that support hierarchy provide one or more methods that set the container. By convention, if the container is set, then the instance should be removed from the workspace directory, if it is present. The workspace directory is expected to list only top-level objects in a hierarchy. The NamedObj can still use the workspace for synchronization. Any object contained by another uses the workspace of its container as its own workspace by default.
This class supports change requests or mutations,
which are changes to a model that are performed in a disciplined
fashion. In particular, a mutation can be requested via the
requestChange(ChangeRequest)
method. By default, when
a change is requested, the change is executed immediately.
However, by calling setDeferringChangeRequests(boolean)
,
you can ensure that change requests are queued to be executed
only when it is safe to execute them.
This class supports the notion of a model error, which is an exception that is handled by a registered model error handler, or passed up the container hierarchy if there is no registered model error handler. This mechanism complements the exception mechanism in Java. Instead of unraveling the calling stack to handle exceptions, this mechanism passes control up the Ptolemy II hierarchy.
Derived classes should override the _description() method to append new fields if there is new information that should be included in the description.
A NamedObj can contain instances of DecoratorAttributes
. These are attributes that are
added by another NamedObj that implements the Decorator
interface.
These attributes are stored separately and can be retrieved by using
getDecoratorAttributes(Decorator)
or
getDecoratorAttribute(Decorator, String)
.
Modifier and Type | Class and Description |
---|---|
protected class |
NamedObj.ContainedObjectsIterator
This class is an iterator over all the contained objects
(all instances of NamedObj).
|
Modifier and Type | Field and Description |
---|---|
(package private) NamedList |
_attributes
The Attributes attached to this object.
|
protected java.util.List |
_changeListeners
A list of weak references to change listeners.
|
protected java.lang.Object |
_changeLock
Object for locking accesses to change request list and status.
|
protected java.util.List |
_changeRequests
A list of pending change requests.
|
protected boolean |
_debugging
Flag that is true if there are debug listeners.
|
protected java.util.LinkedList |
_debugListeners
The list of DebugListeners registered with this object.
|
protected boolean |
_deferChangeRequests
Flag indicating that we should not immediately
execute a change request.
|
protected java.lang.String |
_elementName
The MoML element name.
|
protected java.lang.Boolean |
_isPersistent
Boolean variable to indicate the persistence of the object.
|
protected boolean |
_verbose
Flag that is true if detailed debug information is necessary.
|
protected Workspace |
_workspace
The workspace for this object.
|
static int |
ATTRIBUTES
Indicate that the description(int) method should include attributes
(if any).
|
static int |
CLASSNAME
Indicate that the description(int) method should include the class name.
|
static int |
COMPLETE
Indicate that the description(int) method should include everything.
|
static int |
CONTENTS
Indicate that the description(int) method should include the contained
objects (if any) that the object has.
|
static int |
DEEP
Indicate that the description(int) method should include the contained
objects (if any) that the contained objects have.
|
static int |
FULLNAME
Indicate that the description(int) method should include the full name.
|
static int |
LINKS
Indicate that the description(int) method should include the links
(if any) that the object has.
|
Modifier | Constructor and Description |
---|---|
|
NamedObj()
Construct an object in the default workspace with an empty string
as its name.
|
|
NamedObj(java.lang.String name)
Construct an object in the default workspace with the given name.
|
|
NamedObj(Workspace workspace)
Construct an object in the specified workspace with an empty string
as its name.
|
|
NamedObj(Workspace workspace,
java.lang.String name)
Construct an object in the given workspace with the given name.
|
protected |
NamedObj(Workspace workspace,
java.lang.String name,
boolean incrementWorkspaceVersion)
Construct an object in the given workspace with the given name.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_addAttribute(Attribute attribute)
Add an attribute.
|
protected void |
_adjustOverride(int depth)
Adjust the _override field of this object, if there is
one, by incrementing the value at the specified depth
by one, and do the same for all contained objects, with
one larger depth.
|
protected void |
_attachText(java.lang.String name,
java.lang.String text)
Attach the specified text as an attribute with the specified
name.
|
protected void |
_cloneFixAttributeFields(NamedObj newObject)
Fix the fields of the given object which point to Attributes.
|
protected java.util.List<Decorator> |
_containedDecorators()
Return a list of decorators contained by this object.
|
protected java.util.List<ChangeRequest> |
_copyChangeRequestList()
Return a copy of the current list of change requests, or return
null if there aren't any pending change requests.
|
protected void |
_debug(DebugEvent event)
Send a debug event to all debug listeners that have registered.
|
protected void |
_debug(java.lang.String message)
Send a debug message to all debug listeners that have registered.
|
protected void |
_debug(java.lang.String part1,
java.lang.String part2)
Send a debug message to all debug listeners that have registered.
|
protected void |
_debug(java.lang.String part1,
java.lang.String part2,
java.lang.String part3)
Send a debug message to all debug listeners that have registered.
|
protected void |
_debug(java.lang.String part1,
java.lang.String part2,
java.lang.String part3,
java.lang.String part4)
Send a debug message to all debug listeners that have registered.
|
protected java.lang.String |
_description(int detail,
int indent,
int bracket)
Return a description of the object.
|
protected void |
_executeChangeRequests(java.util.List<ChangeRequest> changeRequests)
Execute the specified list of change requests.
|
protected void |
_exportMoMLContents(java.io.Writer output,
int depth)
Write a MoML description of the contents of this object, which
in this base class is the attributes.
|
protected NamedObj |
_getContainedObject(NamedObj container,
java.lang.String relativeName)
Get an object with the specified name in the specified container.
|
protected static java.lang.String |
_getIndentPrefix(int level)
Return a number of spaces that is proportional to the argument.
|
protected boolean |
_isMoMLSuppressed(int depth)
Return true if describing this class in MoML is redundant.
|
protected void |
_markContentsDerived(int depth)
Mark the contents of this object as being derived objects.
|
protected void |
_notifyHierarchyListenersAfterChange()
If any hierarchy listeners are registered, notify them
that a change has occurred in the hierarchy.
|
protected void |
_notifyHierarchyListenersBeforeChange()
If any hierarchy listeners are registered, notify them
that a change is about to occur in the hierarchy.
|
protected NamedObj |
_propagateExistence(NamedObj container)
Propagate existence of this object to the
specified object.
|
protected void |
_propagateValue(NamedObj destination)
Propagate the value of this object (if any) to the
specified object.
|
protected void |
_removeAttribute(Attribute param)
Remove the given attribute.
|
protected static java.lang.String[] |
_splitName(java.lang.String name)
Split the specified name at the first period and return the
two parts as a two-element array.
|
protected static java.lang.String |
_stripNumericSuffix(java.lang.String string)
Return a string that is identical to the specified string
except any trailing digits are removed.
|
protected void |
_validateSettables(java.util.Collection attributesValidated)
Validate attributes deeply contained by this object if they
implement the Settable interface by calling their validate() method.
|
void |
addChangeListener(ChangeListener listener)
Add a change listener.
|
void |
addDebugListener(DebugListener listener)
Append a listener to the current set of debug listeners.
|
void |
addHierarchyListener(HierarchyListener listener)
Add a hierarchy listener.
|
void |
attributeChanged(Attribute attribute)
React to a change in an attribute.
|
void |
attributeDeleted(Attribute attribute)
React to the deletion of an attribute.
|
java.util.List |
attributeList()
Return a list of the attributes contained by this object.
|
<T> java.util.List<T> |
attributeList(java.lang.Class<T> filter)
Return a list of the attributes contained by this object that
are instances of the specified class.
|
void |
attributeTypeChanged(Attribute attribute)
React to a change in the type of an attribute.
|
java.lang.Object |
clone()
Clone the object into the current workspace by calling the clone()
method that takes a Workspace argument.
|
java.lang.Object |
clone(Workspace workspace)
Clone the object into the specified workspace.
|
java.util.Iterator |
containedObjectsIterator()
Return an iterator over contained objects.
|
java.util.Set<Decorator> |
decorators()
Return the set of decorators that decorate this object.
|
boolean |
deepContains(NamedObj inside)
Return true if this object contains the specified object,
directly or indirectly.
|
int |
depthInHierarchy()
Return the depth in the hierarchy of this object.
|
java.lang.String |
description()
Return a full description of the object.
|
java.lang.String |
description(int detail)
Return a description of the object.
|
void |
event(DebugEvent event)
React to the given debug event by relaying to any registered
debug listeners.
|
void |
executeChangeRequests()
Execute previously requested changes.
|
java.lang.String |
exportMoML()
Get a MoML description of this object.
|
java.lang.String |
exportMoML(java.lang.String name)
Get a MoML description of this object with its name replaced by
the specified name.
|
void |
exportMoML(java.io.Writer output)
Write a MoML description of this object using the specified
Writer.
|
void |
exportMoML(java.io.Writer output,
int depth)
Write a MoML description of this entity with the specified
indentation depth.
|
void |
exportMoML(java.io.Writer output,
int depth,
java.lang.String name)
Write a MoML description of this object with the specified
indentation depth and with the specified name substituting
for the name of this object.
|
java.lang.String |
exportMoMLPlain()
Get a MoML description of this object without any XML headers.
|
Attribute |
getAttribute(java.lang.String name)
Get the attribute with the given name.
|
Attribute |
getAttribute(java.lang.String name,
java.lang.Class attributeClass)
Get the attribute with the given name and class.
|
java.util.Enumeration |
getAttributes()
Deprecated.
Use attributeList() instead.
|
java.util.List |
getChangeListeners()
Return a list of weak references to change listeners,
or null if there is none.
|
java.lang.String |
getClassName()
Return the MoML class name.
|
NamedObj |
getContainer()
Get the container.
|
Attribute |
getDecoratorAttribute(Decorator decorator,
java.lang.String name)
Return the decorator attribute with the specified name for the
specified decorator, or null the specified decorator provides
no attribute with the specified name or the decorator does not
decorate this object.
|
DecoratorAttributes |
getDecoratorAttributes(Decorator decorator)
Return the decorated attributes of this NamedObj, as decorated by the
specified decorator.
|
int |
getDerivedLevel()
Get the minimum level above this object in the hierarchy where a
parent-child relationship implies the existence of this object.
|
java.util.List |
getDerivedList()
Return a list of objects derived from this one.
|
java.lang.String |
getDisplayName()
Return a name to present to the user.
|
java.lang.String |
getElementName()
Get the MoML element name.
|
java.lang.String |
getFullName()
Return a string of the form ".name1.name2...nameN".
|
ModelErrorHandler |
getModelErrorHandler()
Get the model error handler specified by setErrorHandler().
|
java.lang.String |
getName()
Get the name.
|
java.lang.String |
getName(NamedObj parent)
Get the name of this object relative to the specified container.
|
java.util.List |
getPrototypeList()
Return a list of prototypes for this object.
|
java.lang.String |
getSource()
Get the source, which gives an external URL
associated with an entity (presumably from which the entity
was defined).
|
boolean |
handleModelError(NamedObj context,
IllegalActionException exception)
Handle a model error.
|
boolean |
isDeferringChangeRequests()
Return true if setDeferringChangeRequests(true) has been called
to specify that change requests should be deferred.
|
boolean |
isOverridden()
Return true if propagateValue() has been called, which
indicates that the value of this object (if any) has been
overridden from the default defined by its class definition.
|
boolean |
isPersistent()
Return true if this object is persistent.
|
java.util.Iterator |
lazyContainedObjectsIterator()
Return an iterator over contained object that currently exist,
omitting any objects that have not yet been instantiated because
they are "lazy".
|
void |
message(java.lang.String message)
React to a debug message by relaying it to any registered
debug listeners.
|
int |
moveDown()
Move this object down by one in the list of objects in
its container.
|
int |
moveToFirst()
Move this object to the first position in the list
of attributes of the container.
|
int |
moveToIndex(int index)
Move this object to the specified position in the list of
attributes of the container.
|
int |
moveToLast()
Move this object to the last position in the list
of attributes of the container.
|
int |
moveUp()
Move this object up by one in the list of
attributes of the container.
|
void |
notifyOfNameChange(NamedObj object)
React to a change in a contained named object.
|
java.util.List |
propagateExistence()
Propagate the existence of this object.
|
java.util.List |
propagateValue()
Propagate the value (if any) held by this
object to derived objects that have not been overridden.
|
void |
propagateValues()
If this object has a value that has been set directly,
or if it has a value that has propagated in, then
propagate that value to all derived objects, and
then repeat this for all objects this object contains.
|
void |
removeAttribute(Attribute param)
Remove attribute from list of attributes.
|
void |
removeChangeListener(ChangeListener listener)
Remove a change listener.
|
void |
removeDebugListener(DebugListener listener)
Unregister a debug listener.
|
void |
removeHierarchyListener(HierarchyListener listener)
Remove a hierarchy listener.
|
void |
requestChange(ChangeRequest change)
Request that the given change be executed.
|
void |
setClassName(java.lang.String name)
Set the MoML class name.
|
void |
setDeferringChangeRequests(boolean isDeferring)
Specify whether change requests made by calls to requestChange()
should be executed immediately.
|
void |
setDerivedLevel(int level)
Set the level above this object in the hierarchy where a
parent-child relationship implies the existence of this object.
|
void |
setDisplayName(java.lang.String name)
Set a name to present to the user.
|
void |
setModelErrorHandler(ModelErrorHandler handler)
Set the model error handler.
|
void |
setName(java.lang.String name)
Set or change the name.
|
void |
setPersistent(boolean persistent)
Set the persistence of this object.
|
void |
setSource(java.lang.String source)
Set the source, which gives an external URL
associated with an entity (presumably from which the entity
was defined).
|
java.util.List |
sortContainedObjects(java.util.Collection filter)
Return an ordered list of contained objects filtered by the specified
filter.
|
NamedObj |
toplevel()
Return the top level of the containment hierarchy.
|
java.lang.String |
toString()
Return the class name and the full name of the object,
with syntax "className {fullName}".
|
java.lang.String |
uniqueName(java.lang.String prefix)
Return a name that is guaranteed to not be the name of any
contained attribute.
|
void |
validateSettables()
Validate attributes deeply contained by this object if they
implement the Settable interface by calling their validate() method.
|
Workspace |
workspace()
Get the workspace.
|
public static final int COMPLETE
public static final int CLASSNAME
public static final int FULLNAME
public static final int LINKS
public static final int CONTENTS
public static final int DEEP
public static final int ATTRIBUTES
protected java.util.List _changeListeners
protected java.lang.Object _changeLock
protected java.util.List _changeRequests
protected boolean _debugging
protected java.util.LinkedList _debugListeners
protected transient boolean _deferChangeRequests
protected java.lang.String _elementName
protected java.lang.Boolean _isPersistent
protected Workspace _workspace
protected boolean _verbose
NamedList _attributes
public NamedObj()
public NamedObj(java.lang.String name) throws IllegalActionException
name
- Name of this object.IllegalActionException
- If the name has a period.public NamedObj(Workspace workspace)
workspace
- Object for synchronization and version trackingpublic NamedObj(Workspace workspace, java.lang.String name) throws IllegalActionException
workspace
- Object for synchronization and version trackingname
- Name of this object.IllegalActionException
- If the name has a period.protected NamedObj(Workspace workspace, java.lang.String name, boolean incrementWorkspaceVersion) throws IllegalActionException
workspace
- Object for synchronization and version trackingname
- Name of this object.incrementWorkspaceVersion
- False to not add this to the workspace
or do anything else that might change the workspace version number.IllegalActionException
- If the name has a period.public void addChangeListener(ChangeListener listener)
If the listener is already in the list, remove the previous instance and add it again in the first position. This listener is also notified before other listeners that have been previously registered with the top-level object.
addChangeListener
in interface Changeable
listener
- The listener to add.removeChangeListener(ChangeListener)
,
requestChange(ChangeRequest)
,
Changeable
public void addDebugListener(DebugListener listener)
addDebugListener
in interface Debuggable
listener
- The listener to which to send debug messages.removeDebugListener(DebugListener)
public void addHierarchyListener(HierarchyListener listener)
listener
- The listener to add.removeHierarchyListener(HierarchyListener)
public void attributeChanged(Attribute attribute) throws IllegalActionException
attribute
- The attribute that changed.IllegalActionException
- If the change is not acceptable
to this container (not thrown in this base class).public void attributeDeleted(Attribute attribute) throws IllegalActionException
attribute
- The attribute that was deleted.IllegalActionException
- If the deletion is not acceptable
to this container (not thrown in this base class).public java.util.List attributeList()
public <T> java.util.List<T> attributeList(java.lang.Class<T> filter)
T
- The type of that class.filter
- The class of attribute of interest.public void attributeTypeChanged(Attribute attribute) throws IllegalActionException
attribute
- The attribute whose type changed.IllegalActionException
- If the change is not acceptable
to this container (not thrown in this base class).public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
- If any of the attributes
cannot be cloned.public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
workspace
- The workspace for the new object.java.lang.CloneNotSupportedException
- If any of the attributes
cannot be cloned.exportMoML(Writer, int, String)
,
setDeferringChangeRequests(boolean)
public java.util.Iterator containedObjectsIterator()
public java.util.Set<Decorator> decorators() throws IllegalActionException
IllegalActionException
- If a decorator referenced
by a DecoratorAttributes cannot be found.Decorator
public boolean deepContains(NamedObj inside)
inside
- The object to check for inside this object.public int depthInHierarchy()
public java.lang.String description() throws IllegalActionException
description
in interface Nameable
IllegalActionException
- Not thrown in this base class,
but derived classes could throw an exception if there is a problem
accessing subcomponents of this object.exportMoML(Writer, int, String)
public java.lang.String description(int detail) throws IllegalActionException
detail
- The level of detail.IllegalActionException
- Not thrown in this base class,
but derived classes could throw an exception if there is a problem
accessing subcomponents of this object.exportMoML(Writer, int, String)
public void event(DebugEvent event)
event
in interface DebugListener
event
- The event.public void executeChangeRequests()
isDeferringChangeRequests()
returns true.
Listeners will be notified of success or failure.executeChangeRequests
in interface Changeable
addChangeListener(ChangeListener)
,
requestChange(ChangeRequest)
,
isDeferringChangeRequests()
,
Changeable
public final java.lang.String exportMoML()
exportMoML
in interface MoMLExportable
MoMLExportable
,
exportMoML(Writer, int, String)
,
isPersistent()
,
getDerivedLevel()
public final java.lang.String exportMoML(java.lang.String name)
exportMoML
in interface MoMLExportable
name
- The name of we use when exporting the description.MoMLExportable
,
exportMoML(Writer, int, String)
,
isPersistent()
,
getDerivedLevel()
public final void exportMoML(java.io.Writer output) throws java.io.IOException
exportMoML(new OutputStreamWriter(System.out))This method uses the three-argument version of this method. It is final to ensure that derived classes only need to override that method to change the MoML description.
exportMoML
in interface MoMLExportable
output
- The stream to write to.java.io.IOException
- If an I/O error occurs.MoMLExportable
,
exportMoML(Writer, int, String)
,
isPersistent()
,
getDerivedLevel()
public final void exportMoML(java.io.Writer output, int depth) throws java.io.IOException
exportMoML
in interface MoMLExportable
output
- The output stream to write to.depth
- The depth in the hierarchy, to determine indenting.java.io.IOException
- If an I/O error occurs.MoMLExportable
,
exportMoML(Writer, int, String)
,
isPersistent()
,
getDerivedLevel()
public void exportMoML(java.io.Writer output, int depth, java.lang.String name) throws java.io.IOException
getClassName()
, the source is determined by
getSource()
. The description has the form:
<element name="name" class="classname" source="source">> body, determined by _exportMoMLContents() </element>By default, the element name is "entity." The default class name is the Java classname of this instance. The source attribute is by default left off altogether.
If this object has no container and the depth argument is zero, then this method prepends XML file header information, which is:
<?xml version="1.0" standalone="no"?> <!DOCTYPE entity PUBLIC "-//UC Berkeley//DTD MoML 1//EN" "http://ptolemy.eecs.berkeley.edu/xml/dtd/MoML_1.dtd">In the above, "entity" may be replaced by "property" or "port" if somehow a top-level property or port is exported.
The text that is written is indented according to the specified depth, with each line (including the last one) terminated with a newline. Derived classes can override this method to change the MoML description of an object. They can override the protected method _exportMoMLContents() if they need to only change which contents are described.
If this object is not persistent, or if there is no MoML description of this object, or if this object is a class instance, then write nothing.
exportMoML
in interface MoMLExportable
output
- The output stream to write to.depth
- The depth in the hierarchy, to determine indenting.name
- The name to use in the exported MoML.java.io.IOException
- If an I/O error occurs.MoMLExportable
,
clone(Workspace)
,
isPersistent()
,
getDerivedLevel()
public final java.lang.String exportMoMLPlain()
exportMoML()
public Attribute getAttribute(java.lang.String name)
name
- The name of the desired attribute.public Attribute getAttribute(java.lang.String name, java.lang.Class attributeClass) throws IllegalActionException
name
- The name of the desired attribute.attributeClass
- The class of the desired attribute.IllegalActionException
- If an attribute is found with
the specified name that is not an instance of the specified class.@Deprecated public java.util.Enumeration getAttributes()
public java.util.List getChangeListeners()
public java.lang.String getClassName()
getClassName
in interface MoMLExportable
MoMLExportable
,
setClassName(String)
public NamedObj getContainer()
getContainer
in interface Nameable
public Attribute getDecoratorAttribute(Decorator decorator, java.lang.String name) throws IllegalActionException
decorator
- The decorator.name
- The name of the attribute.IllegalActionException
- If a decorator referenced
by a DecoratorAttributes cannot be found.Decorator.createDecoratorAttributes(NamedObj)
,
getDecoratorAttributes(Decorator)
public DecoratorAttributes getDecoratorAttributes(Decorator decorator) throws IllegalActionException
decorator
- The decorator.IllegalActionException
- If a decorator referenced
by a DecoratorAttributes cannot be found.Decorator.createDecoratorAttributes(NamedObj)
,
getDecoratorAttribute(Decorator, String)
public int getDerivedLevel()
getDerivedLevel
in interface Derivable
Derivable
,
setDerivedLevel(int)
public java.util.List getDerivedList()
getDerivedList
in interface Derivable
Derivable
public java.lang.String getDisplayName()
getDisplayName
in interface Nameable
setDisplayName(String)
public java.lang.String getElementName()
getElementName
in interface MoMLExportable
MoMLExportable
public java.lang.String getFullName()
getFullName
in interface Nameable
public ModelErrorHandler getModelErrorHandler()
setModelErrorHandler(ModelErrorHandler handler)
public java.lang.String getName()
getName
in interface Nameable
setName(String)
public java.lang.String getName(NamedObj parent) throws InvalidStateException
A recursive structure, where this object is directly or indirectly contained by itself, may result in a runtime exception of class InvalidStateException if it is detected. Note that it is not possible to construct a recursive structure using this class alone, since there is no container. But derived classes might erroneously permit recursive structures, so this error is caught here.
This method is read-synchronized on the workspace.
getName
in interface Nameable
parent
- The object relative to which you want the name.InvalidStateException
- If a recursive structure is
encountered, where this object directly or indirectly contains
itself. Note that this is a runtime exception so it need not
be declared explicitly.setName(String)
public java.util.List getPrototypeList() throws IllegalActionException
getPrototypeList
in interface Derivable
IllegalActionException
- If a prototype with the right
name but the wrong class is found.Derivable
public java.lang.String getSource()
getSource
in interface MoMLExportable
setSource(String)
,
MoMLExportable
public boolean handleModelError(NamedObj context, IllegalActionException exception) throws IllegalActionException
A typical use of this facility is where a subclass of NamedObj does the following:
handleModelError(this, new IllegalActionException(this, message));instead of this:
throw new IllegalActionException(this, message);The former allows a container in the hierarchy to intercept the exception, whereas the latter simply throws the exception.
handleModelError
in interface ModelErrorHandler
context
- The object in which the error occurred.exception
- An exception that represents the error.IllegalActionException
- If the handler handles the
error by throwing an exception.setModelErrorHandler(ModelErrorHandler handler)
public boolean isDeferringChangeRequests()
isDeferringChangeRequests
in interface Changeable
setDeferringChangeRequests(boolean)
,
Changeable
public boolean isOverridden()
propagateValue()
,
setDerivedLevel(int)
public boolean isPersistent()
isPersistent
in interface MoMLExportable
setPersistent(boolean)
,
MoMLExportable
public java.util.Iterator lazyContainedObjectsIterator()
containedObjectsIterator()
.
If derived classes override it, they must guarantee that any omitted
objects are genuinely not needed in whatever uses this method.public void message(java.lang.String message)
message
in interface DebugListener
message
- The debug message.public int moveDown() throws IllegalActionException
moveDown
in interface Moveable
IllegalActionException
- Always thrown in this base class.public int moveToFirst() throws IllegalActionException
moveToFirst
in interface Moveable
IllegalActionException
- Always thrown in this base class.public int moveToIndex(int index) throws IllegalActionException
moveToIndex
in interface Moveable
index
- The position to move this object to.IllegalActionException
- Always thrown in this base class.public int moveToLast() throws IllegalActionException
moveToLast
in interface Moveable
IllegalActionException
- Always thrown in this base class.public int moveUp() throws IllegalActionException
moveUp
in interface Moveable
IllegalActionException
- Always thrown in this base class.public void notifyOfNameChange(NamedObj object)
object
- The object that changed.public java.util.List propagateExistence() throws IllegalActionException
propagateExistence
in interface Derivable
IllegalActionException
- If the object does
not exist and cannot be created.Derivable
,
setDerivedLevel(int)
public java.util.List propagateValue() throws IllegalActionException
propagateValue
in interface Derivable
IllegalActionException
- If propagation fails.Derivable
,
isOverridden()
public void propagateValues() throws IllegalActionException
IllegalActionException
- If propagation fails.public void removeChangeListener(ChangeListener listener)
removeChangeListener
in interface Changeable
listener
- The listener to remove.addChangeListener(ChangeListener)
,
Changeable
public void removeDebugListener(DebugListener listener)
removeDebugListener
in interface Debuggable
listener
- The listener to remove from the list of listeners
to which debug messages are sent.addDebugListener(DebugListener)
public void removeHierarchyListener(HierarchyListener listener)
listener
- The listener to remove.addHierarchyListener(HierarchyListener)
public void requestChange(ChangeRequest change)
requestChange
in interface Changeable
change
- The requested change.executeChangeRequests()
,
setDeferringChangeRequests(boolean)
,
Changeable
public void setClassName(java.lang.String name)
name
- The MoML class name.getClassName()
public void setDeferringChangeRequests(boolean isDeferring)
setDeferringChangeRequests
in interface Changeable
isDeferring
- If true, defer change requests.addChangeListener(ChangeListener)
,
executeChangeRequests()
,
isDeferringChangeRequests()
,
requestChange(ChangeRequest)
,
Changeable
public final void setDerivedLevel(int level)
NOTE: This method is tricky to use correctly. It is public because the MoML parser needs access to it. It should not be considered part of the public interface, however, in that only very sophisticated users should use it.
level
- The minimum level above this object in the containment
hierarchy where a parent-child relationship implies this object.getDerivedLevel()
,
setPersistent(boolean)
,
Derivable
public void setDisplayName(java.lang.String name)
name
- A name to present to the user.getDisplayName()
public void setModelErrorHandler(ModelErrorHandler handler)
handler
- The error handler, or null to specify no handler.getModelErrorHandler()
public void setName(java.lang.String name) throws IllegalActionException, NameDuplicationException
setName
in interface Nameable
name
- The new name.IllegalActionException
- If the name contains a period
or if the object is a derived object and the name argument does
not match the current name.NameDuplicationException
- Not thrown in this base class.
May be thrown by derived classes if the container already contains
an object with this name.getName()
,
getName(NamedObj)
public void setPersistent(boolean persistent)
setPersistent
in interface MoMLExportable
persistent
- False to make this object non-persistent.isPersistent()
,
MoMLExportable
public void setSource(java.lang.String source)
setSource
in interface MoMLExportable
source
- The source, or null if there is none.getSource()
,
MoMLExportable
public java.util.List sortContainedObjects(java.util.Collection filter)
filter
- A collection specifying which objects to include
in the returned list.public java.lang.String toString()
toString
in class java.lang.Object
public NamedObj toplevel()
public java.lang.String uniqueName(java.lang.String prefix)
prefix
- A prefix for the name.public void validateSettables() throws IllegalActionException
IllegalActionException
- If there is a problem validating
the deeply contained attributes.handleModelError(NamedObj context, IllegalActionException exception)
public final Workspace workspace()
protected void _addAttribute(Attribute attribute) throws NameDuplicationException, IllegalActionException
This method is write-synchronized on the workspace and increments its version number.
attribute
- The attribute to be added.NameDuplicationException
- If this object already
has an attribute with the same name.IllegalActionException
- If the attribute is not an
an instance of the expect class (in derived classes).protected void _adjustOverride(int depth)
depth
- The depth.protected void _attachText(java.lang.String name, java.lang.String text)
Note that attribute names beginning with an underscore "_" are reserved for system use. This method is used in several places to set the value of such attributes.
name
- The name of the attribute.text
- The text with which to configure the attribute.protected void _cloneFixAttributeFields(NamedObj newObject) throws java.lang.CloneNotSupportedException
newObject
- The object in which we fix the fields.java.lang.CloneNotSupportedException
- If there is a problem
getting the attributeprotected java.util.List<Decorator> _containedDecorators()
Decorator
interface. In subclasses, it can contain other
objects that implement the Decorator interface, such as Entities.protected java.util.List<ChangeRequest> _copyChangeRequestList()
protected final void _debug(DebugEvent event)
event
- The event.protected final void _debug(java.lang.String message)
message
- The message.protected final void _debug(java.lang.String part1, java.lang.String part2)
part1
- The first part of the message.part2
- The second part of the message.protected final void _debug(java.lang.String part1, java.lang.String part2, java.lang.String part3)
part1
- The first part of the message.part2
- The second part of the message.part3
- The third part of the message.protected final void _debug(java.lang.String part1, java.lang.String part2, java.lang.String part3, java.lang.String part4)
part1
- The first part of the message.part2
- The second part of the message.part3
- The third part of the message.part4
- The fourth part of the message.protected java.lang.String _description(int detail, int indent, int bracket) throws IllegalActionException
detail
- The level of detail.indent
- The amount of indenting.bracket
- The number of surrounding brackets (0, 1, or 2).IllegalActionException
- Not thrown in this base class,
but derived classes could throw an exception if there is a problem
accessing subcomponents of this object.protected void _executeChangeRequests(java.util.List<ChangeRequest> changeRequests)
changeRequests
- The list of change requests to execute.protected void _exportMoMLContents(java.io.Writer output, int depth) throws java.io.IOException
output
- The output stream to write to.depth
- The depth in the hierarchy, to determine indenting.java.io.IOException
- If an I/O error occurs.exportMoML(Writer, int)
protected NamedObj _getContainedObject(NamedObj container, java.lang.String relativeName) throws IllegalActionException
relativeName
- The name relative to the container.container
- The container expected to contain the object.IllegalActionException
- If the object exists
and has the wrong class. Not thrown in this base class.protected static java.lang.String _getIndentPrefix(int level)
level
- The level of indenting represented by the spaces.protected boolean _isMoMLSuppressed(int depth)
depth
- The depth of the requested MoML.protected void _markContentsDerived(int depth)
depth
- The derivation depth for this object, which
should be 0 except on recursive calls.setDerivedLevel(int)
protected void _notifyHierarchyListenersAfterChange() throws IllegalActionException
IllegalActionException
- If the change to the
hierarchy is not acceptable to the listener.addHierarchyListener(HierarchyListener)
,
HierarchyListener
protected void _notifyHierarchyListenersBeforeChange() throws IllegalActionException
IllegalActionException
- If changing the
hierarchy is not acceptable to the listener.addHierarchyListener(HierarchyListener)
,
HierarchyListener
protected NamedObj _propagateExistence(NamedObj container) throws IllegalActionException
NOTE: Any object that creates objects in its constructor that it does not contain must override this method and call propagateExistence() on those objects. Otherwise, those objects will not be propagated to subclasses or instances when this object is contained by a class definition. See PortParameter for an example.
container
- Object to contain the new object.IllegalActionException
- If the object
cannot be cloned.protected void _propagateValue(NamedObj destination) throws IllegalActionException
destination
- Object to which to propagate the
value.IllegalActionException
- If the value cannot
be propagated.protected void _removeAttribute(Attribute param)
param
- The attribute to be removed.public void removeAttribute(Attribute param)
param
- Attribute to remove.protected static final java.lang.String[] _splitName(java.lang.String name)
name
- The name to split.protected static java.lang.String _stripNumericSuffix(java.lang.String string)
string
- The string to strip of its numeric suffix.protected void _validateSettables(java.util.Collection attributesValidated) throws IllegalActionException
attributesValidated
- A collection of Settables that have
already been validated. For example, Settables that implement
the ShareableSettable interface are validated only once.IllegalActionException
- If there is a problem validating
the deeply contained attributes.handleModelError(NamedObj context, IllegalActionException exception)