| RDF-Trine documentation | Contained in the RDF-Trine distribution. |
RDF::Trine::Node::Variable - RDF Node class for variables
This document describes RDF::Trine::Node::Variable version 0.135
Beyond the methods documented below, this class inherits methods from the RDF::Trine::Node class.
new ( $name )Returns a new Variable structure.
nameReturns the name of the variable.
sseReturns the SSE string for this variable.
as_stringReturns a string representation of the node.
valueReturns the variable name.
as_ntriplesReturns the node in a string form suitable for NTriples serialization.
typeReturns the type string of this node.
equal ( $node )Returns true if the two nodes are equal, false otherwise.
Gregory Todd Williams <gwilliams@cpan.org>
Copyright (c) 2006-2010 Gregory Todd Williams. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| RDF-Trine documentation | Contained in the RDF-Trine distribution. |
# RDF::Trine::Node::Variable # -----------------------------------------------------------------------------
package RDF::Trine::Node::Variable; use strict; use warnings; no warnings 'redefine'; use base qw(RDF::Trine::Node); use Data::Dumper; use Scalar::Util qw(blessed); use Carp qw(carp croak confess); ###################################################################### our ($VERSION); BEGIN { $VERSION = '0.135'; } ###################################################################### use overload '""' => sub { $_[0]->sse }, ;
sub new { my $class = shift; my $name = shift; return bless( [ $name ], $class ); }
sub name { my $self = shift; return $self->[0]; }
sub sse { my $self = shift; my $name = $self->name; return qq(?${name}); }
sub as_string { my $self = shift; return '?' . $self->name; }
sub value { my $self = shift; return $self->name; }
sub as_ntriples { my $self = shift; throw RDF::Trine::Error::UnimplementedError -text => "Variable nodes aren't allowed in NTriples"; }
sub type { return 'VAR'; }
sub equal { my $self = shift; my $node = shift; return 0 unless (blessed($node) and $node->isa('RDF::Trine::Node')); return 0 unless ($self->type eq $node->type); return ($self->name eq $node->name); } # called to compare two nodes of the same type sub _compare { my $a = shift; my $b = shift; return ($a->name cmp $b->name); } 1; __END__