Package bsh

Examples of bsh.Interpreter


            expanderContext = StringUtil.HtmlEncodingMapWrapper.getHtmlEncodingMapWrapper(context, simpleEncoder);
        }

        try {
            // use the same Interpreter (ie with the same context setup) for all evals
            Interpreter bsh = this.getBshInterpreter(context);
            for (AltTarget altTarget: this.altTargets) {
                Object retVal = bsh.eval(StringUtil.convertOperatorSubstitutions(altTarget.useWhen));
                boolean condTrue = false;
                // retVal should be a Boolean, if not something weird is up...
                if (retVal instanceof Boolean) {
                    Boolean boolVal = (Boolean) retVal;
                    condTrue = boolVal.booleanValue();
View Full Code Here


                    java.net.URL url = new java.net.URL(classname);
                    classname = url.getFile();
                    File file = new File(classname);
                    classname = file.getName();
                    classname = classname.substring(0, classname.length() - 4);
                    Interpreter i = new Interpreter(); // Construct an interpreter
                    BshClassManager bsh = i.getClassManager();
                    if (!bsh.classExists(classname)) {
                        i.source(url.getFile());
                    }
                    ti = bsh.classForName(classname);
                } catch (IOException ex) {
                    System.err.println("File missing:" + ex);
                    return null;
View Full Code Here

                    ScriptFrameworkErrorType.UNKNOWN );
            }
            // Set class loader to be used for class files
            // and jar files
            Thread.currentThread().setContextClassLoader(cl);
            Interpreter interpreter = new Interpreter();

            interpreter.getNameSpace().clear();
            // Set class loader to be used by interpreter
            // to look for classes by source e.g. interpreter
            // will use this classloader to search classpath
            // for source file ( bla.java ) on import or reference
            interpreter.setClassLoader(cl);
            try {
                interpreter.set("XSCRIPTCONTEXT",
                    ScriptContext.createContext(m_xModel, m_xInvocContext,
                        m_xContext, m_xMultiComponentFactory));

                interpreter.set("ARGUMENTS", aParams);
            }
            catch (bsh.EvalError e) {
                // Framework error setting up context
                throw new ScriptFrameworkErrorException(
                    e.getMessage(), null,
                    metaData.getLanguageName(), metaData.getLanguage(),
                    ScriptFrameworkErrorType.UNKNOWN );
            }

            try {
                String source = null;
                Object result = null;

                ScriptEditorForBeanShell editor =
                    ScriptEditorForBeanShell.getEditor(
                       sourceUrl );

                if ( editor != null )
                {
                    result = editor.execute();

                    if (result == null)
                    {
                        return new Any(new Type(), null);
                    }
                    return result;
                }

                metaData.loadSource()
                source = metaData.getSource();

                if ( source == null || source.length() == 0 )
                {
                  throw new ScriptFrameworkErrorException(
                        "Failed to read script", null,
                      metaData.getLanguageName(), metaData.getLanguage(),
                      ScriptFrameworkErrorType.NO_SUCH_SCRIPT );
                }
                result = interpreter.eval( source );

                if (result == null)
                {
                    return new Any(new Type(), null);
                }
View Full Code Here

    private Interpreter i;
   
    /** Creates a new instance of ScriptEngineBeanshell */
    public ScriptEngineBeanshell() {
        i = new Interpreter();
    }
View Full Code Here

   * @return the scripted Java class, or <code>null</code> if none could be determined
   * @throws EvalError in case of BeanShell parsing failure
   */
  static Class determineBshObjectType(String scriptSource) throws EvalError {
    Assert.hasText(scriptSource, "Script source must not be empty");
    Interpreter interpreter = new Interpreter();
    Object result = interpreter.eval(scriptSource);
    if (result instanceof Class) {
      return (Class) result;
    }
    else if (result != null) {
      return result.getClass();
View Full Code Here

   */
  static Object evaluateBshScript(String scriptSource, Class[] scriptInterfaces, ClassLoader classLoader)
      throws EvalError {

    Assert.hasText(scriptSource, "Script source must not be empty");
    Interpreter interpreter = new Interpreter();
    Object result = interpreter.eval(scriptSource);
    if (result != null) {
      return result;
    }
    else {
      // Simple BeanShell script: Let's create a proxy for it, implementing the given interfaces.
      Assert.notEmpty(scriptInterfaces,
          "Given script requires a script proxy: At least one script interface is required.");
      XThis xt = (XThis) interpreter.eval("return this");
      return Proxy.newProxyInstance(classLoader, scriptInterfaces, new BshObjectInvocationHandler(xt));
    }
  }
View Full Code Here

   * @return the scripted Java class, or <code>null</code> if none could be determined
   * @throws EvalError in case of BeanShell parsing failure
   */
  static Class determineBshObjectType(String scriptSource) throws EvalError {
    Assert.hasText(scriptSource, "Script source must not be empty");
    Interpreter interpreter = new Interpreter();
    Object result = interpreter.eval(scriptSource);
    if (result instanceof Class) {
      return (Class) result;
    }
    else if (result != null) {
      return result.getClass();
View Full Code Here

   */
  static Object evaluateBshScript(String scriptSource, Class[] scriptInterfaces, ClassLoader classLoader)
      throws EvalError {

    Assert.hasText(scriptSource, "Script source must not be empty");
    Interpreter interpreter = new Interpreter();
    Object result = interpreter.eval(scriptSource);
    if (result != null) {
      return result;
    }
    else {
      // Simple BeanShell script: Let's create a proxy for it, implementing the given interfaces.
      Assert.notEmpty(scriptInterfaces,
          "Given script requires a script proxy: At least one script interface is required.");
      XThis xt = (XThis) interpreter.eval("return this");
      return Proxy.newProxyInstance(classLoader, scriptInterfaces, new BshObjectInvocationHandler(xt));
    }
  }
View Full Code Here

     return beanShellPanel;
  }
 
  public Interpreter getInterpreter() {
    if (interpreter == null) {
      interpreter = new Interpreter(getBeanShellPanel().getConsole());
    }
    return interpreter;
  }
View Full Code Here

        m_jConsole = new JConsole();

        this.setLayout( new BorderLayout() );
        this.add( m_jConsole, BorderLayout.CENTER );

        m_interpreter = new Interpreter( m_jConsole );
        try
        {
            m_interpreter.set( "phoenix-kernel", kernel );
        }
        catch( EvalError ee )
View Full Code Here

TOP

Related Classes of bsh.Interpreter

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.