Package org.mozilla.javascript

Examples of org.mozilla.javascript.Scriptable


    }

    try
    {
      final Context context = Context.enter();
      final Scriptable scope = context.initStandardObjects();
      initializeScope(scope);

      return context.evaluateString(scope, expression, getName(), 1, null);
    }
    finally
View Full Code Here


        boolean result = false;

        // now evaluate the condition using JavaScript
        Context cx = Context.enter();
        try {
            Scriptable scope = cx.initStandardObjects(null);
            Object cxResultObject = cx.evaluateString(scope, cond
            /** * conditionString ** */
            , "<cmd>", 1, null);
            resultStr = Context.toString(cxResultObject);

View Full Code Here

        String resultStr = "";

        Context cx = Context.enter();
        try {

            Scriptable scope = cx.initStandardObjects(null);

            // Set up some objects for the script to play with
            scope.put("log", scope, log); //$NON-NLS-1$
            scope.put("ctx", scope, jmctx); //$NON-NLS-1$
            scope.put("vars", scope, vars); //$NON-NLS-1$
            scope.put("props", scope, JMeterUtils.getJMeterProperties()); //$NON-NLS-1$
            // Previously mis-spelt as theadName
            scope.put("threadName", scope, Thread.currentThread().getName()); //$NON-NLS-1$
            scope.put("sampler", scope, currentSampler); //$NON-NLS-1$
            scope.put("sampleResult", scope, previousResult); //$NON-NLS-1$

            Object result = cx.evaluateString(scope, script, "<cmd>", 1, null); //$NON-NLS-1$

            resultStr = Context.toString(result);
            if (varName != null && vars != null) {// vars can be null if run from TestPlan
View Full Code Here

        if (rootScope == null) {

            final Context rhinoContext = Context.enter();
            try {

                Scriptable tmpScope = rhinoContext.initStandardObjects(
                    new ImporterTopLevel(), false);

                // default classes
                addHostObjects(tmpScope,
                    (Class<? extends ScriptableObject>[]) HOSTOBJECT_CLASSES);
View Full Code Here

                    } else {

                        // but other Scriptable host objects need to be
                        // registered as well
                        final Scriptable host = clazz.newInstance();
                        getWrapFactory().registerWrapper(
                            host.getClass(), host.getClassName());

                    }

                } catch (Throwable t) {
                    log.warn("addHostObjects: Cannot prepare host object "
View Full Code Here

            scriptReader = new EspReader(scriptReader);
        }

        // container for replaced properties
        Map<String, Object> replacedProperties = null;
        Scriptable scope = null;
        boolean isTopLevelCall = false;

        // create a rhino Context and execute the script
        try {

            final Context rhinoContext = Context.enter();
            rhinoContext.setOptimizationLevel(optimizationLevel());

            if (ScriptRuntime.hasTopCall(rhinoContext)) {
                // reuse the top scope if we are included
                scope = ScriptRuntime.getTopCallScope(rhinoContext);

            } else {
                // create the request top scope, use the ImporterToplevel here
                // to support the importPackage and importClasses functions
                scope = new ImporterTopLevel();

                // Set the global scope to be our prototype
                scope.setPrototype(rootScope);

                // We want "scope" to be a new top-level scope, so set its
                // parent scope to null. This means that any variables created
                // by assignments will be properties of "scope".
                scope.setParentScope(null);

                // setup the context for use
                WrapFactory wrapFactory = ((RhinoJavaScriptEngineFactory) getFactory()).getWrapFactory();
                rhinoContext.setWrapFactory(wrapFactory);
View Full Code Here

        SlingScriptHelper.class);
    if (sling == null) {
      throw new NullPointerException(SlingBindings.SLING);
    }

    Scriptable globalScope = ScriptableObject.getTopLevelScope(thisObj);

    Resource scriptResource = sling.getScript().getScriptResource();
    ResourceResolver resolver = scriptResource.getResourceResolver();

    // the path of the current script to resolve realtive paths
View Full Code Here

        protected SlingWrapFactory wrapFactory;

        @Override
        public ScriptEngine getScriptEngine() {
            final Context rhinoContext = Context.enter();
            Scriptable scope = rhinoContext.initStandardObjects(new ImporterTopLevel(), false);
            return new RhinoJavaScriptEngine(this, scope);
        }
View Full Code Here

 
  public TabStopStructure(String text) {
    createGroups();
   
    Emmet jse = Emmet.getSingleton();
    Scriptable tabstopData = (Scriptable) jse.execJSFunction("javaExtractTabstops", text);
    if (tabstopData != null) {
      text = Context.toString(ScriptableObject.getProperty(tabstopData, "text"));
      NativeArray tabstops = (NativeArray) ScriptableObject.getProperty(tabstopData, "tabstops");
      NativeObject tabstopItem;
      for (int i = 0; i < tabstops.getLength(); i++) {
View Full Code Here

        }

        String[] names = new String[] { "print", "load", "consoleWarn", "consoleError", "readFile" };
        browserSupport.defineFunctionProperties(names, scope.getClass(), ScriptableObject.DONTENUM);

        Scriptable argsObj = context.newArray(scope, new Object[]{});
        scope.defineProperty("arguments", argsObj, ScriptableObject.DONTENUM);
    }
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.Scriptable

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.