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