Class StringToIntArray

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

    public class StringToIntArray
    extends TypedAtomicActor
    Convert a string to an integer-array. The output is an array of integers constructed by placing one byte (i.e. one character) of the string into the least significant byte of each integer. Typically, this byte is the ASCII code of the character. NOTE: For the time being, this actor assumes an 8-bit character has been set as the Java default on the platform in use. This actor is designed to facilitate use of the SerialComm serial communication actor which uses the same kind of integer array. Datagram actors can take this format as well.

    Since:
    Ptolemy II 2.0
    Version:
    $Id$
    Author:
    Winthrop Williams
    Pt.AcceptedRating:
    Red (winthrop)
    Pt.ProposedRating:
    Red (winthrop)
    • Field Detail

      • input

        public TypedIOPort input
        The port for the input, which has type string.
      • output

        public TypedIOPort output
        The output port, which has type {int}.
    • Method Detail

      • fire

        public void fire()
                  throws IllegalActionException
        Consume one string token on the input port and output a new array token of integer tokens on the output port. The low byte of each integer is the byte form of one of the characters. The other three bytes of each integer may be 0x000000 or 0xFFFFFF. The first character of the string is copied to the first element of the array, and so on. NOTE: Assumes an 8-bit character set is the default setting for this implementation of Java.
        Specified by:
        fire in interface Executable
        Overrides:
        fire in class AtomicActor<TypedIOPort>
        Throws:
        IllegalActionException - If there is no director. FIXME: Does this method actually check if there is a director?