Package nodebox.util

Examples of nodebox.util.LoadException


        Object returnValue;
        try {
            IFn loadFile = Clojure.var("clojure.core", "load-file");
            returnValue = loadFile.invoke(file.getCanonicalPath());
        } catch (IOException e) {
            throw new LoadException(file, e);
        }
        // We need a Var as the last statement, because we need to retrieve the current namespace.
        if (!(returnValue instanceof Var)) {
            throw new LoadException(file,
                    String.format("The last statement does not define a var, but %s.\n", returnValue));
        }
        Var nodesVar = (Var) returnValue;
        Namespace ns = nodesVar.ns;
        String namespace = ns.name.getName();
View Full Code Here


        } else if (language.equals("clojure")) {
            return ClojureLibrary.loadScript(file, identifier);
        } else if (language.equals("python")) {
            return PythonLibrary.loadScript(file, identifier);
        } else {
            throw new LoadException(file, "Unknown function library type " + language + ".");
        }
    }
View Full Code Here

        String currentVersion = parseFormatVersion(currentXml);
        ArrayList<String> warnings = new ArrayList<String>();
        // Avoid upgrades getting stuck in an infinite loop.
        int tries = 0;
        if (currentVersion.equals("0.9")) {
            throw new LoadException(file, "This is a NodeBox 2 file. Download NodeBox 2 from http://beta.nodebox.net/");
        }
        while (!currentVersion.equals(targetVersion) && tries < 100) {
            Method upgradeMethod = upgradeMap.get(currentVersion);
            if (upgradeMethod == null) {
                throw new LoadException(file, "Unsupported version " + currentVersion + ": this file is too new. Try downloading a new version of NodeBox from http://nodebox.net/download/");
            }
            try {
                UpgradeStringResult result = (UpgradeStringResult) upgradeMethod.invoke(null, currentXml);
                warnings.addAll(result.warnings);
                currentXml = result.xml;
            } catch (Exception e) {
                throw new LoadException(file, "Upgrading to " + currentVersion + " failed.", e);
            }
            currentVersion = parseFormatVersion(currentXml);
            tries++;
        }
        if (tries >= 100) {
            throw new LoadException(file, "Got stuck in an infinite loop when trying to upgrade from " + currentVersion);
        }
        return new UpgradeResult(file, currentXml, warnings);
    }
View Full Code Here

        try {
            Class c = Class.forName(identifier);
            Field instanceField = c.getDeclaredField("LIBRARY");
            return (JavaLibrary) instanceField.get(null);
        } catch (ClassNotFoundException e) {
            throw new LoadException(null, e);
        } catch (NoSuchFieldException e) {
            throw new LoadException(null, e);
        } catch (IllegalAccessException e) {
            throw new LoadException(null, e);
        } catch (ClassCastException e) {
            throw new LoadException(null, e);
        } catch (ExceptionInInitializerError e) {
            throw new LoadException(null, e);
        }
    }
View Full Code Here

            file = new File(baseFile, fileName);
        } else {
            file = new File(fileName);
        }
        if (!file.exists()) {
            throw new LoadException(file, "Library does not exist.");
        }
        return new PythonLibrary(namespace, file, loadScript(file));
    }
View Full Code Here

                Py.getSystemState().path.append(new PyString(file.getParentFile().getCanonicalPath()));
                PythonInterpreter interpreter = new PythonInterpreter();
                try {
                    interpreter.execfile(file.getCanonicalPath());
                } catch (IOException e) {
                    throw new LoadException(file, e);
                } catch (PyException e) {
                    throw new LoadException(file, e);
                }
                PyStringMap map = (PyStringMap) interpreter.getLocals();

                ImmutableMap.Builder<String, Function> builder = ImmutableMap.builder();
View Full Code Here

        checkNotNull(libraryName, "Library name cannot be null.");
        checkNotNull(xml, "XML string cannot be null.");
        try {
            return load(libraryName, null, new StringReader(xml), nodeRepository);
        } catch (XMLStreamException e) {
            throw new LoadException(null, "Could not read NDBX string", e);
        }
    }
View Full Code Here

        checkNotNull(libraryName, "Library name cannot be null.");
        checkNotNull(xml, "XML string cannot be null.");
        try {
            return load(libraryName, baseFile, new StringReader(xml), nodeRepository);
        } catch (XMLStreamException e) {
            throw new LoadException(null, "Could not read NDBX string", e);
        }
    }
View Full Code Here

        checkNotNull(f, "File cannot be null.");
        String libraryName = FileUtils.stripExtension(f);
        try {
            return load(libraryName, f, createFileReader(f), nodeRepository);
        } catch (FileNotFoundException e) {
            throw new LoadException(f, "File not found.");
        } catch (XMLStreamException e) {
            throw new LoadException(f, "Could not read NDBX file", e);
        }
    }
View Full Code Here

TOP

Related Classes of nodebox.util.LoadException

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.