| 1 | |||||||||||||||||||||||||||||
| 2 | package VoiceXML::Client::Item::If; | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use base qw (VoiceXML::Client::Item); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use VoiceXML::Client::Util; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use VoiceXML::Client::Item::Util; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | Copyright (C) 2007,2008 by Pat Deegan. | ||||||||||||||||||||||||||||
| 14 | All rights reserved | ||||||||||||||||||||||||||||
| 15 | http://voicexml.psychogenic.com | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | This library is released under the terms of the GNU GPL version 3, making it available only for | ||||||||||||||||||||||||||||
| 18 | free programs ("free" here being used in the sense of the GPL, see http://www.gnu.org for more details). | ||||||||||||||||||||||||||||
| 19 | Anyone wishing to use this library within a proprietary or otherwise non-GPLed program MUST contact psychogenic.com to | ||||||||||||||||||||||||||||
| 20 | acquire a distinct license for their application. This approach encourages the use of free software | ||||||||||||||||||||||||||||
| 21 | while allowing for proprietary solutions that support further development. | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | This file is part of VoiceXML::Client. | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | VoiceXML::Client is free software: you can redistribute it and/or modify | ||||||||||||||||||||||||||||
| 29 | it under the terms of the GNU General Public License as published by | ||||||||||||||||||||||||||||
| 30 | the Free Software Foundation, either version 3 of the License, or | ||||||||||||||||||||||||||||
| 31 | (at your option) any later version. | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | VoiceXML::Client is distributed in the hope that it will be useful, | ||||||||||||||||||||||||||||
| 34 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||||||||||
| 35 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||||||||||||||||||||||||
| 36 | GNU General Public License for more details. | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | You should have received a copy of the GNU General Public License | ||||||||||||||||||||||||||||
| 39 | along with VoiceXML::Client. If not, see <http://www.gnu.org/licenses/>. | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | =cut | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 3 | ▶ | use vars qw{ | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 50 | $VERSION | ||||||||||||||||||||||||||||
| 51 | 3 | }; | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 3 | $VERSION = $VoiceXML::Client::Item::VERSION; | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 1 | ▶ | sub init { | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||
| 59 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 1 | my $cond = $self->{'XMLElement'}->attribute('cond'); | |||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 1 | ▶ | unless (defined $cond) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | { | ||||||||||||||||||||||||||||
| 65 | 0 | VoiceXML::Client::Util::log_msg("No condition set in IF clause"); | |||||||||||||||||||||||||||
| 66 | 0 | return undef; | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 1 | $self->{'cond'} = $cond; | |||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 1 | return 1; | |||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | ▶ | sub execute { | ||||||||||||||||||||||||||
|
Subroutine
execute: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 78 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 79 | 0 | my $handle = shift; | |||||||||||||||||||||||||||
| 80 | 0 | my $optParms = shift; | |||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 0 | my $vxmlDoc = $self->getParentVXMLDocument(); | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 0 | $self->reset(); | |||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | # check if the IF condition is met... | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 0 | ▶ | if ($self->evaluateCondition($self->{'cond'}, $vxmlDoc)) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 89 | { | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 0 | ▶ | while (my $curChild = $self->getNextSameLevelChild()) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | { | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 0 | my $rv = $curChild->execute($handle, $optParms); | |||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 0 | ▶ | return $rv if ($rv != $VoiceXML::Client::Flow::Directive{'CONTINUE'}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 0 | return $VoiceXML::Client::Flow::Directive{'CONTINUE'}; | |||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | # if condition not met... if we have any kids | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 0 | ▶ | while (my $condChild = $self->getNextConditionChild()) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 106 | { | ||||||||||||||||||||||||||||
| 107 | 0 | my $matchFound = 0; | |||||||||||||||||||||||||||
| 108 | 0 | ▶ | if (exists $condChild->{'cond'}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 109 | { | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 0 | ▶ | if ($self->evaluateCondition($condChild->{'cond'}, $vxmlDoc)) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 112 | { | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | # we've found a good one. | ||||||||||||||||||||||||||||
| 115 | 0 | $matchFound = 1; | |||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||
| 117 | } else { | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | # it's an else... | ||||||||||||||||||||||||||||
| 120 | 0 | $matchFound = 1; | |||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 0 | ▶ | if ($matchFound) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 124 | { | ||||||||||||||||||||||||||||
| 125 | # got a good one... | ||||||||||||||||||||||||||||
| 126 | 0 | ▶ | while (my $sChild = $self->getNextSameLevelChild()) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 127 | { | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | 0 | my $rv = $sChild->execute($handle, $optParms); | |||||||||||||||||||||||||||
| 130 | 0 | ▶ | return $rv if ($rv != $VoiceXML::Client::Flow::Directive{'CONTINUE'}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | # and we're done. | ||||||||||||||||||||||||||||
| 136 | 0 | return $VoiceXML::Client::Flow::Directive{'CONTINUE'}; | |||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | #if we get here... nothing matched/there's nothing to do. | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | 0 | return $VoiceXML::Client::Flow::Directive{'CONTINUE'}; | |||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | 0 | ▶ | sub getNextSameLevelChild { | ||||||||||||||||||||||||||
|
Subroutine
getNextSameLevelChild: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 148 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 0 | ▶ | while (my $curChild = $self->getCurrentChild()) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 151 | { | ||||||||||||||||||||||||||||
| 152 | 0 | $self->proceedToNextChild(); | |||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 0 | my $ctype = $curChild->getType() ; | |||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 0 | ▶ | if ($ctype eq 'VoiceXML::Client::Item::Elseif' | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ctype eq "VoiceXML::Client::Item::Elseif" or $ctype eq "VoiceXML::Client::Item::Else"
MC/DC0%0/2
$ctype eq "VoiceXML::Client::Item::Elseif" or $ctype eq "VoiceXML::Client::Item::Else"
$ctype eq "VoiceXML::Client::Item::Elseif"
$ctype eq "VoiceXML::Client::Item::Else"
Truth table0%0/3
A or B
A= $ctype eq "VoiceXML::Client::Item::Elseif"B= $ctype eq "VoiceXML::Client::Item::Else"
| |||||||||||||||||||||||||||||
| 158 | || $ctype eq 'VoiceXML::Client::Item::Else') | ||||||||||||||||||||||||||||
| 159 | { | ||||||||||||||||||||||||||||
| 160 | # party's over... | ||||||||||||||||||||||||||||
| 161 | 0 | return undef; | |||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 0 | return $curChild ; | |||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | 0 | return undef; | |||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | 0 | ▶ | sub getNextConditionChild { | ||||||||||||||||||||||||||
|
Subroutine
getNextConditionChild: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 172 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 0 | ▶ | while (my $curChild = $self->getCurrentChild()) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 176 | { | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 0 | $self->proceedToNextChild(); | |||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | 0 | my $ctype = $curChild->getType() ; | |||||||||||||||||||||||||||
| 182 | 0 | ▶ | return $curChild if ($ctype eq 'VoiceXML::Client::Item::Elseif' | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ctype eq "VoiceXML::Client::Item::Elseif" or $ctype eq "VoiceXML::Client::Item::Else"
MC/DC0%0/2
$ctype eq "VoiceXML::Client::Item::Elseif" or $ctype eq "VoiceXML::Client::Item::Else"
$ctype eq "VoiceXML::Client::Item::Elseif"
$ctype eq "VoiceXML::Client::Item::Else"
Truth table0%0/3
A or B
A= $ctype eq "VoiceXML::Client::Item::Elseif"B= $ctype eq "VoiceXML::Client::Item::Else"
| |||||||||||||||||||||||||||||
| 183 | || $ctype eq 'VoiceXML::Client::Item::Else'); | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | 0 | return undef; | |||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | 0 | ▶ | sub evaluateCondition { | ||||||||||||||||||||||||||
|
Subroutine
evaluateCondition: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 192 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 193 | 0 | ▶ | my $condition = shift || ''; | ||||||||||||||||||||||||||
|
Condition0%0/2
shift() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 194 | 0 | ▶ | my $vxmlDoc = shift || $self->getParentVXMLDocument(); | ||||||||||||||||||||||||||
|
Condition0%0/3
shift() || $self->getParentVXMLDocument
MC/DC0%0/2
shift() || $self->getParentVXMLDocument
shift()
$self->getParentVXMLDocument
Truth table0%0/3
A || B
A= shift()B= $self->getParentVXMLDocument
| |||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | 0 | return VoiceXML::Client::Item::Util->evaluateCondition($self, $condition, $vxmlDoc); | |||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | 3 | 1; | |||||||||||||||||||||||||||