File: Relation.pm

package info (click to toggle)
libcql-parser-perl 1.13-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 316 kB
  • sloc: perl: 2,388; makefile: 2
file content (105 lines) | stat: -rw-r--r-- 1,843 bytes parent folder | download | duplicates (4)
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
package CQL::Relation;

use strict;
use warnings;
use Class::Accessor;
use CQL::ModifierSet;
use base qw( CQL::Node );

=head1 NAME

CQL::Relation - object for CQL Relations

=head1 SYNOPSIS

=head1 DESCRIPTION

CQL::Relation represents the common CQL relation operations ( =, E<gt>, 
E<lt>, any, all and exact. In addition modifiers may be applied (stem, 
relevant, fuzzy, phonetic). The operators are passed into the constructor
as the base relation.

=head1 METHODS

=head2 new()

Creates a new CQL::Relation object with the specified base relation.

=cut

sub new {
    my ($class,$base) = @_;
    my $ms = CQL::ModifierSet->new( $base );
    return bless { modifierSet => $ms }, ref($class) || $class;
}

=head2 getBase()

Returns the base relation with which the CQL::Relation object was originally
created.

=cut

sub getBase {
    return shift->{modifierSet}->getBase();
}

=head2 addModifier()

Adds a new relation modifier to the specified CQLRelation.
Typical relation modifiers include relevant, fuzzy stem and phonetic.  
On the whole, these modifiers have a meaningful interpretation
only for the text relations.

=cut

sub addModifier {
    my ($self,$modifier) = @_;
    $self->{modifierSet}->addModifier( undef, $modifier );
}

=head2 getModifiers()

Returns a list of modifiers associated with a CQL relation.

=cut

sub getModifiers {
    return shift->{modifierSet}->getModifiers();
}

=head2 toCQL() 

=cut

sub toCQL {
    return shift->{modifierSet}->toCQL();
}

=head2 toSwish()

=cut

sub toSwish {
    return shift->{modifierSet}->toSwish();
}

=head2 toXCQL()

=cut

sub toXCQL {
    my ($self,$level) = @_;
    my $xml = $self->{modifierSet}->toXCQL( $level, "relation" );
    return $self->addNamespace( $level, $xml );
}

=head2 toLucene()

=cut

sub toLucene {
    return shift->{modifierSet}->toLucene();
}

1;