line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CQL::BooleanNode; |
2
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
58
|
use strict; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
353
|
|
4
|
9
|
|
|
9
|
|
51
|
use warnings; |
|
9
|
|
|
|
|
14
|
|
|
9
|
|
|
|
|
233
|
|
5
|
9
|
|
|
9
|
|
46
|
use base qw( CQL::Node ); |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
766
|
|
6
|
9
|
|
|
9
|
|
55
|
use CQL::Utils qw( indent xq renderPrefixes ); |
|
9
|
|
|
|
|
103
|
|
|
9
|
|
|
|
|
10460
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
CQL::BooleanNode - represents a boolean node in a CQL parse tree |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
n/a |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 DESCRIPTION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Base class for boolean nodes in a CQL parse tree. See CQL::AndNode |
19
|
|
|
|
|
|
|
and CQL::OrNode. CQL::BooleanNode inherits from CQL::Node. Typically |
20
|
|
|
|
|
|
|
you'll want to use CQL::AndNode or CQL::OrNode to instantiate the |
21
|
|
|
|
|
|
|
object. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 METHODS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head2 new() |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
You must pass in both a left and right parameter, which should be |
28
|
|
|
|
|
|
|
CQL::Node objects. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub new { |
33
|
37
|
|
|
37
|
1
|
1174
|
my ( $class, %args ) = @_; |
34
|
37
|
|
33
|
|
|
660
|
return bless { left => $args{left}, right => $args{right} }, |
35
|
|
|
|
|
|
|
ref($class) || $class; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 left() |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub left { |
43
|
47
|
|
|
47
|
1
|
325
|
return shift->{left}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 right() |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub right { |
51
|
47
|
|
|
47
|
1
|
90
|
return shift->{right}; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 toCQL() |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub toCQL { |
59
|
29
|
|
|
29
|
1
|
8354
|
my $self = shift; |
60
|
29
|
|
|
|
|
119
|
my $left = $self->left(); |
61
|
29
|
|
|
|
|
108
|
my $right = $self->right(); |
62
|
|
|
|
|
|
|
## return: (left) op (right) |
63
|
|
|
|
|
|
|
return |
64
|
29
|
|
|
|
|
105
|
'(' . $left->toCQL() . ') ' . |
65
|
|
|
|
|
|
|
$self->op() . |
66
|
|
|
|
|
|
|
' (' . $right->toCQL() . ')'; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 toSwish() |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub toSwish { |
74
|
5
|
|
|
5
|
1
|
79
|
my $self = shift; |
75
|
5
|
|
|
|
|
17
|
my $left = $self->left(); |
76
|
5
|
|
|
|
|
16
|
my $right = $self->right(); |
77
|
5
|
100
|
|
|
|
41
|
my $leftStr = $left->isa('CQL::TermNode') ? $left->toSwish() |
78
|
|
|
|
|
|
|
: '('.$left->toSwish().')'; |
79
|
5
|
50
|
|
|
|
25
|
my $rightStr = $right->isa('CQL::TermNode') ? $right->toSwish() |
80
|
|
|
|
|
|
|
: '('.$right->toSwish().')'; |
81
|
5
|
|
|
|
|
24
|
return $leftStr . " " . $self->op() . " " . $rightStr; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 toXCQL() |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub toXCQL { |
89
|
2
|
|
|
2
|
1
|
5
|
my ($self,$level,@prefixes) = @_; |
90
|
2
|
50
|
|
|
|
9
|
$level = 0 if ! $level; |
91
|
2
|
|
|
|
|
28
|
my $left = $self->left(); |
92
|
2
|
|
|
|
|
13
|
my $right = $self->right(); |
93
|
2
|
|
|
|
|
11
|
my $xml = |
94
|
|
|
|
|
|
|
indent($level)."\n". |
95
|
|
|
|
|
|
|
renderPrefixes($level+1,@prefixes). |
96
|
|
|
|
|
|
|
$self->opXCQL($level+1). |
97
|
|
|
|
|
|
|
indent($level+1)."\n". |
98
|
|
|
|
|
|
|
$left->toXCQL($level+2). |
99
|
|
|
|
|
|
|
indent($level+1)."\n". |
100
|
|
|
|
|
|
|
indent($level+1)."\n". |
101
|
|
|
|
|
|
|
$right->toXCQL($level+2). |
102
|
|
|
|
|
|
|
indent($level+1)."\n". |
103
|
|
|
|
|
|
|
indent($level)."\n"; |
104
|
2
|
|
|
|
|
20
|
return $self->addNamespace( $level, $xml ); |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 toLucene() |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub toLucene { |
112
|
7
|
|
|
7
|
1
|
132
|
my $self = shift; |
113
|
7
|
|
|
|
|
34
|
my $left = $self->left(); |
114
|
7
|
|
|
|
|
31
|
my $right = $self->right(); |
115
|
7
|
100
|
|
|
|
71
|
my $leftStr = $left->isa('CQL::TermNode') ? $left->toLucene() |
116
|
|
|
|
|
|
|
: '('.$left->toLucene().')'; |
117
|
7
|
50
|
|
|
|
41
|
my $rightStr = $right->isa('CQL::TermNode') ? $right->toLucene() |
118
|
|
|
|
|
|
|
: '('.$right->toLucene().')'; |
119
|
|
|
|
|
|
|
|
120
|
7
|
100
|
|
|
|
39
|
return join( ' ', $leftStr, uc $self->op(), $rightStr ) if $self->op() !~ /prox/; |
121
|
|
|
|
|
|
|
|
122
|
2
|
|
|
|
|
12
|
my $distance = 1; |
123
|
2
|
100
|
|
|
|
6
|
$distance = $1 if $self->op() =~ /\/distance[=><]{1,2}(\d+)/; |
124
|
2
|
|
|
|
|
16
|
return "\"$leftStr $rightStr\"~$distance"; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub opXCQL { |
128
|
2
|
|
|
2
|
0
|
5
|
my ($self,$level) = @_; |
129
|
|
|
|
|
|
|
return |
130
|
2
|
|
|
|
|
14
|
indent($level)."\n". |
131
|
|
|
|
|
|
|
indent($level+1)."".xq($self->op())."\n". |
132
|
|
|
|
|
|
|
indent($level)."\n"; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
1; |