/usr/share/perl5/RDF/Trine/Iterator/Boolean.pm is in librdf-trine-perl 1.019-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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | # RDF::Trine::Iterator::Boolean
# -----------------------------------------------------------------------------
=head1 NAME
RDF::Trine::Iterator::Boolean - Iterator class for boolean query results
=head1 VERSION
This document describes RDF::Trine::Iterator::Boolean version 1.019
=head1 SYNOPSIS
use RDF::Trine::Iterator::Boolean;
my $iterator = RDF::Trine::Iterator::Boolean->new( [1] );
my $bool = $iterator->get_boolean;
if ($bool) {
print "Yes.\n";
}
=head1 METHODS
Beyond the methods documented below, this class inherits methods from the
L<RDF::Trine::Iterator> class.
=over 4
=cut
package RDF::Trine::Iterator::Boolean;
use strict;
use warnings;
no warnings 'redefine';
use JSON 2.0;
use base qw(RDF::Trine::Iterator);
our ($VERSION);
BEGIN {
$VERSION = '1.019';
}
=item C<new ( \@results, %args )>
=item C<new ( \&results, %args )>
Returns a new SPARQL Result interator object. Results must be either
an reference to an array containing results or a CODE reference that
acts as an iterator, returning successive items when called, and
returning undef when the iterator is exhausted.
$type should be one of: bindings, boolean, graph.
=cut
sub new {
my $class = shift;
my $stream = shift || sub { undef };
my %args = @_;
my $type = 'boolean';
return $class->SUPER::new( $stream, $type, [], %args );
}
sub _new {
my $class = shift;
my $stream = shift;
my $type = shift;
my $names = shift;
my %args = @_;
return $class->new( $stream, %args );
}
=item C<is_boolean>
Returns true if the underlying result is a boolean value.
=cut
sub is_boolean {
my $self = shift;
return 1;
}
=item C<as_string ( $max_size [, \$count] )>
Returns a string serialization of the stream data.
=cut
sub as_string {
my $self = shift;
my $value = $self->get_boolean ? 'true' : 'false';
return $value;
}
=item C<as_xml ( $max_size )>
Returns an XML serialization of the stream data.
=cut
sub as_xml {
my $self = shift;
my $value = $self->get_boolean ? 'true' : 'false';
my $xml = <<"END";
<?xml version="1.0" encoding="utf-8"?>
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
<head></head>
<boolean>${value}</boolean>
</sparql>
END
return $xml;
}
=item C<< print_xml ( $fh, $max_size ) >>
Prints an XML serialization of the stream data to the filehandle $fh.
=cut
sub print_xml {
my $self = shift;
my $fh = shift;
print {$fh} $self->as_xml;
}
=item C<as_json ( $max_size )>
Returns a JSON serialization of the stream data.
=cut
sub as_json {
my $self = shift;
my $max_result_size = shift || 0;
my $value = $self->get_boolean ? JSON::true : JSON::false;
my $data = { head => { vars => [] }, boolean => $value };
return to_json( $data );
}
=item C<< construct_args >>
Returns the arguments necessary to pass to the stream constructor _new
to re-create this stream (assuming the same closure as the first
=cut
sub construct_args {
my $self = shift;
my $type = $self->type;
my $args = $self->_args || {};
return ($type, [], %{ $args });
}
1;
__END__
=back
=head1 DEPENDENCIES
L<JSON|JSON>
L<Scalar::Util|Scalar::Util>
=head1 BUGS
Please report any bugs or feature requests to through the GitHub web interface
at L<https://github.com/kasei/perlrdf/issues>.
=head1 AUTHOR
Gregory Todd Williams C<< <gwilliams@cpan.org> >>
=head1 COPYRIGHT
Copyright (c) 2006-2012 Gregory Todd Williams. This
program is free software; you can redistribute it and/or modify it under
the same terms as Perl itself.
=cut
|