| Redland documentation | Contained in the Redland distribution. |
RDF::Redland::URI - Redland RDF URI Class
use RDF::Redland;
my $uri=new RDF::Redland::URI("http://example.com/");
my $uri2=RDF::Redland::URI->new_from_uri($uri);
print $uri2->as_string,"\n";
Represents a URI as a mostly-opaque object for identifying things in the RDF world. The URIs are also used for identifying features for the RDF::Redland::Parser and RDF::Redland::Serializer classes.
Create a new RDF::Redland::URI object from a URI string.
Copy a RDF::Redland::URI
Return the statement formatted as a string (UTF-8 encoded).
Return non zero if this uri is equal to URI
Create a new RDF::Redland::URI object from RDF::Redland::URI URI (copy constructor). Instead use:
$u=$uri->clone
Dave Beckett - http://purl.org/net/dajobe/
| Redland documentation | Contained in the Redland distribution. |
# -*- Mode: Perl -*- # # URI.pm - Redland Perl RDF URI module # # $Id: URI.pm 10593 2006-03-05 08:30:38Z dajobe $ # # Copyright (C) 2000-2005 David Beckett - http://purl.org/net/dajobe/ # Copyright (C) 2000-2005 University of Bristol - http://www.bristol.ac.uk/ # # This package is Free Software or Open Source available under the # following licenses (these are alternatives): # 1. GNU Lesser General Public License (LGPL) # 2. GNU General Public License (GPL) # 3. Mozilla Public License (MPL) # # See LICENSE.html or LICENSE.txt at the top of this package for the # full license terms. # # # package RDF::Redland::URI; use strict;
######################################################################
sub new ($$) { my($proto,$arg)=@_; my $class = ref($proto) || $proto; my $self = {}; if(my $arg_class=ref($arg)) { if(UNIVERSAL::isa($arg, 'RDF::Redland::URI')) { return $arg->clone; } elsif (UNIVERSAL::isa($arg, 'URI::URL')) { $arg=$arg->as_string; } else { die "RDF::Redland::URI::new - Cannot make a URI from an object of class $arg_class\n"; } } $self->{URI}=&RDF::Redland::CORE::librdf_new_uri($RDF::Redland::World->{WORLD},$arg); return undef if !$self->{URI}; bless ($self, $class); return $self; }
sub clone ($) { my($uri)=@_; my $class = ref($uri); my $self = {}; if(!$class || $class ne 'RDF::Redland::URI') { die "RDF::Redland::URI::clone - Cannot copy a URI object not of class RDF::Redland::URI\n"; } $self->{URI}=&RDF::Redland::CORE::librdf_new_uri_from_uri($uri->{URI}); return undef if !$self->{URI}; bless ($self, $class); return $self; } sub new_from_uri ($$) { my($proto,$uri)=@_; return $uri->clone; } sub _new_from_object ($$) { my($proto,$object)=@_; my $class = ref($proto) || $proto; my $self = {}; warn "RDF::Redland::URI->_new_from_object from object $object\n" if $RDF::Redland::Debug; $self->{URI}=$object; $self->{DONT_FREE_ME}=1; bless ($self, $class); return $self; }
sub DESTROY ($) { my $self=shift; warn "RDF::Redland::URI DESTROY\n" if $RDF::Redland::Debug; if($self->{URI}) { if(!$self->{DONT_FREE_ME}) { &RDF::Redland::CORE::librdf_free_uri($self->{URI}); } } }
sub as_string ($) { &RDF::Redland::CORE::librdf_uri_to_string(shift->{URI}); }
sub equals ($$) { my($self,$uri)=@_; &RDF::Redland::CORE::librdf_uri_equals($self->{URI}, $uri->{URI}); }
1;