Package org.jruby

Examples of org.jruby.Ruby.newArray()


        } finally {
            try {
                rs.close();
            } catch(Exception e) {}
        }
        return runtime.newArray(results);
    }

    public static IRubyObject unmarshal_result(IRubyObject recv, IRubyObject resultset, Block row_filter) throws SQLException, IOException {
        Ruby runtime = recv.getRuntime();
        ResultSet rs = intoResultSet(resultset);
View Full Code Here


            try {
                rs.close();
            } catch(Exception e) {}
        }
        return runtime.newArray(results);
    }

    private static IRubyObject jdbc_to_ruby(Ruby runtime, int row, int type, int scale, ResultSet rs) throws SQLException, IOException {
        int n;
        switch(type) {
View Full Code Here

                    max = v1.callMethod(runtime.getCurrentContext(), MethodIndex.OP_PLUS, "+", RubyFixnum.one(runtime));
                }
                IRubyObject ret = JdbcAdapterInternalService.execute_query(conn, new IRubyObject[]{args[0], max}).
                    callMethod(runtime.getCurrentContext(), MethodIndex.AREF, "[]", range);
                if(ret.isNil()) {
                    return runtime.newArray();
                } else {
                    return ret;
                }
            } else {
                return JdbcAdapterInternalService.execute_update(conn, args[0]);
View Full Code Here

        Ruby ruby = context.getRuntime();
        if(nodeMap == null){
            return ruby.newEmptyArray();
        }

        RubyArray attr = ruby.newArray();

        for(int i = 0; i < nodeMap.getLength(); i++) {
            if ((doc instanceof HtmlDocument) || !NokogiriHelpers.isNamespace(nodeMap.item(i))) {
                attr.append(getCachedNodeOrCreate(context.getRuntime(), nodeMap.item(i)));
            }
View Full Code Here

        // don't use namespace_definitions cache anymore since
        // namespaces might be deleted. Reflecting the result of
        // namesapce removals is complicated, so the cache might not be
        // updated.
        Ruby ruby = context.getRuntime();
        RubyArray namespace_definitions = ruby.newArray();
        if (doc == null) return namespace_definitions;
        if (doc instanceof HtmlDocument) return namespace_definitions;
        List<XmlNamespace> namespaces = ((XmlDocument)doc).getNamespaceCache().get(node);
        for (XmlNamespace namespace : namespaces) {
            namespace_definitions.append(namespace);
View Full Code Here

        }
    }

    public void addErrorsIfNecessary(ThreadContext context, XmlDocument doc) {
        Ruby ruby = context.getRuntime();
        RubyArray errors = ruby.newArray(errorHandler.getErrorsReadyForRuby(context));
        doc.setInstanceVariable("@errors", errors);
    }

    public XmlDocument getDocumentWithErrorsOrRaiseException(ThreadContext context, RubyClass klazz, Exception ex) {
        if (options.recover) {
View Full Code Here

        if(args[0].isNil()) throw runtime.newArgumentError("io cannot be nil");

        XmlReader reader = (XmlReader) NokogiriService.XML_READER_ALLOCATOR.allocate(runtime, getNokogiriClass(runtime, "Nokogiri::XML::Reader"));
        reader.init(runtime);
        reader.setInstanceVariable("@source", args[0]);
        reader.setInstanceVariable("@errors", runtime.newArray());
        IRubyObject url = context.nil;
        if (args.length > 1) url = args[1];
        if (args.length > 2) reader.setInstanceVariable("@encoding", args[2]);

        Options options;
View Full Code Here

        if(args[0].isNil()) throw runtime.newArgumentError("string cannot be nil");

        XmlReader reader = (XmlReader) NokogiriService.XML_READER_ALLOCATOR.allocate(runtime, getNokogiriClass(runtime, "Nokogiri::XML::Reader"));
        reader.init(runtime);
        reader.setInstanceVariable("@source", args[0]);
        reader.setInstanceVariable("@errors", runtime.newArray());
        IRubyObject url = context.nil;
        if (args.length > 1) url = args[1];
        if (args.length > 2) reader.setInstanceVariable("@encoding", args[2]);

        Options options;
View Full Code Here

        IRubyObject[] ary = new IRubyObject[subs.size()];
        for (int i = 0; i < subs.size(); ++i) {
            ary[i] = ruby.newString(subs.get(i));
        }

        return ruby.newArray(ary);
    }

}
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.