Class URLReader

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

    public abstract class URLReader
    extends Source
    This actor reads tokens from an URL, and output them. Each entry in the file corresponds to one iteration. If there are multiple fires in the iteration, the same token will be repeated. This actor has a multiport, where each port corresponds to one column in the data file.

    The file format at the URL is assumed as the following. A newline character separates the rows, and a tab or a space character separates the columns.

    The sourceURL parameter should be set to the name of the file, specified as a fully qualified URL. If the sourceURL parameter is an empty string, then the System.in is used for input. It is possible to load a file from the local file system by using the prefix "file://" instead of "http://". Relative file paths are allowed. To specify a file relative to the current directory, use "../" or "./". For example, if the current directory contains a file called "test.txt", then sourceURL should be set to "file:./test.txt". If the parent directory contains a file called "test.txt", then sourceURL should be set to "file:../test.txt". To reference the file test.txt, located at "/tmp/test.txt", sourceURL should be set to "file:///tmp/test.txt" The default value is "file:///tmp/test.txt".

    FIXME: The type of the output ports is set to Double for now. It should read a line in the prefire() and refer the type from there.

    FIXME: URLReader should read in expressions and serialized tokens

    Since:
    Ptolemy II 2.0
    Version:
    $Id$
    Author:
    Jie Liu
    See Also:
    AudioReader
    Pt.AcceptedRating:
    Red (liuj)
    Pt.ProposedRating:
    Red (liuj)
    • Field Detail

      • sourceURL

        public Parameter sourceURL
        The URL of the file to read from. This parameter contains a StringToken. By default, it contains an empty string, which is interpreted to mean that input should be directed to the standard input. FIXME: Should this bring up a dialog box to type (or select) a URL?
      • refresh

        public Parameter refresh
        The flag that indicates whether to refresh between each reading. This is a boolean, and defaults to false.
      • _reader

        protected java.io.BufferedReader _reader
        The reader to read from.
      • _stdIn

        protected static java.io.BufferedReader _stdIn
        Standard in as a reader.
      • _source

        protected java.lang.String _source
        String for the URL.
      • _refreshFlag

        protected boolean _refreshFlag
        Flag to indicate whether or not to refresh the data between readings.