1URI::Nested(3pm) User Contributed Perl Documentation URI::Nested(3pm)
2
3
4
6 URI::Nested - Nested URIs
7
9 package URI::jdbc;
10 use parent 'URI::Nested';
11 sub prefix { 'jdbc' }
12 sub nested_class { undef }
13 sub subprotocol { shift->nested_uri->scheme(@_) }
14
15 package main;
16 my $jdbc_uri = URI->new('jdbc:oracle:scott/tiger@//myhost:1521/myservicename');
17 my $nested_uri = $jdbc_uri->nested_uri;
18
20 This class provides support for nested URIs, where the scheme is a
21 prefix, and the remainder of the URI is another URI. Examples include
22 JDBC URIs
23 <http://docs.oracle.com/cd/B14117_01/java.101/b10979/urls.htm#BEIJFHHB>
24 and database URIs <https://github.com/theory/uri-db>.
25
27 The following differences exist compared to the "URI" class interface:
28
29 Class Method
30 "prefix"
31
32 Returns the prefix to be used, which corresponds to the URI's scheme.
33 Defaults to the last part of class name.
34
35 "nested_class"
36
37 Returns the URI subclass to use for the nested URI. If defined, the
38 nested URI will always be coerced into this class if it is not
39 naturally an instance of this class or one of its subclasses.
40
41 Constructors
42 "new"
43
44 my $uri = URI::Nested->new($string);
45 my $uri = URI::Nested->new($string, $base);
46
47 Always returns a URI::Nested object. $base may be another URI object or
48 string. Unlike in URI's new(), schemes will always be applied to the
49 URI and the nested URI if they does not already schemes. And if
50 "nested_class" is defined, the nested URI will be coerced into that
51 class.
52
53 Accessors
54 "scheme"
55
56 my $scheme = $uri->scheme;
57 $uri->scheme( $new_scheme );
58
59 Gets or sets the scheme part of the URI. When setting the scheme, it
60 must always be the same as the value returned by "prefix" or an
61 exception will be thrown -- although the letter casing may vary. The
62 returned value is always lowercase.
63
64 "nested_uri"
65
66 my $nested_uri = $uri->nested_uri;
67
68 Returns the nested URI.
69
70 Instance Methods
71 "abs"
72
73 my $abs = $uri->abs( $base_uri );
74
75 Returns the URI::Nested object itself. Unlike URI's abs(),
76 $URI::ABS_ALLOW_RELATIVE_SCHEME is ignored.
77
78 "rel"
79
80 my $rel = $uri->rel( $base_uri );
81
82 Returns the URI::Nested object itself.
83
85 This module is stored in an open GitHub repository
86 <http://github.com/theory/uri-db/>. Feel free to fork and contribute!
87
88 Please file bug reports via GitHub Issues
89 <http://github.com/theory/uri-db/issues/> or by sending mail to
90 bug-URI-db@rt.cpan.org <mailto:bug-URI-db@rt.cpan.org>.
91
93 David E. Wheeler <david@justatheory.com>
94
96 Copyright (c) 2013 David E. Wheeler. Some Rights Reserved.
97
98 This module is free software; you can redistribute it and/or modify it
99 under the same terms as Perl itself.
100
101
102
103perl v5.38.0 2023-07-21 URI::Nested(3pm)