File Coverage

blib/lib/DBI/Format.pm
Criterion Covered Total %
statement 252 308 81.8
branch 39 68 57.3
condition 15 31 48.3
subroutine 29 32 90.6
pod 0 2 0.0
total 335 441 75.9


'; '; ", $widths->[$i]); ", \n"; \n";
line stmt bran cond sub pod time code
1             # -*- perl -*-
2             # vim:ts=2:sw=2:aw:ai:sta:nows
3             #
4             # DBI::Format - a package for displaying result tables
5             #
6             # Copyright (c) 1998 Jochen Wiedmann
7             # Copyright (c) 1998 Tim Bunce
8             #
9             # The DBI::Shell:Result module is free software; you can redistribute
10             # it and/or modify it under the same terms as Perl itself.
11             #
12             # Author: Jochen Wiedmann
13             # Am Eisteich 9
14             # 72555 Metzingen
15             # Germany
16             #
17             # Email: joe@ispsoft.de
18             # Phone: +49 7123 14881
19             #
20              
21 7     7   52 use strict;
  7         14  
  7         489  
22              
23             package DBI::Format;
24              
25             our $VERSION = '11.96_03'; # TRIAL VERSION
26             $VERSION = eval $VERSION;
27              
28 7     7   51 use Text::Abbrev;
  7         15  
  7         3843  
29              
30             sub available_formatters {
31 22     22 0 48 my ($use_abbrev) = @_;
32 22         212 my @fmt;
33 22         68 my @dir = grep { -d "$_/DBI/Format" } @INC;
  242         3048  
34 22         219 foreach my $dir (@dir) {
35 66 50       1846 opendir DIR, "$dir/DBI/Format" or warn "Unable to read $dir/DBI: $!\n";
36 66 100       1443 push @fmt, map { m/^(\w+)\.pm$/i ? ($1) : () } readdir DIR;
  264         1182  
37 66         815 closedir DIR;
38             }
39 22         76 my %fmt = map { (lc($_) => "DBI::Format::$_") } @fmt;
  132         419  
40 22         81 $fmt{box} = "DBI::Format::Box";
41 22         52 $fmt{partbox} = "DBI::Format::PartBox";
42 22         46 $fmt{neat} = "DBI::Format::Neat";
43 22         49 $fmt{raw} = "DBI::Format::Raw";
44 22         44 $fmt{string} = "DBI::Format::String";
45 22         48 $fmt{html} = "DBI::Format::HTML";
46 22         46 my $formatters = \%fmt;
47 22 50       67 if ($use_abbrev) {
48 22         126 $formatters = abbrev(keys %fmt);
49 22         4797 foreach my $abbrev (sort keys %$formatters) {
50 792   50     1499 $formatters->{$abbrev} = $fmt{ $formatters->{$abbrev} } || die;
51             }
52             }
53 22         120 return $formatters;
54             }
55              
56              
57             sub formatter {
58 22     22 0 60 my ($class, $mode, $use_abbrev) = @_;
59 22         58 $mode = lc($mode);
60 22         61 my $formatters = available_formatters($use_abbrev);
61 22         48 my $fmt = $formatters->{$mode};
62 22 50       59 if (!$fmt) {
63 0         0 $formatters = available_formatters(0);
64 0         0 die "Format '$mode' unavailable. Available formats: ".
65             join(", ", sort keys %$formatters)."\n";
66             }
67             {
68             # Attempt to determine if format mode is in the base class.
69 7     7   56 no strict 'refs';
  7         17  
  7         1232  
  22         36  
70 22         1728 eval "$fmt->new()";
71 22 100 66     174 if ( $@ and $@ =~ m/locate/ ) {
    50          
72 2     2   126 eval "use $fmt";
  2         1139  
  2         7  
  2         51  
73 2 50       26 die "$@\n" if $@;
74             } elsif ($@) {
75 0 0       0 die "$@\n" if $@;
76             }
77             }
78 22         219 return $fmt;
79             }
80              
81              
82             package DBI::Format::Base;
83              
84 7     7   58 use DBI qw(:sql_types);
  7         14  
  7         9521  
85              
86             # DBI::Format::Foo objects are presently copies of the parent DBI::Shell
87             # session hashref at the time of instantiation, and so are not aware of
88             # `/option' updates to the parent thereafter. Check the ->{parent} member
89             # for any session-specific /option values.
90              
91             sub new {
92 42     42   90 my $class = shift;
93 42 100       131 my $self = (@_ == 1) ? { %{$_[0]}, parent => $_[0] } : { @_ };
  22         510  
94 42   33     224 bless ($self, (ref($class) || $class));
95 42         360 $self;
96             }
97              
98             # Basic preparation for output, setting up 'fh', 'sth', 'rows' and possibly
99             # 'sep' members. Also caches SQL type information and sets up BOOLEAN
100             # formatting, if needed.
101             sub header {
102 53     53   135 my ($self, $sth, $fh, $sep) = @_;
103 53         79 my $types;
104              
105 53         188 $self->{fh} = $self->setup_fh($fh);
106 53         256 $self->{sth} = $sth;
107 53         118 $self->{rows} = 0;
108 53 100       172 $self->{sep} = $sep if defined $sep;
109              
110 53         317 $self->{__dbi_format_sql_types} = $types = $sth->{TYPE};
111              
112             # Parent DBI::Shell session may have changed `/option bool_format'
113             # since the last query we formatted, so update our internal bool
114             # display data if needed.
115 53         1586 for my $t (@$types) {
116 259 50       618 next unless $t == SQL_BOOLEAN;
117             $self->{__dbi_format_bool_alterns} =
118 0         0 [ split(',', $self->{parent}->{bool_format}, 2) ];
119 0         0 last;
120             }
121              
122 53         109 $self;
123             }
124              
125             # $fmt->encode_value( $value_reference, $sql_type )
126             #
127             # Do not call directly. This method is called by DBI::Format::Base::row.
128             #
129             # Apply output encoding to a single, textual representation of a field
130             # value. This method is called _after_ NULLs and BOOLEANs have been
131             # stringified.
132             #
133             # Base implementation escapes \n, \t and \r and translates ASCII
134             # non-printables without regard to $sql_type (SQL_NUMERIC, SQL_VARCHAR,
135             # etc.). This is *not* ``safe'' for all terminals in all locales --
136             # the default is merely simple encoding.
137             #
138             # Subclasses may override to URI- or XML-encode certain data, for example.
139             #
140              
141             sub encode_value {
142 2315     2315   3427 my ($self, $value_ref, $sql_type) = @_;
143              
144 2315         3314 for ($$value_ref) {
145 2315 50       3737 last unless defined;
146 2315         4198 s/\n/\\n/g;
147 2315         2954 s/\t/\\t/g;
148 2315         2791 s/\r/\\r/g;
149 2315         4618 s/[\000-\037\177-\237]/./g;
150             }
151             }
152              
153             # $fmt->row( $row_ref )
154             #
155             # Basic preparation of row data, responsible for formatting NULLs and
156             # BOOLEANs according to `/option' values, and calling encode_value() on
157             # fields. As a convenience, also increments $fmt->{rows}.
158             #
159             # All subclasses should call this function from their overridden row()
160             # methods.
161             #
162             # Note that row() modifies its argument in place, so $row_ref should be
163             # a _copy_ of the (presumptively read-only) row from the active $sth.
164             #
165             sub row {
166 509     509   882 my ($self, $row) = @_;
167              
168 509         719 my $i = 0;
169 509         1092 for my $value (@$row) {
170 2315 100       3804 unless (defined $value) {
171 18         31 $value = $self->{parent}->{null_format};
172             }
173              
174 2315         3278 my $sql_type = $self->{__dbi_format_sql_types}->[$i];
175 2315 50       4559 if ($sql_type == SQL_BOOLEAN) {
176 0 0       0 $value = $self->{__dbi_format_bool_alterns}->[ $value ? 0 : 1 ];
177             }
178              
179 2315         3807 $self->encode_value(\$value, $sql_type);
180             } continue {
181 2315         3422 $i++;
182             }
183              
184 509         797 $self->{rows}++;
185 509 50       1999 return wantarray ? @$row : $row;
186             }
187              
188             sub setup_fh {
189 53     53   110 my ($self, $fh) = @_;
190              
191             # This method has grown confused as to what it's trying to do and why
192             # Partly because this module was written in pre-perl5.3 days
193             # the code in other methods originally did: $fh->print(...)
194             # because C didn't work reliably as a method call.
195             # Now the code uses C some of this may no longer be
196             # required. It's important that things like IO::Scalar handles work.
197              
198 53 0 33     157 return $self->{fh} if !$fh && $self->{fh};
199              
200 53   50     130 $fh ||= \*STDOUT;
201              
202 53 100       350 return $fh if ref($fh) =~ m/GLOB/;
203              
204 1 50       20 unless (UNIVERSAL::can($fh,'print')) { # not blessed
205 0         0 require FileHandle;
206 0         0 bless $fh => "FileHandle";
207             }
208              
209 1         5 return $fh;
210             }
211              
212              
213             sub trailer {
214 50     50   127 my($self) = @_;
215 50         150 my $fh = delete $self->{'fh'};
216 50         106 my $sth = delete $self->{'sth'};
217 50         107 my $rows = delete $self->{'rows'};
218 50         881 print $fh ("[$rows rows of $sth->{NUM_OF_FIELDS} fields returned]\n");
219 50         346 delete $self->{'sep'};
220             }
221              
222             sub _determine_width {
223 19     19   289 my($self , $type, $precision) = @_;
224              
225 19 50 66     218 my $width =
    50 33        
    50          
    50          
    50          
226             (!defined($type)) ? 0 : # Is type defined?
227             ($type == SQL_DATE) ? 8 : # Is type a Date?
228             ($type == SQL_INTEGER # Is type an Integer?
229             and defined $precision
230             and $precision > 15 ) ? 10 :
231             ($type == SQL_NUMERIC # Is type a Numeric?
232             and defined $precision
233             and $precision > 15 ) ? 10 :
234             defined($precision) ? $precision: 0; # Default 0
235              
236 19         68 return $width;
237             }
238              
239              
240             package DBI::Format::Neat;
241              
242             @DBI::Format::Neat::ISA = qw(DBI::Format::Base);
243              
244             sub header {
245 26     26   121 my ($self, $sth, $fh, $sep) = @_;
246 26         144 $self->SUPER::header($sth, $fh, $sep);
247 26         36 print {$self->{fh}} (join($self->{sep}, @{$sth->{'NAME'}}), "\n");
  26         58  
  26         1193  
248             }
249              
250             sub row {
251 249     249   439 my($self, $rowref) = @_;
252 249         806 my @row = $self->SUPER::row([@$rowref]);
253 249         565 my $fh = $self->{'fh'};
254 249         751 print $fh (DBI::neat_list(\@row, 9999, $self->{sep}),"\n");
255             }
256              
257              
258              
259             package DBI::Format::Box;
260              
261 7     7   61 use DBI qw(:sql_types);
  7         35  
  7         6530  
262              
263             @DBI::Format::Box::ISA = qw(DBI::Format::Base);
264              
265             sub header {
266 1     1   4 my($self, $sth, $fh, $sep) = @_;
267 1         9 $self->SUPER::header($sth, $fh, $sep);
268 1         5 my $types = $sth->{'TYPE'};
269 1         15 my @right_justify;
270             my @widths;
271 1         19 my $names = $sth->{'NAME'};
272 1         3 my $type;
273 1         9 for (my $i = 0; $i < $sth->{'NUM_OF_FIELDS'}; $i++) {
274 14 50       38 push(@widths, defined($names->[$i]) ? length($names->[$i]) : 0);
275 14         21 $type = $types->[$i];
276 14   66     160 push(@right_justify,
277             (defined($type) and ($type == SQL_NUMERIC ||
278             $type == SQL_DECIMAL ||
279             $type == SQL_INTEGER ||
280             $type == SQL_SMALLINT ||
281             $type == SQL_FLOAT ||
282             $type == SQL_REAL ||
283             $type == SQL_TINYINT))
284             );
285             }
286 1         5 $self->{'widths'} = \@widths;
287 1         5 $self->{'right_justify'} = \@right_justify;
288             }
289              
290              
291             sub row {
292 10     10   22 my($self, $orig_row) = @_;
293 10         14 my $i = 0;
294 10         13 my $col;
295 10         17 my $widths = $self->{'widths'};
296 10         45 my @row = $self->SUPER::row([@$orig_row]); # don't mess with the original row
297 10         34 for (@row) {
298 140 100       229 if (length > $widths->[$i]) {
299 12         16 $widths->[$i] = length;
300             }
301 140         171 ++$i;
302             }
303 10         19 push @{$self->{data}}, \@row;
  10         41  
304             }
305              
306              
307             sub trailer {
308 1     1   2 my $self = shift;
309 1         4 my $widths = delete $self->{'widths'};
310 1         3 my $right_justify = delete $self->{'right_justify'};
311 1         6 my $sth = $self->{'sth'};
312 1         2 my $data = $self->{'data'};
313 1         2 $self->{'rows'} = @$data;
314              
315 1         3 my $format_sep = '+';
316 1         2 my $format_names = '|';
317 1         2 my $format_rows = '|';
318 1         11 for (my $i = 0; $i < $sth->{'NUM_OF_FIELDS'}; $i++) {
319 14         34 $format_sep .= ('-' x $widths->[$i]) . '+';
320 14         31 $format_names .= sprintf("%%-%ds|", $widths->[$i]);
321 14 100       75 $format_rows .= sprintf("%%"
322             . ($right_justify->[$i] ? "" : "-") . "%ds|",
323             $widths->[$i]);
324             }
325 1         4 $format_sep .= "\n";
326 1         1 $format_names .= "\n";
327 1         2 $format_rows .= "\n";
328              
329 1         15 my $fh = $self->{'fh'};
330 1         42 print $fh ($format_sep);
331 1         14 print $fh (sprintf($format_names, @{$sth->{'NAME'}}));
  1         20  
332 1         7 foreach my $row (@$data) {
333 10         65 print $fh ($format_sep);
334 10         97 print $fh (sprintf($format_rows, @$row));
335             }
336 1         19 print $fh ($format_sep);
337              
338 1         16 $self->SUPER::trailer(@_);
339             }
340              
341             package DBI::Format::PartBox;
342              
343 7     7   76 use DBI qw(:sql_types);
  7         14  
  7         14878  
344              
345             @DBI::Format::PartBox::ISA = qw(DBI::Format::Base);
346              
347             sub header {
348 0     0   0 my ($self, $sth, $fh, $sep) = @_;
349 0         0 $self->SUPER::header($sth, $fh, $sep);
350 0         0 my $types = $sth->{'TYPE'};
351 0         0 my @right_justify;
352             my @widths;
353 0         0 my $names = $sth->{'NAME'};
354 0         0 my $type;
355 0         0 for (my $i = 0; $i < $sth->{'NUM_OF_FIELDS'}; $i++) {
356 0 0       0 push(@widths, defined($names->[$i]) ? length($names->[$i]) : 0);
357 0         0 $type = $types->[$i];
358 0   0     0 push(@right_justify,
359             ($type == SQL_NUMERIC ||
360             $type == SQL_DECIMAL ||
361             $type == SQL_INTEGER ||
362             $type == SQL_SMALLINT ||
363             $type == SQL_FLOAT ||
364             $type == SQL_REAL ||
365             $type == SQL_TINYINT));
366             }
367 0         0 $self->{'widths'} = \@widths;
368 0         0 $self->{'right_justify'} = \@right_justify;
369             }
370              
371              
372             sub row {
373 0     0   0 my($self, $orig_row) = @_;
374 0         0 my $i = 0;
375 0         0 my $col;
376 0         0 my $widths = $self->{'widths'};
377 0         0 my @row = $self->SUPER::row([@$orig_row]); # don't mess with the original row
378 0         0 for (@row) {
379 0 0       0 if (length > $widths->[$i]) {
380 0         0 $widths->[$i] = length;
381             }
382 0         0 ++$i;
383             }
384 0         0 push @{$self->{data}}, \@row;
  0         0  
385             }
386              
387              
388             sub trailer {
389 0     0   0 my $self = shift;
390 0         0 my $widths = delete $self->{'widths'};
391 0         0 my $right_justify = delete $self->{'right_justify'};
392 0         0 my $sth = $self->{'sth'};
393 0         0 my $data = $self->{'data'};
394 0         0 $self->{'rows'} = @$data;
395              
396 0         0 my $format_sep = '+';
397 0         0 my $format_names = '|';
398 0         0 my $format_rows = '|';
399 0         0 for (my $i = 0; $i < $sth->{'NUM_OF_FIELDS'}; $i++) {
400 0         0 $format_sep .= ('-' x $widths->[$i]) . '+';
401 0         0 $format_names .= sprintf("%%-%ds|", $widths->[$i]);
402 0 0       0 $format_rows .= sprintf("%%"
403             . ($right_justify->[$i] ? "" : "-") . "%ds|",
404             $widths->[$i]);
405             }
406 0         0 $format_sep .= "\n";
407 0         0 $format_names .= "\n";
408 0         0 $format_rows .= "\n";
409              
410 0         0 my $fh = $self->{'fh'};
411 0         0 print $fh ($format_sep);
412 0         0 print $fh (sprintf($format_names, @{$sth->{'NAME'}}));
  0         0  
413 0         0 print $fh ($format_sep);
414 0         0 foreach my $row (@$data) {
415             # print $fh ($format_sep);
416 0         0 print $fh (sprintf($format_rows, @$row));
417             }
418 0         0 print $fh ($format_sep);
419              
420 0         0 $self->SUPER::trailer(@_);
421             }
422              
423             package DBI::Format::Raw;
424              
425             @DBI::Format::Raw::ISA = qw(DBI::Format::Base);
426              
427             sub header {
428 1     1   5 my ($self, $sth, $fh, $sep) = @_;
429 1         28 $self->SUPER::header($sth, $fh, $sep);
430 1         2 print {$self->{fh}} (join($self->{sep}, @{$sth->{'NAME'}}), "\n");
  1         4  
  1         42  
431             }
432              
433             sub row {
434 10     10   19 my($self, $rowref) = @_;
435 10         37 local $^W = 0;
436 10         33 my @row = @$rowref;
437 10         19 my $fh = $self->{'fh'};
438 10         263 print $fh (join($self->{sep}, @row), "\n");
439             }
440              
441             package DBI::Format::String;
442              
443             @DBI::Format::String::ISA = qw(DBI::Format::Base);
444              
445             sub header {
446 1     1   4 my ($self, $sth, $fh, $sep) = @_;
447 1         9 $self->SUPER::header($sth, $fh, $sep);
448 1         5 my $types = $sth->{'TYPE'};
449 1         14 my @right_justify;
450             my @widths;
451 1         13 my $names = $sth->{'NAME'};
452 1         3 my $type;
453 1         10 for (my $i = 0; $i < $sth->{'NUM_OF_FIELDS'}; $i++) {
454 14         37 $type = $types->[$i];
455             push(@widths, $self->_determine_width(
456 14         57 $type, $sth->{PRECISION}->[$i] ));
457              
458 14   66     124 push(@right_justify,
459             (defined($type) and ($type == DBI::SQL_NUMERIC() ||
460             $type == DBI::SQL_DECIMAL() ||
461             $type == DBI::SQL_INTEGER() ||
462             $type == DBI::SQL_SMALLINT() ||
463             $type == DBI::SQL_FLOAT() ||
464             $type == DBI::SQL_REAL() ||
465             $type == DBI::SQL_TINYINT()))
466             );
467 14         22 my $format_names;
468 14         49 $format_names .= sprintf("%%-%ds ", $widths[$i]);
469 14         16 print {$self->{fh}} (sprintf($format_names, $names->[$i]));
  14         512  
470             }
471 1         5 $self->{'widths'} = \@widths;
472 1         3 $self->{'right_justify'} = \@right_justify;
473 1         2 print {$self->{fh}} "\n";
  1         12  
474              
475             }
476              
477              
478             sub row {
479 10     10   32 my($self, $orig_row) = @_;
480 10         17 my $i = 0;
481 10         14 my $col;
482 10         15 my $widths = $self->{'widths'};
483 10         13 my $right_justify = $self->{'right_justify'};
484 10         43 my @row = $self->SUPER::row([@$orig_row]); # don't mess with the original row
485              
486 10         29 my $sth = $self->{'sth'};
487 10         16 my $format_rows = ' ';
488 10         64 for (my $i = 0; $i < $sth->{'NUM_OF_FIELDS'}; $i++) {
489 140 100       715 $format_rows .= sprintf("%%"
490             . ($right_justify->[$i] ? "" : "-") . "%ds ",
491             $widths->[$i]);
492             }
493 10         29 $format_rows .= "\n";
494              
495 10         15 my $fh = $self->{'fh'};
496 10         421 print $fh (sprintf($format_rows, @row));
497             }
498              
499              
500             sub trailer {
501 1     1   2 my $self = shift;
502 1         4 my $widths = delete $self->{'widths'};
503 1         2 my $right_justify = delete $self->{'right_justify'};
504 1         7 $self->SUPER::trailer(@_);
505             }
506              
507             package DBI::Format::HTML;
508              
509             @DBI::Format::HTML::ISA = qw(DBI::Format::Base);
510              
511             sub header {
512 1     1   5 my($self, $sth, $fh) = @_;
513 1         9 $self->SUPER::header($sth, $fh);
514 1         5 $self->{'data'} = [];
515 1         4 my $types = $sth->{'TYPE'};
516 1         14 my @right_justify;
517             my @widths;
518 1         4 my $names = $sth->{'NAME'};
519 1         3 my $type;
520 1         8 for (my $i = 0; $i < $sth->{'NUM_OF_FIELDS'}; $i++) {
521 14 50       35 push(@widths, defined($names->[$i]) ? length($names->[$i]) : 0);
522 14         19 $type = $types->[$i];
523 14   66     166 push(@right_justify,
524             (defined $type and ($type == DBI::SQL_NUMERIC() ||
525             $type == DBI::SQL_DECIMAL() ||
526             $type == DBI::SQL_INTEGER() ||
527             $type == DBI::SQL_SMALLINT() ||
528             $type == DBI::SQL_FLOAT() ||
529             $type == DBI::SQL_REAL() ||
530             $type == DBI::SQL_TINYINT()))
531             );
532             }
533 1         4 $self->{'widths'} = \@widths;
534 1         5 $self->{'right_justify'} = \@right_justify;
535             }
536              
537              
538             sub row {
539 10     10   19 my($self, $orig_row) = @_;
540 10         14 my $i = 0;
541 10         12 my $col;
542 10         17 my $widths = $self->{'widths'};
543 10         34 my @row = $self->SUPER::row([@$orig_row]); # don't mess with the original row
544 10         28 for (@row) {
545 140 100       224 if (length($_) > $widths->[$i]) {
546 12         16 $widths->[$i] = length($_);
547             }
548 140         170 ++$i;
549             }
550 10         13 push @{$self->{data}}, \@row;
  10         37  
551             }
552              
553              
554             sub trailer {
555 1     1   3 my $self = shift;
556 1         3 my $widths = delete $self->{'widths'};
557 1         3 my $right_justify = delete $self->{'right_justify'};
558 1         2 my $sth = $self->{'sth'};
559 1         2 my $data = $self->{'data'};
560 1         3 $self->{'rows'} = @$data;
561              
562 1         3 my $format_sep = '+';
563 1         2 my $format_names = '
564 1         2 my $format_rows = '
565 1         10 for (my $i = 0; $i < $sth->{'NUM_OF_FIELDS'}; $i++) {
566 14         38 $format_names .= sprintf("%%-%ds
567 14 100       74 $format_rows .= sprintf("%%"
568             . ($right_justify->[$i] ? "" : "-") . "%ds
569             $widths->[$i]);
570             }
571 1         3 $format_sep .= "\n";
572 1         2 $format_names .= "
573 1         2 $format_rows .= "
574              
575 1         3 my $fh = $self->{'fh'};
576 1         37 print $fh("\n");
577 1         13 print $fh(sprintf($format_names, @{$sth->{'NAME'}}));
  1         25  
578 1         7 foreach my $row (@$data) {
579 10         91 print $fh (sprintf($format_rows, @$row));
580             }
581 1         8 print $fh ("
\n");
582              
583 1         8 $self->SUPER::trailer(@_);
584             }
585              
586              
587             1;
588              
589             =head1 NAME
590              
591             DBI::Format - A package for displaying result tables
592              
593             =head1 SYNOPSIS
594              
595             # create a new result object
596             $r = DBI::Format->new('var1' => 'val1', ...);
597              
598             # Prepare it for output by creating a header
599             $r->header($sth, $fh);
600              
601             # In a loop, display rows
602             while ($ref = $sth->fetchrow_arrayref()) {
603             $r->row($ref);
604             }
605              
606             # Finally create a trailer
607             $r->trailer();
608              
609              
610             =head1 DESCRIPTION
611              
612             THIS PACKAGE IS STILL VERY EXPERIMENTAL. THINGS WILL CHANGE.
613              
614             This package is used for making the output of DBI::Shell configurable.
615             The idea is to derive a subclass for any kind of output table you might
616             create. Examples are
617              
618             =over 8
619              
620             =item *
621              
622             a very simple output format as offered by DBI::neat_list().
623             L<"AVAILABLE SUBCLASSES">.
624              
625             =item *
626              
627             a box format, as offered by the Data::ShowTable module.
628              
629             =item *
630              
631             HTML format, as used in CGI binaries
632              
633             =item *
634              
635             postscript, to be piped into lpr or something similar
636              
637             =back
638              
639             In the future the package should also support interactive methods, for
640             example tab completion.
641              
642             These are the available methods:
643              
644             =over 8
645              
646             =item new(@attr)
647              
648             =item new(\%attr)
649              
650             (Class method) This is the constructor. You'd rather call a subclass
651             constructor. The construcor is accepting either a list of key/value
652             pairs or a hash ref.
653              
654             =item header($sth, $fh)
655              
656             (Instance method) This is called when a new result table should be
657             created to display the results of the statement handle B<$sth>. The
658             (optional) argument B<$fh> is an IO handle (or any object supporting
659             a I method), usually you use an IO::Wrap object for STDIN.
660              
661             The method will query the B<$sth> for its I, I,
662             I, I and I attributes and typically print a
663             header. In general you should not assume that B<$sth> is indeed a DBI
664             statement handle and better treat it as a hash ref with the above
665             attributes.
666              
667             =item row($ref)
668              
669             (Instance method) Prints the contents of the array ref B<$ref>. Usually
670             you obtain this array ref by calling B<$sth-Efetchrow_arrayref()>.
671              
672             =item trailer
673              
674             (Instance method) Once you have passed all result rows to the result
675             package, you should call the I method. This method can, for
676             example print the number of result rows.
677              
678             =back
679              
680              
681             =head1 AVAILABLE SUBCLASSES
682              
683             First of all, you can use the DBI::Format package itself: It's
684             not an abstract base class, but a very simple default using
685             DBI::neat_list().
686              
687              
688             =head2 Ascii boxes
689              
690             This subclass is using the I mode of the I module
691             internally. L.
692              
693             =head2 Raw
694              
695             Row is written without formating. Columns returned in comma or user defined
696             separated list.
697              
698             =head2 String
699              
700             Row is written using a string format. Future releases will include th ability
701             set the string format.
702              
703              
704             =head1 AUTHOR AND COPYRIGHT
705              
706             This module is Copyright (c) 1997, 1998
707              
708             Jochen Wiedmann
709             Am Eisteich 9
710             72555 Metzingen
711             Germany
712              
713             Email: joe@ispsoft.de
714             Phone: +49 7123 14887
715              
716             The DBD::Proxy module is free software; you can redistribute it and/or
717             modify it under the same terms as Perl itself.
718              
719              
720             =head1 SEE ALSO
721              
722             L, L, L