Class Dictionary

    • Field Detail

      • file

        public FileParameter file
        If a file is given here, it will be read upon initialization (if it exists and can be parsed as an array of arrays of tokens) to initialize the dictionary.
      • keys

        public TypedIOPort keys
        Upon receiving any token at the triggerKeys port, this actor will produce on this output an array containing all the keys of entries in the dictionary. The order is arbitrary. If there are no entries in the dictionary, then send an empty array. The type is array of string.
      • loggingDirectory

        public FileParameter loggingDirectory
        If given, a log file will be written to the specified directory.

        A file name can also contain the following strings that start with "$", which get substituted with the appropriate values.

        "Properties that are substituted.
        String Description Property
        $CWD The current working directory user.dir
        $HOME The user's home directory user.home
        $PTII The home directory of the Ptolemy II installation ptolemy.ptII.dir
        $TMPDIR The temporary directory java.io.tmpdir
        $USERNAME The user's account name user.name
      • notFound

        public TypedIOPort notFound
        An output listing one or more keys that were requested but not found in the dictionary. The output is produced only if a key is not found. The output type is an array of strings.
      • readKey

        public TypedIOPort readKey
        An input that provides a key for a value to be read from the dictionary. If the dictionary does not contain any value corresponding to this key, then the output will be a nil token. This has type string.
      • readKeyArray

        public TypedIOPort readKeyArray
        An input that provides an array of keys to be read simultaneously from the dictionary. The output will be an array with the same length as this input where each entry in the output array is the value corresponding to the corresponding key in the input array. For any key that has no entry in the dictionary, a nil token will be inserted in the output array. The type is array of string.
      • result

        public TypedIOPort result
        An output providing the result of a single reading of the dictionary via the readKey input port. If the specified key is not found, this port will produce a nil token, and an array of length one with the key will be produced on the notFound output port.
      • resultArray

        public TypedIOPort resultArray
        An output providing the result of a multiple reading of the dictionary via the readKeyArray input port. For any of the keys in the readKeyArray input is not in the dictionary, there will be a nil token in the result array in the position of the missing key. The missing keys will be produced on the notFound output.
      • triggerKeys

        public TypedIOPort triggerKeys
        Upon receiving any token at this port, this actor will produce on the keys output an array containing all the keys of entries in the dictionary. The order is arbitrary.
      • triggerValues

        public TypedIOPort triggerValues
        Upon receiving any token at this port, this actor will produce on the values output an array containing all the values of entries in the dictionary. The order is arbitrary.
      • values

        public TypedIOPort values
        Upon receiving any token at the triggerValues port, this actor will produce on this output an array containing all the values of entries in the dictionary. The order is arbitrary. If there are no entries in the dictionary, then send an empty array. The type is array of token.
      • updateFile

        public Parameter updateFile
        If set to true, and if a file parameter is given, then upon each update to the dictionary, the contents of the dictionary will be stored in the file. This defaults to false.
      • value

        public TypedIOPort value
        Input port for providing a value to store in the dictionary. The value will be stored only if a writeKey input arrives at the same time. Otherwise, it will be discarded.
      • writeKey

        public TypedIOPort writeKey
        An input that provides a key for a key-value pair to be stored in the dictionary. If a key arrives on this port, but there is no value on the value port or the value is nil, then the dictionary entry with the specified key will be removed. Otherwise, the value provided on the value port will be stored indexed by this key. This has type string.
    • Method Detail

      • fire

        public void fire()
                  throws IllegalActionException
        If there is a writeKey input, then update the dictionary; specifically, if there is also a value input, then insert into the dictionary the key-value pair given by these two inputs. Otherwise, or if the value input is a nil token, then delete the dictionary entry corresponding to the key. If there is a readKey input, then read the dictionary and produce on the result output the entry corresponding to the key, or a nil token if there is no such entry. If there is a readKeyArray input, then read the dictionary and produce on the resultArray output the entries corresponding to the keys, with nil tokens inserted for any missing entry. If there is a triggerKeys input, then produce on the keys output an array containing all the keys in the dictionary, in arbitrary order.
        Specified by:
        fire in interface Executable
        Overrides:
        fire in class AtomicActor<TypedIOPort>
        Throws:
        IllegalActionException - Not thrown in this base class.
      • wrapup

        public void wrapup()
                    throws IllegalActionException
        If a file has been specified and updateFile is true, then save the current state of the dictionary in the file. If the file cannot be written, then dictionary contents will be sent to standard out and an exception will be thrown.
        Specified by:
        wrapup in interface Initializable
        Overrides:
        wrapup in class AtomicActor<TypedIOPort>
        Throws:
        IllegalActionException - If the file cannot be written.