URI::jar - Java ARchive URI


URI-jar documentation Contained in the URI-jar distribution.

Index


Code Index:

NAME

Top

URI::jar - Java ARchive URI

VERSION

Top

version 0.02

SYNOPSIS

Top

  use URI;
  use URI::jar;

  my $jar_uri = URI->jar("jar:http://www.art-code.org/foo/bar.jar!/content/baz/zigorou.js");
  local $\ = "\n";
  print $jar_uri->jar_entry_name; # will print "/content/baz/zigorou.js"
  print $jar_uri->jar_file_uri; # will print "http://www.art-code.org/foo/bar.jar"

METHOD

Top

jar_entry_name()

Return entry name in jar file.

jar_file_uri()

Return jar file's uri as URI object.

AUTHOR

Top

Toru Yamaguchi, <zigorou@cpan.org>

BUGS

Top

Please report any bugs or feature requests to bug-uri-jar@rt.cpan.org, or through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

COPYRIGHT & LICENSE

Top


URI-jar documentation Contained in the URI-jar distribution.
package URI::jar;

use strict;
use warnings;

use base qw(URI::_generic);
use URI;

our $VERSION = '0.02';

sub jar_entry_name {
    my ($self, $jar_entry_name) = @_;
    my @leaf = split(/!/, $$self);

    if (@leaf == 2) {
        if ($jar_entry_name) {
            $self->path(join("!", $leaf[0], $jar_entry_name));
        }
        else {
            return $leaf[1];
        }
    }
    else {
        return;
    }
}

sub jar_file_uri {
    my ($self, $jar_file_uri) = @_;

    my @leaf = split(/!/, $self->path);

    if (@leaf == 2) {
        if ($jar_file_uri) {
            if (UNIVERSAL::isa($jar_file_uri, "URI")) {
                $jar_file_uri = $jar_file_uri->as_string;
            }

            $self->path(join("!", $jar_file_uri, $leaf[1]));
        }
        else {
            if ($leaf[0] =~ /^([^:]+)\:/) {
                return URI->new($leaf[0]);
            }
            else {
                return URI->new($leaf[0], "file");
            }
        }
    }
    else {
        return;
    }
}

1; # End of URI::jar