Package bsh

Examples of bsh.Interpreter


     */
    public String getStyleAltRowStyle(Map<String, Object> context) {
        String styles = "";
        try {
            // use the same Interpreter (ie with the same context setup) for all evals
            Interpreter bsh = this.getBshInterpreter(context);
            for (AltRowStyle altRowStyle : this.altRowStyles) {
                Object retVal = bsh.eval(StringUtil.convertOperatorSubstitutions(altRowStyle.useWhen));
                // retVal should be a Boolean, if not something weird is up...
                if (retVal instanceof Boolean) {
                    Boolean boolVal = (Boolean) retVal;
                    if (boolVal.booleanValue()) {
                        styles += altRowStyle.style;
View Full Code Here


 
  public BeanShellAssertion()
  {
    String init="";
    try{
      bshInterpreter = new Interpreter();
      init = JMeterUtils.getPropDefault(INIT_FILE,null);
      if (init != null)
      {
        try
        {
View Full Code Here

 
  public BeanShellSampler()
  {
    String init="";
    try{
      bshInterpreter = new Interpreter();
      init = JMeterUtils.getPropDefault(INIT_FILE,null);
      if (init != null)
      {
        try
        {
View Full Code Here

        code=new String(buf);

        // create interpreter just-in-time
        if(interpreter == null) {
            interpreter=new Interpreter();

                if(log.isInfoEnabled()) log.info("beanshell interpreter was created");
            try {
                interpreter.set("bsh_prot", this);
View Full Code Here

    public static void main(String[] args) throws Exception {
        new BshCommand().execute(args);
    }

    public void execute() throws Exception {
        Interpreter bsh = null;
        Object ret;
        boolean interactive = false;
        InputStream in = getInput().getInputStream();
        OutputStream out = getOutput().getOutputStream();
        OutputStream err = getError().getOutputStream();
        if (FLAG_INTERACTIVE.isSet()) {
            bsh = createInterpreter(in, out, err, true);
            interactive = true;
        }

        if (ARG_CODE.isSet()) {
            if (bsh == null) {
                bsh = createInterpreter(in, out, err, false);
            }
            String code = ARG_CODE.getValue();
            ret = bsh.eval(code);

            if (ret != null) {
                out.write((ret + "\n").getBytes());
            }
        }

        if (ARG_FILE.isSet()) {
            if (bsh == null) {
                bsh = createInterpreter(in, out, err, false);
            }

            String file = ARG_FILE.getValue().toString();
            ret = bsh.source(file);

            if (ret != null) {
                out.write((ret + "\n").getBytes());
            }
        }
        out.flush();

        if (bsh == null) {
            // If no arguments were given, default to interactive mode.
            bsh = createInterpreter(in, out, err, true);
            interactive = true;
        }

        if (interactive) {
            bsh.run();
        }
    }
View Full Code Here

    }

    private Interpreter createInterpreter(
            InputStream in, OutputStream out, OutputStream err, boolean interactive)
        throws Exception {
        Interpreter interpreter = new Interpreter(
                new BufferedReader(new InputStreamReader(in)),
                new PrintStream(out),
                new PrintStream(err), interactive);
        if (interactive) {
            interpreter.eval("show();");
        }
        return interpreter;
    }
View Full Code Here

    return bshInerp.eval(expression);
  }

  public static synchronized Object getBeanShell() throws Exception {
    if (bshInerp == null)
      bshInerp = new Interpreter();

    for (Iterator<String> iterator = pageVars.iterator(); iterator.hasNext();)
    {
      String key = iterator.next();
      bshInerp.set(key, Fixture.getSymbol(key));
View Full Code Here

      if (useConsole)
      {
         String welcomeMessage = getWelcomeMessage();

         bshConsole = new JConsole();
         Interpreter interpreter = new Interpreter(bshConsole);

         configureInterpreter(interpreter, cacheDelegate);

         interpreter.println(welcomeMessage);
         interpreter.setShowResults(!interpreter.getShowResults());// show() in beanShell
         System.setOut(bshConsole.getOut());
         System.setErr(bshConsole.getErr());
         Thread t = new Thread(interpreter);
         t.start();
View Full Code Here

        public boolean shouldUse(Map<String, Object> context) {
            boolean shouldUse = true;
            String useWhen = this.getUseWhen(context);
            if (UtilValidate.isNotEmpty(useWhen)) {
                try {
                    Interpreter bsh = (Interpreter) context.get("bshInterpreter");
                    if (bsh == null) {
                        bsh = BshUtil.makeInterpreter(context);
                        context.put("bshInterpreter", bsh);
                    }

                    Object retVal = bsh.eval(StringUtil.convertOperatorSubstitutions(useWhen));

                    // retVal should be a Boolean, if not something weird is up...
                    if (retVal instanceof Boolean) {
                        Boolean boolVal = (Boolean) retVal;
                        shouldUse = boolVal.booleanValue();
View Full Code Here

        String useWhenStr = this.getUseWhen(context);
        if (UtilValidate.isEmpty(useWhenStr)) {
            return true;
        } else {
            try {
                Interpreter bsh = this.modelForm.getBshInterpreter(context);
                Object retVal = bsh.eval(StringUtil.convertOperatorSubstitutions(useWhenStr));
                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

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.