| RDF-Query documentation | Contained in the RDF-Query distribution. |
RDF::Query::Expression - Class for Expr expressions
This document describes RDF::Query::Expression version 2.907.
new ( $op, @operands )Returns a new Expr structure.
construct_argsReturns a list of arguments that, passed to this class' constructor, will produce a clone of this algebra pattern.
opReturns the operator of the expression.
operandsReturns a list of the operands of the expression.
sseReturns the SSE string for this algebra expression.
explainReturns a string serialization of the expression appropriate for display on the
command line. This method is primarily used by the explain method of
the subclasses of RDF::Query::Plan.
typeReturns the type of this algebra expression.
referenced_variablesReturns a list of the variable names used in this algebra expression.
Gregory Todd Williams <gwilliams@cpan.org>
| RDF-Query documentation | Contained in the RDF-Query distribution. |
# RDF::Query::Expression # -----------------------------------------------------------------------------
package RDF::Query::Expression; use strict; use warnings; no warnings 'redefine'; use base qw(RDF::Query::Algebra); use Data::Dumper; use Scalar::Util qw(blessed); use Carp qw(carp croak confess); ###################################################################### our ($VERSION); BEGIN { $VERSION = '2.907'; } ######################################################################
sub new { my $class = shift; my $op = shift; my @operands = @_; return bless( [ $op, @operands ], $class ); }
sub construct_args { my $self = shift; return ($self->op, $self->operands); }
sub op { my $self = shift; return $self->[0]; }
sub operands { my $self = shift; return @{ $self }[ 1 .. $#{ $self } ]; }
sub sse { my $self = shift; my $context = shift; return sprintf( '(%s %s)', $self->op, join(' ', map { $_->sse( $context ) } $self->operands), ); }
sub explain { my $self = shift; my $s = shift; my $count = shift; my $indent = $s x $count; my $type = $self->op; my $string = "${indent}${type}\n"; foreach my $p ($self->operands) { $string .= $p->explain( $s, $count+1 ); } return $string; }
sub type { return 'EXPR'; }
sub referenced_variables { my $self = shift; my @ops = $self->operands; my @vars; foreach my $o (@ops) { if ($o->isa('RDF::Query::Node::Variable')) { push(@vars, $o->name); } elsif ($o->isa('RDF::Query::Expression')) { push(@vars, $o->referenced_variables); } } return RDF::Query::_uniq(@vars); } 1; __END__