Class StringCompare

  • All Implemented Interfaces:
    java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

    public class StringCompare
    extends TypedAtomicActor
    Compare two strings specified either as inputs or parameters. The output is either true or false, depending on whether the comparison function is satisfied.

    The comparison functions are:

    • equals: Output true if the strings are equal (Default).
    • startsWith: Output true if firstString starts with secondString.
    • endsWith: Output true if firstString ends with secondString.
    • contains: Output true if firstString contains secondString.

    The strings to be compared will be taken from the inputs if they are available, and otherwise will be taken from the corresponding parameters.

    Since:
    Ptolemy II 4.0
    Version:
    $Id$
    Author:
    Vinay Krishnan, Daniel Lázaro Cuadrado (contributor: Edward A. Lee)
    Pt.AcceptedRating:
    Green (net)
    Pt.ProposedRating:
    Green (kapokasa)
    • Field Detail

      • function

        public Parameter function
        The comparison function to be performed. The choices are:
        • equals: Compares firstString to another secondString (Default).
        • startsWith: Tests whether firstString starts with secondString.
        • endsWith: Tests whether firstString ends with secondString.
        • contains: Tests whether firstString contains secondString.
      • firstString

        public PortParameter firstString
        The input PortParameter for the first string of type string.
      • ignoreCase

        public Parameter ignoreCase
        The parameter to state whether to ignore case. This is a boolean that defaults to false.
      • output

        public TypedIOPort output
        The output port for the result of type BooleanToken.
      • secondString

        public PortParameter secondString
        The input PortParameter for the second string of type string.
    • Constructor Detail

      • StringCompare

        public StringCompare​(CompositeEntity container,
                             java.lang.String name)
                      throws NameDuplicationException,
                             IllegalActionException
        Construct an actor with the given container and name. Construct the two operand input PortParameters (initialized to "") and the output port which outputs the result of the various comparison functions executed by the actor. The function to be executed is decided by the parameter function, which is also initialized here to the comparison function equals. The ignoreCase parameter allows to ignore case when comparing.
        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.