Package org.mozilla.javascript

Examples of org.mozilla.javascript.Context


            }
        }
        wrapper = new WrapMaker();
        wrapper.setJavaPrimitiveWrap(false);

        Context context = contextFactory.enterContext();

        try {
            // create global object
            global = new GlobalObject(this, app, false);
            // call the initStandardsObject in ImporterTopLevel so that
View Full Code Here


            // mark this type as updated again so it reflects
            // resources added during compilation
            // lastUpdate = frameworkProto.lastCodeUpdate();

            // If this prototype defines a postCompile() function, call it
            Context cx = Context.getCurrentContext();
            try {
                Object fObj = ScriptableObject.getProperty(objProto,
                                                           "onCodeUpdate");
                if (fObj instanceof Function) {
                    Object[] args = {frameworkProto.getName()};
View Full Code Here

  }

  protected String compileUnits(JRCompilationUnit[] units, String classpath,
      File tempDirFile) throws JRException
  {
    Context context = ContextFactory.getGlobal().enterContext();
    try
    {
      StringBuffer errors = new StringBuffer();
      int errorCount = 0;
      for (int i = 0; i < units.length; i++)
      {
        JRCompilationUnit unit = units[i];
        JavaScriptCompileData compileData = new JavaScriptCompileData();
        for (Iterator it = unit.getExpressions().iterator(); it.hasNext();)
        {
          JRExpression expr = (JRExpression) it.next();
          int id = unit.getCompileTask().getExpressionId(expr).intValue();
          JavaScriptCompileData.Expression jsExpr =
            JavaScriptEvaluator.createJSExpression(expr);
         
          //compile the default expression to catch syntax errors
          try
          {
            context.compileString(jsExpr.getDefaultExpression(),
                "expression", 0, null);
          }
          catch (EvaluatorException e)
          {
            ++errorCount;
View Full Code Here

            }
            sb.append(line).append("\n");
        }
        String scriptStr = sb.toString();

        Context cx = Context.enter();
        boolean providerFound = false;
        try {
            Scriptable scriptScope = cx.initStandardObjects(null, true);
            Object[] ids = compileScript(cx, scriptStr, scriptScope, f);
            if (ids.length > 0) {
                Service.Mode mode = Service.Mode.PAYLOAD;
                for (Object idObj : ids) {
                    if (!(idObj instanceof String)) {
View Full Code Here

        ep.publish(addr);
    }

    public DOMSource invoke(DOMSource request) {
        DOMSource response = new DOMSource();
        Context cx = Context.enter();
        try {
            Scriptable scope = cx.newObject(scriptScope);
            scope.setPrototype(scriptScope);
            scope.setParentScope(null);
            Node node = request.getNode();
            Object inDoc = null;
            if (isE4X) {
                try {
                    Object xo = XmlObject.Factory.parse(node);
                    inDoc = Context.toObject(xo, scope);
                    Object[] args = {inDoc};
                    inDoc = cx.newObject(scriptScope, "XML", args);
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            } else {
                inDoc = Context.toObject(node, scope);
View Full Code Here

        super(function, wrapper);
        this.fnThis = fnThis;
    }
   
    public Object exec(List arguments) throws TemplateModelException {
        Context cx = Context.getCurrentContext();
        Object[] args = arguments.toArray();
        BeansWrapper wrapper = getWrapper();
        for (int i = 0; i < args.length; i++) {
            args[i] = wrapper.unwrap((TemplateModel)args[i]);
        }
View Full Code Here

      return null;
    }

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

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

    public static JsSimpleDomNode wrapNode(Scriptable scope, Node node) {
        if (node == null) {
            return null;
        }
       
        Context cx = Context.enter();
        JsSimpleDomNode newObject = (JsSimpleDomNode)cx.newObject(scope, "Node");
        newObject.initialize(node, null);
        return newObject;
    }
View Full Code Here

        newObject.initialize(node, null);
        return newObject;
    }
   
    private JsSimpleDomNode newObject(Node node, JsSimpleDomNode prev) {
        Context cx = Context.enter();
        JsSimpleDomNode newObject = (JsSimpleDomNode)cx.newObject(getParentScope(), "Node");
        newObject.initialize(node, prev);
        return newObject;
    }
View Full Code Here

        String resultStr = "";
        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);

            if (resultStr.equals("false")) { //$NON-NLS-1$
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.Context

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.