A store for key-value pairs.
This actor stores key-value pairs and provides an interface for retrieving
them one at a time or in groups.
Shuhei Emoto, Edward A. Lee, Kentaro Mizouchi
$Id: Dictionary.java 70402 2014-10-23 00:52:20Z cxh $
Ptolemy II 10.0
Yellow (cxh)
Red (cxh)
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.
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.
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.
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.
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
<a href="../../../ptolemy/actor/lib/Dictionary.xml#notFound">notFound</a> output port.
An output providing the result of a multiple reading of the
dictionary via the readKeyArray input port. For any of the
keys in the <a href="../../../ptolemy/actor/lib/Dictionary.xml#readKeyArray">readKeyArray</a> 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.
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.
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.
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.
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.
If given, a log file will be written to the specified
directory.
<p>A file name can also contain the following strings that start
with "$", which get substituted
with the appropriate values.</p>
<table>
<tr>
<th>String</th>
<th>Description</th>
<th>Property</th>
</tr>
<tr>
<td><code>$CWD</code></td>
<td>The current working directory</td>
<td><code>user.dir</code></td>
</tr>
<tr>
<td><code>$HOME</code></td>
<td>The user's home directory</td>
<td><code>user.home</code></td>
</tr>
<tr>
<td><code>$PTII</code></td>
<td>The home directory of the Ptolemy II installation</td>
<td><code>ptolemy.ptII.dir</code></td>
</tr>
<tr>
<td><code>$TMPDIR</code></td>
<td>The temporary directory</td>
<td><code>java.io.tmpdir</code></td>
</tr>
<tr>
<td><code>$USERNAME</code></td>
<td>The user's account name</td>
<td><code>user.name</code></td>
</tr>
</table>
If set to true, and if a <i>file</i> 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.