Class: DbDom::Rexml::TableElement

Inherits:
DynamicElement show all
Defined in:
lib/rexml.rb

Constant Summary

Constants inherited from DynamicElement

DynamicElement::EVERY_SINGLE_PARENT_METHOD

Instance Method Summary collapse

Methods inherited from DynamicElement

#initialize_children

Methods included from Advice

#advise, #advise_after, #advise_before

Constructor Details

#initialize(tablename, parent, context) ⇒ TableElement

Returns a new instance of TableElement.



73
74
75
76
77
# File 'lib/rexml.rb', line 73

def initialize(tablename, parent, context)
    super("table", parent, context)
    @tablename = tablename;
    attributes["name"] = tablename;
end

Instance Method Details

#construct_row(column_names, column_values, rownum) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
# File 'lib/rexml.rb', line 89

def construct_row(column_names, column_values, rownum)
    row = Element.new("row");
    row.attributes["num"] = rownum.to_s
    column_names.each_with_index do |name, i|
        col = Element.new(name)
        data = Text.new(column_values[i], false)
        col << data
        row << col
    end
    return row
end

#init_childrenObject



79
80
81
82
83
84
85
86
87
# File 'lib/rexml.rb', line 79

def init_children
    Java::Jdbc.with_connection(context) do |conn|
        rownum = 0
        Java::Jdbc.get_rows(conn, @tablename) do |column_names, column_values|
            @children << construct_row(column_names, column_values, rownum)
            rownum += 1
        end
    end
end