Package org.jruby

Examples of org.jruby.Ruby.newArray()


                            IRubyObject[] args = new IRubyObject[] {
                                RubyString.newUnicodeString(runtime, indexTableName), // table_name
                                RubyString.newUnicodeString(runtime, indexName), // index_name
                                runtime.newBoolean( ! nonUnique ), // unique
                                runtime.newArray() // [] for column names, we'll add to that in just a bit
                                // orders, (since AR 3.2) where, type, using (AR 4.0)
                            };

                            indexes.add( indexDefinition.callMethod(context, "new", args) ); // IndexDefinition.new
                        }
View Full Code Here


                        if (lastIndexDef != null) {
                            lastIndexDef.callMethod(context, "columns").callMethod(context, "<<", rubyColumnName);
                        }
                    }

                    return runtime.newArray(indexes);

                } finally { close(indexInfoSet); }
            }
        });
    }
View Full Code Here

        final List<String> primaryKeyNames = new ArrayList<String>(4);
        while ( primaryKeys.next() ) {
            primaryKeyNames.add( primaryKeys.getString(COLUMN_NAME) );
        }

        final RubyArray columns = runtime.newArray();
        final IRubyObject config = getConfig();
        while ( results.next() ) {
            final String colName = results.getString(COLUMN_NAME);
            IRubyObject column = jdbcColumn.callMethod(context, "new",
                new IRubyObject[] {
View Full Code Here

            results.add(result);
        }
        while ( statement.getMoreResults() );

        return runtime.newArray(results);
    }

    /**
     * Converts a JDBC result set into an array (rows) of hashes (row).
     *
 
View Full Code Here

        }
        catch (IllegalAccessException e) { throw new RuntimeException(e); }
        catch (InvocationTargetException e) { throw new RuntimeException(e.getTargetException()); }
        // RubyStackTraceElement[] trace = context.gatherCallerBacktrace(level);

        final RubyArray backtrace = runtime.newArray(trace.length);
        final StringBuilder line = new StringBuilder(32);
        for (int i = 0; i < trace.length; i++) {
            RubyStackTraceElement element = trace[i];
            line.setLength(0);
            line.append(element.getFileName()).append(':').
View Full Code Here

  }

  @JRubyMethod(name = "internal_undefined_instance_methods")
  public static RubyArray internalUndefinedInstanceMethods(ThreadContext context, IRubyObject self, IRubyObject module) {
    Ruby runtime = context.getRuntime();
    RubyArray result = runtime.newArray();
    for (Map.Entry<String, DynamicMethod> entry : ((RubyModule)module).getMethods().entrySet()) {
      if (entry.getValue().isUndefined())
        result.add(runtime.newSymbol(entry.getKey()));
    }
    return result;
View Full Code Here

                rs = c.getMetaData().getTables(catalog, schemapat, tablepat, types);
                List arr = new ArrayList();
                while (rs.next()) {
                    arr.add(runtime.newString(rs.getString(3).toLowerCase()));
                }
                return runtime.newArray(arr);
            } catch (SQLException e) {
                if(c.isClosed()) {
                    recv = recv.callMethod(recv.getRuntime().getCurrentContext(),"reconnect!");
                    if(!((Connection)recv.dataGetStruct()).isClosed()) {
                        continue;
View Full Code Here

                    if(!c.callMethod(ctx,"type").equals(runtime.newSymbol("decimal"))) {
                        c.callMethod(ctx,"precision=", runtime.getNil());
                    }
                }
            }
            return runtime.newArray(columns);
        } finally {
            try {
                rs.close();
            } catch(Exception e) {}
        }
View Full Code Here

       
        try {
            result_set.close();
        } catch(Exception e) {}

        return runtime.newArray(keyNames);
    }

    public static IRubyObject execute_id_insert(IRubyObject recv, IRubyObject sql, IRubyObject id) throws SQLException {
        Connection c = (Connection)recv.dataGetStruct();
        PreparedStatement ps = c.prepareStatement(sql.convertToString().getUnicodeValue());
View Full Code Here

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

    public static IRubyObject unmarshal_result(IRubyObject recv, ResultSet rs) throws SQLException, IOException {
        Ruby runtime = recv.getRuntime();
        List results = new ArrayList();
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.