I want to convert the code by Giuseppe Maxia for DBIx::SQLCrosstab to Java. I have done the bulk of the conversion, however I am stuck at these in the code listed below in DBIx::SQLCrosstab::Format.
Some pointers on the listed code will be helpful.
# find initial columns without sublevels
my @header_columns =();
#@header_columns = map {$_->{alias}} @{$self->{rows}};
if ($tree_depth> 1) {
$tree->walk_down({
callback => sub {
my $node=shift;
return 1 if $node->address eq "0";
if ($node->descendants) {
$_[0]->{_end_hc} = 1;
return 1
}
push @header_columns, $node->name
unless $_[0]->{_end_hc};
my $cur_depth = ($node->address =~ tr/://) -1;
$node->attributes->{rowspan} = $tree_depth - $cur_depth ;
#print STDERR $node->name," ",
# $node->attributes->{rowspan},
# "\n";
},
_end_hc => 0
});
}
else {
my $recs_rows = $#{$self->{recs}};
COL:
for my $col ( 0.. $#{$self->{recs}->[0]} ) {
my $all_numeric =1;
for my $row( 0.. $recs_rows) {
my $value = $self->{recs}[$row][$col];
$value = 0 unless defined $value;
unless (($value =~ /^[0-9.]+$/))
{
push @header_columns,
($tree->daughters)[$col]->name;
$all_numeric =0;
next COL;
}
}
last COL if $all_numeric;
}
}