File Coverage

blib/lib/XML/DOM2/Element/CDATA.pm
Criterion Covered Total %
statement 18 36 50.0
branch 0 4 0.0
condition n/a
subroutine 6 16 37.5
pod 7 7 100.0
total 31 63 49.2


line stmt bran cond sub pod time code
1             package XML::DOM2::Element::CDATA;
2              
3             =head1 NAME
4              
5             XML::DOM2::Element::CDATA
6              
7             =head1 DESCRIPTION
8              
9             CDATA Element object class
10              
11             =head1 METHODS
12              
13             =cut
14              
15 3     3   20 use base "XML::DOM2::Element";
  3         4  
  3         348  
16              
17 3     3   21 use strict;
  3         5  
  3         106  
18 3     3   16 use warnings;
  3         6  
  3         341  
19              
20             use overload
21 0     0   0 '""' => sub { shift->auto_string( @_ ) },
22 0     0   0 'eq' => sub { shift->auto_eq( @_ ) },
23 3     3   171 'ne' => sub { not shift->auto_eq( @_ ) };
  3     0   7  
  3         53  
  0         0  
24              
25             =head2 $class->new( $text, %arguments )
26              
27             Create a new cdata object.
28              
29             =cut
30             sub new
31             {
32 12     12 1 29 my ($proto, $text, %args) = @_;
33 12         25 $args{'text'} = $text;
34 12         56 my $self = $proto->SUPER::new('cdata', %args);
35 12         55 return $self;
36             }
37              
38             =head2 $element->xmlify()
39              
40             Returns the text as a serialised xml string (serialisation)
41              
42             =cut
43             sub xmlify
44             {
45 0     0 1 0 my ($self, %p) = @_;
46 0         0 my $sep = $p{'seperator'};
47 0         0 my $text = $self->text();
48 0 0       0 if($self->{'notag'}) {
    0          
49 0         0 return $sep.''.$sep;
50             } elsif($self->{'noescape'}) {
51 0         0 return $text;
52             }
53 0         0 return $text;
54             }
55              
56             =head2 $element->text()
57              
58             Return plain text (UTF-8)
59              
60             =cut
61             sub text
62             {
63 7     7 1 11 my ($self) = @_;
64 7         26 return $self->{'text'};
65             }
66              
67             =head2 $element->setData( $text )
68              
69             Replace text data with $text.
70              
71             =cut
72             sub setData
73             {
74 0     0 1   my ($self, $text) = @_;
75 0           $self->{'text'} = $text;
76             }
77              
78             =head2 $element->appendData( $text )
79              
80             Append to the end of the data $text.
81              
82             =cut
83             sub appendData
84             {
85 0     0 1   my ($self, $text) = @_;
86 0           $self->{'text'} .= $text;
87             }
88              
89             =head2 $element->_can_contain_elements()
90              
91             The element can not contain sub elements.
92              
93             =cut
94 0     0     sub _can_contain_elements { 0 }
95              
96             =head2 $element->_can_contain_attributes()
97              
98             The element can not contain attributes
99              
100             =cut
101 0     0     sub _can_contain_attributes { 0 }
102              
103             =head1 OVERLOADED
104              
105             =head2 $object->auto_string()
106              
107             =cut
108 0     0 1   sub auto_string { return shift->text() }
109              
110             =head2 $object->auto_eq( $string )
111              
112             =cut
113 0     0 1   sub auto_eq { return shift->text() eq shift }
114              
115             =head1 COPYRIGHT
116              
117             Martin Owens, doctormo@cpan.org
118              
119             =head1 SEE ALSO
120              
121             L,L
122              
123             =cut
124             1;