Package ptolemy.actor.lib
Class Assert
- java.lang.Object
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,Executable
,FiringsRecordable
,Initializable
,TypedActor
,Changeable
,Debuggable
,DebugListener
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
public class Assert extends Expression
Check that an assertion predicate is satisfied, and throw an exception if not. To use this actor, add any number of input ports. Corresponding output ports will be automatically added. Specify an expression that references the inputs and yields a boolean result. When the actor fires, if the expression evaluates to false, then the actor will throw an exception with the message given by themessage
parameter. Otherwise, it will copy the inputs to the corresponding output ports.- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Ilge Akkaya, David Broman, Edward A. Lee
- Pt.AcceptedRating:
- Red (eal)
- Pt.ProposedRating:
- Yellow (eal)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Assert.AssertPort
Class for ports created by the user for this actor.-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description StringParameter
message
The error message to display when the assertion is violated.-
Fields inherited from class ptolemy.actor.lib.Expression
_result, _tokenMap, expression, output
-
Fields inherited from class ptolemy.actor.TypedAtomicActor
_typesValid
-
Fields inherited from class ptolemy.actor.AtomicActor
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
-
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
-
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
-
-
Constructor Summary
Constructors Constructor Description Assert(CompositeEntity container, java.lang.String name)
Construct an instance of Assert.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_addPort(TypedIOPort port)
Override the base class to create an output port corresponding to each new input port added.protected void
_removePort(Port port)
Override the base class to remove the corresponding output port, if the specified port is an input port, or the corresponding input port, if the specified port is an output port.java.lang.Object
clone(Workspace workspace)
Clone the actor into the specified workspace.void
fire()
Override the base class to check the result of the evaluation of the expression.Port
newPort(java.lang.String name)
Override the base class to create a specialized port.-
Methods inherited from class ptolemy.actor.lib.Expression
attributeChanged, initialize, postfire, prefire, preinitialize
-
Methods inherited from class ptolemy.actor.TypedAtomicActor
_containedTypeConstraints, _customTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, isBackwardTypeInferenceEnabled, typeConstraintList, typeConstraints
-
Methods inherited from class ptolemy.actor.AtomicActor
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate, wrapup
-
Methods inherited from class ptolemy.kernel.ComponentEntity
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
-
Methods inherited from class ptolemy.kernel.Entity
_description, _exportMoMLContents, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
-
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ptolemy.actor.Actor
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
-
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
-
Methods inherited from interface ptolemy.actor.Executable
isFireFunctional, isStrict, iterate, stop, stopFire, terminate
-
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, removeInitializable, wrapup
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Field Detail
-
message
public StringParameter message
The error message to display when the assertion is violated. This is a string that defaults to "Assertion failed.".
-
-
Constructor Detail
-
Assert
public Assert(CompositeEntity container, java.lang.String name) throws NameDuplicationException, IllegalActionException
Construct an instance of Assert.- Parameters:
container
- The container.name
- The name of this actor.- Throws:
IllegalActionException
- If the actor cannot be contained by the proposed container.NameDuplicationException
- If the container already has an actor with this name.
-
-
Method Detail
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Clone the actor into the specified workspace.- Overrides:
clone
in classExpression
- Parameters:
workspace
- The workspace for the new object.- Returns:
- A new actor.
- Throws:
java.lang.CloneNotSupportedException
- If a derived class contains an attribute that cannot be cloned.- See Also:
NamedObj.exportMoML(Writer, int, String)
,NamedObj.setDeferringChangeRequests(boolean)
-
fire
public void fire() throws IllegalActionException
Override the base class to check the result of the evaluation of the expression. If the result is false, throw an exception. Otherwise, copy the inputs to the corresponding outputs.- Specified by:
fire
in interfaceExecutable
- Overrides:
fire
in classExpression
- Throws:
IllegalActionException
- If the expression evaluates to false, or if the superclass throws it.
-
newPort
public Port newPort(java.lang.String name) throws NameDuplicationException
Override the base class to create a specialized port.- Overrides:
newPort
in classTypedAtomicActor
- Parameters:
name
- The name for the new port.- Returns:
- The new port.
- Throws:
NameDuplicationException
- If the actor already has a port with the specified name.- See Also:
Workspace.getWriteAccess()
-
_addPort
protected void _addPort(TypedIOPort port) throws IllegalActionException, NameDuplicationException
Override the base class to create an output port corresponding to each new input port added. The output port will have as its display name the name of the input port. It will not be persistent (will not be exported to the MoML file).- Overrides:
_addPort
in classEntity<TypedIOPort>
- Parameters:
port
- The port to add to this entity.- Throws:
IllegalActionException
- If the port has no name.NameDuplicationException
- If the port name collides with a name already in the entity.
-
_removePort
protected void _removePort(Port port)
Override the base class to remove the corresponding output port, if the specified port is an input port, or the corresponding input port, if the specified port is an output port.- Overrides:
_removePort
in classEntity<TypedIOPort>
- Parameters:
port
- The port to remove from this entity. name already in the entity.
-
-