File Coverage

blib/lib/ODO/Query/Constraint.pm
Criterion Covered Total %
statement 15 37 40.5
branch 0 18 0.0
condition 0 3 0.0
subroutine 5 7 71.4
pod 3 3 100.0
total 23 68 33.8


line stmt bran cond sub pod time code
1             #
2             # Copyright (c) 2006 IBM Corporation.
3             #
4             # All rights reserved. This program and the accompanying materials
5             # are made available under the terms of the Eclipse Public License v1.0
6             # which accompanies this distribution, and is available at
7             # http://www.eclipse.org/legal/epl-v10.html
8             #
9             # File: $Source: /var/lib/cvs/ODO/lib/ODO/Query/Constraint.pm,v $
10             # Created by: Stephen Evanchik( evanchik@us.ibm.com )
11             # Created on: 12/02/2004
12             # Revision: $Id: Constraint.pm,v 1.2 2009-11-25 17:53:53 ubuntu Exp $
13             #
14             # Contributors:
15             # IBM Corporation - initial API and implementation
16             #
17             package ODO::Query::Constraint;
18              
19 1     1   114357 use strict;
  1         3  
  1         37  
20 1     1   6 use warnings;
  1         2  
  1         38  
21              
22 1     1   6 use base qw/ODO/;
  1         2  
  1         110  
23 1     1   5 use vars qw /$VERSION/;
  1         3  
  1         473  
24             $VERSION = sprintf "%d.%02d", q$Revision: 1.2 $ =~ /: (\d+)\.(\d+)/;
25             __PACKAGE__->mk_accessors(qw/operation is_unary left right/);
26              
27             =head1 NAME
28              
29             ODO::Query::Constraint - A Constraint on a statement Query
30              
31             =head1 SYNOPSIS
32              
33             =head1 DESCRIPTION
34              
35             =head1 METHODS
36              
37             =over
38              
39             =item new( )
40              
41             =item left( )
42              
43             =item right( )
44              
45             =item is_unary( )
46              
47             =item is_terminal( )
48              
49             =cut
50              
51             sub is_terminal {
52 0     0 1 0 my $self = shift;
53            
54 0 0 0     0 if( !UNIVERSAL::isa($self->left(), 'ODO::Query::Constraint')
55             && !UNIVERSAL::isa($self->right(), 'ODO::Query::Constraint')) {
56            
57 0         0 return 1;
58             }
59            
60 0         0 return 0;
61             }
62              
63             =item print( )
64              
65             =cut
66              
67             sub print {
68 0     0 1 0 my ($self, $fh) = @_;
69            
70 0 0       0 $fh = \*STDERR
71             unless($fh);
72            
73 0 0       0 if($self->is_unary() ) {
74 0         0 print $fh $self->operation(), ' ';
75             }
76            
77 0 0       0 if($self->is_terminal()) {
78 0         0 print $fh $self->left()->value(), ' ';
79 0 0       0 print $fh $self->operation(), ' ', $self->right()->value(), ' '
80             if($self->right());
81             }
82             else {
83 0         0 my $lC = $self->left();
84 0         0 my $rC = $self->right();
85            
86 0 0       0 if(UNIVERSAL::isa($lC, 'ODO::Query::Constraint')) {
    0          
87 0         0 $lC->print($fh);
88             }
89             elsif(UNIVERSAL::isa($lC, 'ODO::Node')) {
90 0         0 print $fh $lC->value(), ' ';
91             }
92            
93 0 0       0 if(UNIVERSAL::isa($rC, 'ODO::Query::Constraint')) {
    0          
94 0         0 print $fh $self->operation(), ' ';
95            
96 0         0 print $fh ' ( ';
97 0         0 $rC->print($fh);
98 0         0 print $fh ' ) ';
99             }
100             elsif(UNIVERSAL::isa($rC, 'ODO::Node')) {
101 0         0 print $fh $self->operation(), ' ', $rC->value(), ' ';
102             }
103            
104             }
105             }
106              
107             sub init {
108 45     45 1 143429 my ($self, $config) = @_;
109 45         194 $self->params($config, qw/left right is_unary operation/);
110 45         22043 return $self;
111             }
112              
113             =back
114              
115             =head1 AUTHOR
116              
117             IBM Corporation
118              
119             =head1 COPYRIGHT
120              
121             Copyright (c) 2006 IBM Corporation.
122              
123             All rights reserved. This program and the accompanying materials
124             are made available under the terms of the Eclipse Public License v1.0
125             which accompanies this distribution, and is available at
126             http://www.eclipse.org/legal/epl-v10.html
127              
128             =cut
129              
130             1;
131              
132             __END__