Class TransformationRule

    • Field Detail

      • matchInput

        public TypedIOPort matchInput
        The matchInput port.
      • matchOutput

        public TypedIOPort matchOutput
        The matchOutput port.
      • matched

        public TypedIOPort matched
        The matched port.
      • modelInput

        public TypedIOPort modelInput
        The modelInput port.
      • modelOutput

        public TypedIOPort modelOutput
        The modelOutput port.
      • remaining

        public TypedIOPort remaining
        The remaining port.
      • repeatCount

        public Parameter repeatCount
        The count of repeated transformation in one firing.
      • repeatUntilFixpoint

        public Parameter repeatUntilFixpoint
        Whether the transformation in one firing should continue until a fixpoint is reached.
      • trigger

        public TypedIOPort trigger
        The trigger port.
    • Constructor Detail

      • TransformationRule

        public TransformationRule​(CompositeEntity container,
                                  java.lang.String name)
                           throws IllegalActionException,
                                  NameDuplicationException
        Construct a transformation rule with a name and a container. The container argument must not be null, or a NullPointerException will be thrown.
        Parameters:
        container - The container.
        name - The name of this actor.
        Throws:
        IllegalActionException - If the container is incompatible with this actor.
        NameDuplicationException - If the name coincides with an actor already in the container.
      • TransformationRule

        public TransformationRule​(Workspace workspace)
                           throws IllegalActionException,
                                  NameDuplicationException
        Construct a transformation rule in the specified workspace 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.
        Parameters:
        workspace - The workspace that will list the actor.
        Throws:
        IllegalActionException - If the name has a period in it, or the director is not compatible with the specified container.
        NameDuplicationException - If the container already contains an entity with the specified name.
    • Method Detail

      • attributeChanged

        public void attributeChanged​(Attribute attribute)
                              throws IllegalActionException
        React to a change in the mode parameter or the repeatUntilFixpoint parameter, and update the appearance of this actor.
        Overrides:
        attributeChanged in class TypedCompositeActor
        Parameters:
        attribute - The attribute changed.
        Throws:
        IllegalActionException - If the change is not acceptable to this container (not thrown in this base class).
      • clone

        public java.lang.Object clone()
                               throws java.lang.CloneNotSupportedException
        Clone the object into the current workspace by calling the clone() method that takes a Workspace argument. This method read-synchronizes on the workspace.
        Overrides:
        clone in class NamedObj
        Returns:
        A new NamedObj.
        Throws:
        java.lang.CloneNotSupportedException - If any of the attributes cannot be cloned.
      • fire

        public void fire()
                  throws IllegalActionException
        Fire this actor. Depending on the transformation mode, the action performed on the input and output is different.
        • If the mode is match only, then the actor has only an input port to receive input models and an output port to send out success flags in Booleans. When fired, a model token is read from the input port. Pattern matching is performed on it with a working copy of the encapsulated transformation rule. A true or false token is produced to the output port depending on the result of the pattern matching.
        • If the mode is one if replace first, replace last, replace any and replace all, the actor has one more output port to send out the transformed models in model tokens. The transformation action is performed according to the transformation modes specified in TransformationMode.Mode.
        • If the mode is full control, then the actor has a total of 6 ports. A modelInput port receives input models. A modelOutput port sends out result models. A matchInput port receives matches to be used for the transformation. A matchOutput port to produce matches. A trigger port to trigger pattern matching. A remaining port to output integer numbers representing the numbers of remaining matches. In each firing, if the modelInput port has a token present, the token is read and pattern matching is performed on the contained model. All the matches are collected in a list. It matchInput port has a token present, the match is read from that port and is used to transform the model, with the output being sent to the modelOutput port. If the trigger port has a token present, the token is consumed and the next match in the collected list is sent to the matchOutput port. Finally, in all cases, the number of remaining matches in the list is sent to the remaining port.
        Specified by:
        fire in interface Executable
        Overrides:
        fire in class CompositeActor
        Throws:
        IllegalActionException - If error occurs in reading the input, in sending the output, or in the transformation.
      • getPattern

        public Pattern getPattern()
        Get the pattern of this transformation rule.
        Returns:
        The pattern.
      • getReplacement

        public Replacement getReplacement()
        Get the replacement of this transformation rule.
        Returns:
        The replacement.
      • valueChanged

        public void valueChanged​(Settable settable)
        React to the change of mode and change the ports of this actor.
        Specified by:
        valueChanged in interface ValueListener
        Parameters:
        settable - The attribute changed.