Package org.mozilla.javascript

Examples of org.mozilla.javascript.Context.newObject()


    }

    private JsSimpleDomNode newObject(Node node, JsSimpleDomNode prev) {
        Context cx = ContextFactory.getGlobal().enterContext();
        try {
            JsSimpleDomNode newObject = (JsSimpleDomNode)cx.newObject(getParentScope(), "Node");
            newObject.initialize(node, prev);
            return newObject;
        } finally {
            Context.exit();
        }
View Full Code Here


        wrappedMap = map;
    }
   
    public static JsNamedNodeMap wrapMap(Scriptable scope, NamedNodeMap map) {
        Context cx = ContextFactory.getGlobal().enterContext();
        JsNamedNodeMap newObject = (JsNamedNodeMap)cx.newObject(scope, "NamedNodeMap");
        newObject.initialize(map);
        return newObject;
    }

    // CHECKSTYLE:OFF
View Full Code Here

      Context cx = Context.enter();
      try {
    Scriptable proto
        = (exception == null
           ? myProcess.jsScope() : exceptionScope());
    Scriptable scope = cx.newObject (proto);       
    scope.setPrototype (proto);
    scope.setParentScope (null);
   
    Object res = cx.evaluateString (scope, trans.condition(),
            "<condition>", 1, null);
View Full Code Here

     */
    public Scriptable jsGet_XML() {
        Context cx = Context.getCurrentContext();
        if (feed != null) {
            Object[] objects = { feed };
            Scriptable xmlHostObject = cx.newObject(this, "XML", objects);
            return xmlHostObject;
        }
        return null;
    }

View Full Code Here

     */
    public Scriptable jsGet_XML() {
        Context cx = Context.getCurrentContext();
        if (entry != null) {
            Object[] objects = { entry };
            Scriptable xmlHostObject = cx.newObject(this, "XML", objects);
            return xmlHostObject;
        }
        return null;
    }

View Full Code Here

                entry =
                        "<item xmlns:content=\"http://purl.org/rss/1.0/modules/content/\" xmlns:taxo=\"http://purl.org/rss/1.0/modules/taxonomy/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:media=\"http://search.yahoo.com/mrss/\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">" +
                                entry + "</item>";

                Object[] objects = { entry };
                return cx.newObject(this, "XML", objects);
            } else if (this.getType().contains("atom")) {
                // Extracting just the entry xml required
                int start = xmlRep.indexOf("<entry>") + "</entry>".length();
                int end = xmlRep.indexOf("</entry>");
                String entry = xmlRep.substring(start, end);
View Full Code Here

                entry =
                        "<entry xmlns=\"http://www.w3.org/2005/Atom\" xmlns:taxo=\"http://purl.org/rss/1.0/modules/taxonomy/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:sy=\"http://purl.org/rss/1.0/modules/syndication/\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">" +
                                entry + "</entry>";

                Object[] objects = { entry };
                return cx.newObject(this, "XML", objects);
            }
        } catch (FeedException e) {
            throw new CarbonException(e);
        }
View Full Code Here

            try {
                String xmlRep = output.outputString(feed);
                //removing the encoding part, since it makes trouble sometimes
                xmlRep = xmlRep.substring(xmlRep.indexOf("?>") + 2);
                Object[] objects = { xmlRep };
                return cx.newObject(this, "XML", objects);
            } catch (FeedException e) {
                throw new CarbonException(e);
            }
        }
        return null;
View Full Code Here

        if (Constants.XSD_ANYTYPE.equals(type)) {
            Context context = engine.getCx();
            OMElement element = omElement.getFirstElement();
            if (element != null) {
                Object[] objects = {element};
                return context.newObject(engine, "XML", objects);
            } else if (omElement.getText() != null) {
                OMAttribute omAttribute = omElement.getAttribute(new QName("http://www.w3.org/2001/XMLSchema-instance", "type"));
                if (omAttribute != null) {
                    String value = omAttribute.getAttributeValue();
                    if (value != null && !value.trim().equals("")) {
View Full Code Here

     */
    public Serializable evalScript (String script) throws ScriptException {
  Context cx = Context.enter();
  try {
      Scriptable proto = jsScope();
      Scriptable scope = cx.newObject (proto);
      scope.setPrototype (proto);
      scope.setParentScope (null);
   
      Object res = cx.evaluateString (scope, script, "<script>", 1, null);
      if (res instanceof Wrapper) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.