| RDF-Query documentation | Contained in the RDF-Query distribution. |
RDF::Query::Node::Resource - RDF Node class for resources
This document describes RDF::Query::Node::Resource version 2.907.
Beyond the methods documented below, this class inherits methods from the RDF::Query::Node and RDF::Trine::Node::Resource classes.
as_sparqlReturns the SPARQL string for this node.
as_hashReturns the query as a nested set of plain data structures (no objects).
Gregory Todd Williams <gwilliams@cpan.org>
| RDF-Query documentation | Contained in the RDF-Query distribution. |
# RDF::Query::Node::Resource # -----------------------------------------------------------------------------
package RDF::Query::Node::Resource; use strict; use warnings; no warnings 'redefine'; use base qw(RDF::Query::Node RDF::Trine::Node::Resource); use URI; use Data::Dumper; use Scalar::Util qw(blessed reftype); use Carp qw(carp croak confess); ###################################################################### our ($VERSION); BEGIN { $VERSION = '2.907'; } ######################################################################
use overload '<=>' => \&_cmp, 'cmp' => \&_cmp, '<' => sub { _cmp(@_) == -1 }, '>' => sub { _cmp(@_) == 1 }, '!=' => sub { _cmp(@_) != 0 }, '==' => sub { _cmp(@_) == 0 }, '+' => sub { $_[0] }, '""' => sub { $_[0]->sse }, ; sub _cmp { my $a = shift; my $b = shift; return 1 unless blessed($b); return -1 if ($b->isa('RDF::Query::Node::Literal')); return 1 if ($b->isa('RDF::Query::Node::Blank')); return 0 unless ($b->isa('RDF::Query::Node::Resource')); my $cmp = $a->uri_value cmp $b->uri_value; return $cmp; }
sub as_sparql { my $self = shift; my $context = shift || {}; my $ns = $context->{ namespaces } || {}; my %ns = %$ns; return $self->sse( { namespaces => \%ns } ); }
sub as_hash { my $self = shift; my $context = shift; return { type => 'node', iri => $self->uri_value, }; } 1; __END__