Package ptolemy.moml

Examples of ptolemy.moml.MoMLParser$UnlinkRequest


    public static Configuration readConfiguration(URL specificationURL)
            throws Exception {
        if (_initialSpecificationURL == null) {
            _initialSpecificationURL = specificationURL;
        }
        MoMLParser parser = new MoMLParser();
        parser.reset();

        Configuration configuration = (Configuration) parser.parse(
                specificationURL, specificationURL);

        // If the toplevel model is a configuration containing a directory,
        // then create an effigy for the configuration itself, and put it
        // in the directory.
View Full Code Here


    }

    public Object clone() throws CloneNotSupportedException {
        ModelGenerator actor = (ModelGenerator) super.clone();
        actor._emptyModel = null;
        actor._parser = new MoMLParser();
        return actor;
    }
View Full Code Here

                // This should not occur.
                System.err.println("Malformed preferences URL: " + ex);
                return;
            }

            MoMLParser parser = new MoMLParser(preferences.workspace());
            parser.setContext(preferences.getContainer());

            // Set the ErrorHandler so that if we have
            // compatibility problems between devel and production
            // versions, we can skip that element.
            // MoMLParser.setErrorHandler(new VergilErrorHandler());

            try {
                parser.parse(fileURL, fileURL);
            } catch (Exception ex) {
                System.out.println("Failed to read user preferences file: "
                        + ex);
            }
        }
View Full Code Here

     @exception Exception If the rule file or the model file cannot be read.
     *  @see #match(String, String)
     */
    public static GraphMatcher match(String ruleXMLFile, String hostXMLFile,
            MatchCallback callback) throws Exception {
        MoMLParser parser = new MoMLParser();
        TransformationRule rule = (TransformationRule) parser.parse(null,
                new File(ruleXMLFile).toURI().toURL());
        parser.reset();
        CompositeEntity host = (CompositeEntity) parser.parse(null, new File(
                hostXMLFile).toURI().toURL());

        GraphMatcher matcher = new GraphMatcher();
        if (callback != null) {
            matcher.setMatchCallback(callback);
View Full Code Here

                        .getAttribute("_parser", ParserAttribute.class);

                if (parserAttribute == null) {
                    parserAttribute = new ParserAttribute(newModel, "_parser");

                    MoMLParser parser = new MoMLParser();

                    // Make sure that the MoMLParser._modified flag is reset
                    // If we don't call reset here, then the second time
                    // the code generator is run, we will be prompted to
                    // save the model because the first time we ran
                    // the code generator the model was marked as modified.
                    parser.reset();

                    parserAttribute.setParser(parser);
                }

                // The name might be "blank" which is confusing.
                // Set it to an empty string.  On Save As, this will
                // be changed to match the file name.
                newModel.setName("");
                effigy.setModel(newModel);

                // THALES MODIF
                new Attribute(newModel, "_navigable");

                if (!modelIsValid(newModel)) {
                    effigy.setContainer(null);
                    effigy = null;
                }

                //END THALES MODIF
                return effigy;
            } else {
                String extension = getExtension(input);

                if (!extension.equals("xml") && !extension.equals("moml")) {
                    return null;
                }

                // THALES MODIF
                if (checkFile(input)) {
                    // Create a blank effigy.
                    PtolemyEffigy effigy = _newEffigy(container, container
                            .uniqueName("effigy"));

                    MoMLParser parser = new MoMLParser();

                    // Make sure that the MoMLParser._modified flag is reset
                    // If we don't call reset here, then the second time
                    // the code generator is run, we will be prompted to
                    // save the model because the first time we ran
                    // the code generator the model was marked as modified.
                    parser.reset();

                    NamedObj toplevel = null;

                    try {
                        try {
                            // If the following fails, we should remove the effigy.
                            try {
                                toplevel = parser.parse(base, input);
                            } catch (IOException io) {
                                // If we are running under Web Start, we
                                // might have a URL that refers to another
                                // jar file.
                                URL anotherURL = ClassUtilities
                                        .jarURLEntryResource(input.toString());

                                if (anotherURL != null) {
                                    toplevel = parser.parse(base, anotherURL);
                                } else {
                                    throw io;
                                }
                            }
View Full Code Here

            //                 System.out.println("CheckModelSize: skipping " + fileName);
            //                 continue;
            //             }
            StringBuffer analysis = new StringBuffer();

            MoMLParser parser = new MoMLParser();
            MoMLParser.setMoMLFilters(BackwardCompatibility.allFilters());

            RemoveGraphicalClasses removeGraphicalClasses = new RemoveGraphicalClasses();

            // Remove StaticSchedulingCodeGenerator from Butterfly because during the
            // nightly build the codegenerator is not yet built when the tests in actor.gui
            // are run.
            removeGraphicalClasses.put(
                    "ptolemy.codegen.kernel.StaticSchedulingCodeGenerator",
                    null);

            // Filter out any graphical classes.
            MoMLParser.addMoMLFilter(removeGraphicalClasses);

            if (!(fileName.endsWith(".xml") || fileName.endsWith(".moml"))) {
                continue;
            }

            try {
                NamedObj top = null;
                try {
                    top = parser
                            .parse(null, new File(fileName).toURI().toURL());
                } catch (Exception ex) {
                    try {
                        top = parser.parse(null, new URL(fileName));
                    } catch (Exception ex2) {
                        throw new Exception("Failed to parse \"" + fileName
                                + "\". First exception:\n" + ex, ex2);
                    }
                }
View Full Code Here

        URL xmlFile = getClass().getClassLoader().getResource(fileName);
        if (xmlFile == null) {
            return false;
        }
        InputStream input = xmlFile.openStream();
        MoMLParser newParser = new MoMLParser();
        newParser.setContext(context);
        newParser.parse(null, input);
        return true;
    }
View Full Code Here

     *  that does not exist.
     *  @param args Ignored.
     *  @exception Exception if there is a problem parsing
     */
    public static void main(String[] args) throws Exception {
        parser = new MoMLParser();
        //CompositeEntity toptop = new CompositeEntity();
        //parser.setContext(toptop);
        try {
            CompositeEntity toplevel = leak();
            toplevel.setContainer(null);
View Full Code Here

                                + ".GiottoCodeGeneratorUtilities ptolemyModel.xml\n"
                                + "The model is read in and Giotto code is "
                                + "generated on stdout.");
            }

            MoMLParser parser = new MoMLParser();

            // We set the list of MoMLFilters to handle Backward Compatibility.
            MoMLParser.setMoMLFilters(BackwardCompatibility.allFilters());

            // Filter out any graphical classes.
            MoMLParser.addMoMLFilter(new RemoveGraphicalClasses());

            // If there is a MoML error, then throw the exception as opposed
            // to skipping the error.  If we call StreamErrorHandler instead,
            // then the nightly build may fail to report MoML parse errors
            // as failed tests
            //parser.setErrorHandler(new StreamErrorHandler());
            // We use parse(URL, URL) here instead of parseFile(String)
            // because parseFile() works best on relative pathnames and
            // has problems finding resources like files specified in
            // parameters if the xml file was specified as an absolute path.
            TypedCompositeActor toplevel = (TypedCompositeActor) parser.parse(
                    null, new File(args[0]).toURI().toURL());

            System.out.println(generateGiottoCode(toplevel));
        } catch (Throwable ex) {
            System.err.println("Command failed: " + ex);
View Full Code Here


            for (Iterator<File> iterator = actorFiles.iterator(); iterator.hasNext();) {
                File xmlFile = (File) iterator.next();

                MoMLParser parser = new MoMLParser();
                MoMLParser.purgeModelRecord(xmlFile.toURL());
                NamedObj namedObject = null;
                try {
                    namedObject = (NamedObj) parser.parse(null, xmlFile.toURL());
                } catch (Exception e) {
                    // Bug 18567
                    LoggerFactory.getLogger(this.getClass()).error("Error while loading Actor in file " + xmlFile.toURL(), e);
                }
                if (namedObject != null) {
View Full Code Here

TOP

Related Classes of ptolemy.moml.MoMLParser$UnlinkRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.