001/* Display the high-level information of interface automata to stdout.
002
003 Copyright (c) 1999-2016 The Regents of the University of California.
004 All rights reserved.
005 Permission is hereby granted, without written agreement and without
006 license or royalty fees, to use, copy, modify, and distribute this
007 software and its documentation for any purpose, provided that the above
008 copyright notice and the following two paragraphs appear in all copies
009 of this software.
010
011 IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
012 FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
013 ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
014 THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
015 SUCH DAMAGE.
016
017 THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
018 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
019 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
020 PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
021 CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
022 ENHANCEMENTS, OR MODIFICATIONS.
023
024 PT_COPYRIGHT_VERSION_2
025 COPYRIGHTENDKEY
026 */
027package ptolemy.domains.modal.kernel.test;
028
029import java.net.URL;
030
031import ptolemy.actor.gui.ConfigurationApplication;
032import ptolemy.domains.modal.kernel.ia.InterfaceAutomaton;
033import ptolemy.moml.MoMLParser;
034
035///////////////////////////////////////////////////////////////////
036//// GetInfo
037
038/**
039 Display the high-level information of interface automata to stdout.
040 This class reads the MoML description of a number of interface automata,
041 and writes their high-level description to stdout one by one. The high-
042 level description is obtained by the getInfo() method of
043 InterfaceAutomaton.
044 The usage is:
045 <pre>
046 java ptolemy.domains.modal.kernel.test.GetInfo <i>automaton1.xml</i> <i>automaton2.xml</i> ...
047 </pre>
048
049 @author Yuhong Xiong
050 @version $Id$
051 @since Ptolemy II 8.0
052 @Pt.ProposedRating Red (yuhong)
053 @Pt.AcceptedRating Red (reviewmoderator)
054 */
055public class GetInfo {
056    /** Write the high-level description of the interface automaton to stdout.
057     *  @param momls An array of MoML file names for InterfaceAutomaton.
058     *  @exception Exception If the MoML file is not valid.
059     */
060    public GetInfo(String[] momls) throws Exception {
061        InterfaceAutomaton[] automata = new InterfaceAutomaton[momls.length];
062
063        for (int i = 0; i < momls.length; i++) {
064            URL url = ConfigurationApplication.specToURL(momls[i]);
065
066            // following the comments in MoMLApplication, use the same URL for
067            // the two arguments (base and URL) to parse(). Also, a instance
068            // of MoMLParser must be used to parse each file, otherwise
069            // the same automaton will be returned the second time parse() is
070            // called.
071            MoMLParser parser = new MoMLParser();
072            automata[i] = (InterfaceAutomaton) parser.parse(url, url);
073            automata[i].addPorts();
074
075            System.out.println("\n" + automata[i].getInfo() + "\n");
076        }
077    }
078
079    /** Pass the command line arguments to the constructor. The command line
080     *  argument is a list of MoML files for InterfaceAutomaton.
081     *  @param args The command line arguments.
082     */
083    public static void main(String[] args) {
084        try {
085            new GetInfo(args);
086        } catch (Exception exception) {
087            System.out.println(exception.getMessage());
088        }
089    }
090
091    ///////////////////////////////////////////////////////////////////
092    ////                         public variables                  ////
093    ///////////////////////////////////////////////////////////////////
094    ////                         public methods                    ////
095    ///////////////////////////////////////////////////////////////////
096    ////                         protected variables               ////
097    ///////////////////////////////////////////////////////////////////
098    ////                         protected methods                 ////
099    ///////////////////////////////////////////////////////////////////
100    ////                         private methods                   ////
101    ///////////////////////////////////////////////////////////////////
102    ////                         private variables                 ////
103}