Xmldoom/ORB/Transport/JSON.pm untested

filter: Statementstmt 0.0% 0 / 26 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 44 CC 4 SCAR 22.2
CC
4
Cov
0%
write_object_list
20.0
new
2.0
get_mime_type
2.0
CRAP 9.2
1  
2 package Xmldoom::ORB::Transport::JSON;
3  
4 use JSON qw/ objToJson /;
5 use strict;
6  
7 sub new
8 {
9 bless {}, shift;
10 }
11  
12 sub get_mime_type
13 {
14 return "text/plain";
15 }
16  
17 sub write_object
18 {
19 my ($self, $object) = (shift, shift);
20  
21 print objToJson($object);
22 }
23  
24 sub write_object_list
25 {
26 my ($self, $rs, $count) = (shift, shift, shift);
27  
28 #
29 # NOTE: kind of a hack so that we can do this progressively.
30 #
31  
32 print "{'result':[";
33 my $first = 1;
34 while ( 1 )
35 {
36 if ( $rs->next() )
37 {
38 if ( $first )
39 {
40 $first = 0;
41 }
42 else
43 {
44 print ",";
45 }
46  
47 $self->write_object( $rs->get_row() );
48 }
49 else
50 {
51 # outta here, homes!
52 last;
53 }
54 }
55 print "]";
56  
57 if ( defined $count )
58 {
59 print ",'count':$count";
60 }
61  
62 print "}";
63 }
64  
65 sub write_count
66 {
67 my ($self, $count) = (shift, shift);
68  
69 print "{'count':$count}";
70 }
71  
72 1;
73