Package jep.python

Examples of jep.python.PyModule


     * @param name a <code>String</code> value
     * @return a <code>PyModule</code> value
     * @exception JepException if an error occurs
     */
    public PyModule createModule(String name) throws JepException {
        return (PyModule) trackObject(new PyModule(
                                          this.tstate,
                                          createModule(this.tstate,
                                                       name),
                                          this));
    }
View Full Code Here


     * @param name a <code>String</code> value
     * @return an <code>Object</code> value
     */
    public Object get(String name) {
        try {
            PyModule module = null;
            String[] tokens = null;

            if(name.indexOf('.') > 0) {
                // split package name by '.' and make modules
                tokens = name.split("\\.");
                for(int i = 0; i < tokens.length - 1; i++) {
                    if(module == null)
                        module = jep.createModule(tokens[i]);
                    else
                        module = module.createModule(tokens[i]);
                }
            }

            if(module == null)
                return this.jep.getValue(name);
            else
                return module.getValue(tokens[tokens.length - 1]);
        }
        catch(JepException e) {
            // probably not found. javax.script wants use to just return null
            return null;
        }
View Full Code Here

     * @exception IllegalArgumentException if an error occurs
     */
    public void put(String name,
            Object val) throws IllegalArgumentException {
        try {
            PyModule module = null;
            String[] tokens = null;
            String   mname  = null;

            if(name.indexOf('.') > 0) {
                // split package name by '.' and make modules
                tokens = name.split("\\.");
                for(int i = 0; i < tokens.length - 1; i++) {
                    mname = tokens[i];
                    if(module == null)
                        module = jep.createModule(mname);
                    else
                        module = module.createModule(mname);
                }
            }

            if(module == null)
                this.jep.set(name, val);
            else
                module.set(tokens[tokens.length - 1], val);
        }
        catch(JepException e) {
            throw new IllegalArgumentException(e);
        }
    }
View Full Code Here

TOP

Related Classes of jep.python.PyModule

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.