Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Attributes | Private Member Functions | Private Attributes
nsJARURI Class Reference

#include <nsJARURI.h>

Inheritance diagram for nsJARURI:
Inheritance graph
[legend]
Collaboration diagram for nsJARURI:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSIURI NS_DECL_NSIURL
NS_DECL_NSIJARURI
NS_DECL_NSIJARURI_MOZILLA_1_8_BRANCH
NS_DECL_NSISERIALIZABLE
NS_DECL_NSICLASSINFO 
NS_DEFINE_STATIC_IID_ACCESSOR (NS_THIS_JARURI_IMPL_CID)
 nsJARURI ()
virtual ~nsJARURI ()
nsresult Init (const char *charsetHint)
nsresult FormatSpec (const nsACString &entryPath, nsACString &result, PRBool aIncludeScheme=PR_TRUE)
nsresult CreateEntryURL (const nsACString &entryFilename, const char *charset, nsIURL **url)
nsresult SetSpecWithBase (const nsACString &aSpec, nsIURI *aBaseURL)
AUTF8String getCommonBaseSpec (in nsIURI aURIToCompare)
 This method takes a uri and compares the two.
AUTF8String getRelativeSpec (in nsIURI aURIToCompare)
 This method takes a uri and returns a substring of this if it can be made relative to the uri passed in.
boolean equals (in nsIURI other)
 URI equivalence test (not a strict string comparison).
boolean schemeIs (in string scheme)
 An optimization to do scheme checks without requiring the users of nsIURI to GetScheme, thereby saving extra allocating and freeing.
nsIURI clone ()
 Clones the current URI.
AUTF8String resolve (in AUTF8String relativePath)
 This method resolves a relative string into an absolute URI string, using this URI as the base.

Public Attributes

attribute nsIURI JARFile
 Returns the root URI (the one for the actual JAR file) for this JAR.
attribute AUTF8String JAREntry
 Returns the entry specified for this JAR URI.
attribute AUTF8String filePath
 Returns a path including the directory and file portions of a URL.
attribute AUTF8String param
 Returns the parameters specified after the ; in the URL.
attribute AUTF8String query
 Returns the query portion (the part after the "?") of the URL.
attribute AUTF8String ref
 Returns the reference portion (the part after the "#") of the URL.
attribute AUTF8String directory
 Returns the directory portion of a URL.
attribute AUTF8String fileName
 Returns the file name portion of a URL.
attribute AUTF8String fileBaseName
 Returns the file basename portion of a filename in a url.
attribute AUTF8String fileExtension
 Returns the file extension portion of a filename in a url.
attribute AUTF8String spec
 Returns a string representation of the URI.
readonly attribute AUTF8String prePath
 The prePath (eg.
attribute ACString scheme
 The Scheme is the protocol to which this URI refers.
attribute AUTF8String userPass
 The username:password (or username only if value doesn't contain a ':')
attribute AUTF8String username
 The optional username and password, assuming the preHost consists of username:password.
attribute AUTF8String password
attribute AUTF8String hostPort
 The host:port (or simply the host, if port == -1).
attribute AUTF8String host
 The host is the internet domain name to which this URI refers.
attribute long port
 A port value of -1 corresponds to the protocol's default port (eg.
attribute AUTF8String path
 The path, typically including at least a leading '/' (but may also be empty, depending on the protocol).
readonly attribute ACString asciiSpec
 The URI spec with an ASCII compatible encoding.
readonly attribute ACString asciiHost
 The URI host with an ASCII compatible encoding.
readonly attribute ACString originCharset
 The charset of the document from which this URI originated.

Protected Attributes

nsCOMPtr< nsIURImJARFile
nsCOMPtr< nsIURLmJAREntry
nsCString mCharsetHint

Private Member Functions

nsIJARURI cloneWithJARFile (in nsIURI jarFile)
 Create a clone of the JAR URI with a new root URI (the URI for the actual JAR file).
void read (in nsIObjectInputStream aInputStream)
 Initialize the object implementing nsISerializable, which must have been freshly constructed via CreateInstance.
void write (in nsIObjectOutputStream aOutputStream)
 Serialize the object implementing nsISerializable to aOutputStream, by writing each data member that must be recovered later to reconstitute a working replica of this object, in a canonical member and byte order, to aOutputStream.
void getInterfaces (out PRUint32 count,[array, size_is(count), retval] out nsIIDPtr array)
 Get an ordered list of the interface ids that instances of the class promise to implement.
nsISupports getHelperForLanguage (in PRUint32 language)
 Get a language mapping specific helper object that may assist in using objects of this class in a specific lanaguage.

Private Attributes

readonly attribute string contractID
 A contract ID through which an instance of this class can be created (or accessed as a service, if |flags & SINGLETON|), or null.
readonly attribute string classDescription
 A human readable string naming the class, or null.
readonly attribute nsCIDPtr classID
 A class ID through which an instance of this class can be created (or accessed as a service, if |flags & SINGLETON|), or null.
readonly attribute PRUint32 implementationLanguage
 Return language type from list in nsIProgrammingLanguage.
const PRUint32 SINGLETON = 1 << 0
 Bitflags for 'flags' attribute.
const PRUint32 THREADSAFE = 1 << 1
const PRUint32 MAIN_THREAD_ONLY = 1 << 2
const PRUint32 DOM_OBJECT = 1 << 3
const PRUint32 PLUGIN_OBJECT = 1 << 4
const PRUint32 EAGER_CLASSINFO = 1 << 5
const PRUint32 CONTENT_NODE = 1 << 6
 'flags' attribute bitflag: whether objects of this type implement nsIContent.
const PRUint32 RESERVED = 1 << 31
readonly attribute PRUint32 flags
readonly attribute nsCID classIDNoAlloc
 Also a class ID through which an instance of this class can be created (or accessed as a service, if |flags & SINGLETON|).

Detailed Description

Definition at line 67 of file nsJARURI.h.


Constructor & Destructor Documentation

Definition at line 57 of file nsJARURI.cpp.

{
}
nsJARURI::~nsJARURI ( ) [virtual]

Definition at line 61 of file nsJARURI.cpp.

{
}

Member Function Documentation

nsIURI nsIURI::clone ( ) [inherited]

Clones the current URI.

For some protocols, this is more than just an optimization. For example, under MacOS, the spec of a file URL does not necessarily uniquely identify a file since two volumes could share the same name.

Here is the caller graph for this function:

Create a clone of the JAR URI with a new root URI (the URI for the actual JAR file).

nsresult nsJARURI::CreateEntryURL ( const nsACString &  entryFilename,
const char *  charset,
nsIURL **  url 
)

Definition at line 118 of file nsJARURI.cpp.

{
    *url = nsnull;

    nsCOMPtr<nsIStandardURL> stdURL(do_CreateInstance(NS_STANDARDURL_CONTRACTID));
    if (!stdURL) {
        return NS_ERROR_OUT_OF_MEMORY;
    }

    // Flatten the concatenation, just in case.  See bug 128288
    nsCAutoString spec(NS_BOGUS_ENTRY_SCHEME + entryFilename);
    nsresult rv = stdURL->Init(nsIStandardURL::URLTYPE_NO_AUTHORITY, -1,
                               spec, charset, nsnull);
    if (NS_FAILED(rv)) {
        return rv;
    }

    return CallQueryInterface(stdURL, url);
}

Here is the call graph for this function:

boolean nsIURI::equals ( in nsIURI  other) [inherited]

URI equivalence test (not a strict string comparison).

eg. http://foo.com:80/ == http://foo.com/

nsresult nsJARURI::FormatSpec ( const nsACString &  entryPath,
nsACString &  result,
PRBool  aIncludeScheme = PR_TRUE 
)

Definition at line 96 of file nsJARURI.cpp.

{
    // The entrySpec MUST start with "x:///"
    NS_ASSERTION(StringBeginsWith(entrySpec, NS_BOGUS_ENTRY_SCHEME),
                 "bogus entry spec");

    nsCAutoString fileSpec;
    nsresult rv = mJARFile->GetSpec(fileSpec);
    if (NS_FAILED(rv)) return rv;

    if (aIncludeScheme)
        result = NS_JAR_SCHEME;
    else
        result.Truncate();

    result.Append(fileSpec + NS_JAR_DELIMITER +
                  Substring(entrySpec, 5, entrySpec.Length() - 5));
    return NS_OK;
}

Here is the call graph for this function:

AUTF8String nsIURL::getCommonBaseSpec ( in nsIURI  aURIToCompare) [inherited]

This method takes a uri and compares the two.

The common uri portion is returned as a string. The minimum common uri portion is the protocol, and any of these if present: login, password, host and port If no commonality is found, "" is returned. If they are identical, the whole path with file/ref/etc. is returned. For file uris, it is expected that the common spec would be at least "file:///" since '/' is a shared common root.

Examples: this.spec aURIToCompare.spec result 1) http://mozilla.org/ http://www.mozilla.org/ "" 2) http://foo.com/bar/ ftp://foo.com/bar/ "" 3) http://foo.com:8080/ http://foo.com/bar/ "" 4) ftp://user@foo.com/ ftp://user:pw@foo.com/ "" 5) ftp://foo.com/bar/ ftp://foo.com/bar ftp://foo.com/ 6) ftp://foo.com/bar/ ftp://foo.com/bar/b.html ftp://foo.com/bar/ 7) http://foo.com/a.htm#i http://foo.com/b.htm http://foo.com/ 8) ftp://foo.com/c.htm#i ftp://foo.com/c.htm ftp://foo.com/c.htm 9) file:///a/b/c.html file:///d/e/c.html file:///

nsISupports nsIClassInfo::getHelperForLanguage ( in PRUint32  language) [inherited]

Get a language mapping specific helper object that may assist in using objects of this class in a specific lanaguage.

For instance, if asked for the helper for nsIProgrammingLanguage::JAVASCRIPT this might return an object that can be QI'd into the nsIXPCScriptable interface to assist XPConnect in supplying JavaScript specific behavior to callers of the instance object.

see: nsIProgrammingLanguage.idl

Should return null if no helper available for given language.

void nsIClassInfo::getInterfaces ( out PRUint32  count,
[array, size_is(count), retval] out nsIIDPtr  array 
) [inherited]

Get an ordered list of the interface ids that instances of the class promise to implement.

Note that nsISupports is an implicit member of any such list and need not be included.

Should set *count = 0 and *array = null and return NS_OK if getting the list is not supported.

AUTF8String nsIURL::getRelativeSpec ( in nsIURI  aURIToCompare) [inherited]

This method takes a uri and returns a substring of this if it can be made relative to the uri passed in.

If no commonality is found, the entire uri spec is returned. If they are identical, "" is returned. Filename, query, etc are always returned except when uris are identical.

else NS_INTERFACE_MAP_END nsresult nsJARURI::Init ( const char *  charsetHint)

Definition at line 83 of file nsJARURI.cpp.

{
    mCharsetHint = charsetHint;
    return NS_OK;
}
NS_DECL_ISUPPORTS NS_DECL_NSIURI NS_DECL_NSIURL NS_DECL_NSIJARURI NS_DECL_NSIJARURI_MOZILLA_1_8_BRANCH NS_DECL_NSISERIALIZABLE NS_DECL_NSICLASSINFO nsJARURI::NS_DEFINE_STATIC_IID_ACCESSOR ( NS_THIS_JARURI_IMPL_CID  )
void nsISerializable::read ( in nsIObjectInputStream  aInputStream) [inherited]

Initialize the object implementing nsISerializable, which must have been freshly constructed via CreateInstance.

All data members that can't be set to default values must have been serialized by write, and should be read from aInputStream in the same order by this method.

AUTF8String nsIURI::resolve ( in AUTF8String  relativePath) [inherited]

This method resolves a relative string into an absolute URI string, using this URI as the base.

NOTE: some implementations may have no concept of a relative URI.

boolean nsIURI::schemeIs ( in string  scheme) [inherited]

An optimization to do scheme checks without requiring the users of nsIURI to GetScheme, thereby saving extra allocating and freeing.

Returns true if the schemes match (case ignored).

nsresult nsJARURI::SetSpecWithBase ( const nsACString &  aSpec,
nsIURI aBaseURL 
)

Definition at line 256 of file nsJARURI.cpp.

{
    nsresult rv;

    nsCOMPtr<nsIIOService> ioServ(do_GetIOService(&rv));
    NS_ENSURE_SUCCESS(rv, rv);

    nsCAutoString scheme;
    rv = ioServ->ExtractScheme(aSpec, scheme);
    if (NS_FAILED(rv)) {
        // not an absolute URI
        if (!aBaseURL)
            return NS_ERROR_MALFORMED_URI;

        nsRefPtr<nsJARURI> otherJAR;
        aBaseURL->QueryInterface(NS_GET_IID(nsJARURI), getter_AddRefs(otherJAR));
        NS_ENSURE_TRUE(otherJAR, NS_NOINTERFACE);

        mJARFile = otherJAR->mJARFile;

        nsCOMPtr<nsIStandardURL> entry(do_CreateInstance(NS_STANDARDURL_CONTRACTID));
        if (!entry)
            return NS_ERROR_OUT_OF_MEMORY;

        rv = entry->Init(nsIStandardURL::URLTYPE_NO_AUTHORITY, -1,
                         aSpec, mCharsetHint.get(), otherJAR->mJAREntry);
        if (NS_FAILED(rv))
            return rv;

        mJAREntry = do_QueryInterface(entry);
        if (!mJAREntry)
            return NS_NOINTERFACE;

        return NS_OK;
    }

    NS_ENSURE_TRUE(scheme.EqualsLiteral("jar"), NS_ERROR_MALFORMED_URI);

    nsACString::const_iterator begin, end;
    aSpec.BeginReading(begin);
    aSpec.EndReading(end);

    while (begin != end && *begin != ':')
        ++begin;

    ++begin; // now we're past the "jar:"

    // Search backward from the end for the "!/" delimiter. Remember, jar URLs
    // can nest, e.g.:
    //    jar:jar:http://www.foo.com/bar.jar!/a.jar!/b.html
    // This gets the b.html document from out of the a.jar file, that's 
    // contained within the bar.jar file.
    // Also, the outermost "inner" URI may be a relative URI:
    //   jar:../relative.jar!/a.html

    nsACString::const_iterator delim_begin (begin),
                               delim_end   (end);

    if (!RFindInReadable(NS_JAR_DELIMITER, delim_begin, delim_end))
        return NS_ERROR_MALFORMED_URI;

    rv = ioServ->NewURI(Substring(begin, delim_begin), mCharsetHint.get(),
                        aBaseURL, getter_AddRefs(mJARFile));
    if (NS_FAILED(rv)) return rv;

    // skip over any extra '/' chars
    while (*delim_end == '/')
        ++delim_end;

    return SetJAREntry(Substring(delim_end, end));
}

Here is the call graph for this function:

void nsISerializable::write ( in nsIObjectOutputStream  aOutputStream) [inherited]

Serialize the object implementing nsISerializable to aOutputStream, by writing each data member that must be recovered later to reconstitute a working replica of this object, in a canonical member and byte order, to aOutputStream.

NB: a class that implements nsISerializable must also implement nsIClassInfo, in particular nsIClassInfo::GetClassID.

Here is the caller graph for this function:


Member Data Documentation

readonly attribute ACString nsIURI::asciiHost [inherited]

The URI host with an ASCII compatible encoding.

Follows the IDNA draft spec for converting internationalized domain names (UTF-8) to ASCII for compatibility with existing internet infrasture.

Definition at line 220 of file nsIURI.idl.

readonly attribute ACString nsIURI::asciiSpec [inherited]

The URI spec with an ASCII compatible encoding.

Host portion follows the IDNA draft spec. Other parts are URL-escaped per the rules of RFC2396. The result is strictly ASCII.

Definition at line 213 of file nsIURI.idl.

A human readable string naming the class, or null.

Definition at line 86 of file nsIClassInfo.idl.

readonly attribute nsCIDPtr nsIClassInfo::classID [inherited]

A class ID through which an instance of this class can be created (or accessed as a service, if |flags & SINGLETON|), or null.

Definition at line 92 of file nsIClassInfo.idl.

Also a class ID through which an instance of this class can be created (or accessed as a service, if |flags & SINGLETON|).

If the class does not have a CID, it should return NS_ERROR_NOT_AVAILABLE. This attribute exists so C++ callers can avoid allocating and freeing a CID, as would happen if they used classID.

Definition at line 130 of file nsIClassInfo.idl.

'flags' attribute bitflag: whether objects of this type implement nsIContent.

Definition at line 113 of file nsIClassInfo.idl.

A contract ID through which an instance of this class can be created (or accessed as a service, if |flags & SINGLETON|), or null.

Definition at line 81 of file nsIClassInfo.idl.

attribute AUTF8String nsIURL::directory [inherited]

Returns the directory portion of a URL.

If the URL denotes a path to a directory and not a file, e.g. http://foo/bar/, then the Directory attribute accesses the complete /foo/bar/ portion, and the FileName is the empty string. If the trailing slash is omitted, then the Directory is /foo/ and the file is bar (i.e. this is a syntactic, not a semantic breakdown of the Path). And hence dont rely on this for something to be a definitely be a file. But you can get just the leading directory portion for sure.

Some characters may be escaped.

Definition at line 117 of file nsIURL.idl.

const PRUint32 nsIClassInfo::DOM_OBJECT = 1 << 3 [inherited]

Definition at line 106 of file nsIClassInfo.idl.

Definition at line 108 of file nsIClassInfo.idl.

attribute AUTF8String nsIURL::fileBaseName [inherited]

Returns the file basename portion of a filename in a url.

Some characters may be escaped.

Definition at line 142 of file nsIURL.idl.

attribute AUTF8String nsIURL::fileExtension [inherited]

Returns the file extension portion of a filename in a url.

If a file extension does not exist, the empty string is returned.

Some characters may be escaped.

Definition at line 150 of file nsIURL.idl.

attribute AUTF8String nsIURL::fileName [inherited]

Returns the file name portion of a URL.

If the URL denotes a path to a directory and not a file, e.g. http://foo/bar/, then the Directory attribute accesses the complete /foo/bar/ portion, and the FileName is the empty string. Note that this is purely based on searching for the last trailing slash. And hence dont rely on this to be a definite file.

Some characters may be escaped.

Definition at line 130 of file nsIURL.idl.

attribute AUTF8String nsIURL::filePath [inherited]

Returns a path including the directory and file portions of a URL.

For example, the filePath of "http://foo/bar.html#baz" is "/foo/bar.html".

Some characters may be escaped.

Definition at line 73 of file nsIURL.idl.

readonly attribute PRUint32 nsIClassInfo::flags [inherited]

Definition at line 121 of file nsIClassInfo.idl.

attribute AUTF8String nsIURI::host [inherited]

The host is the internet domain name to which this URI refers.

It could be an IPv4 (or IPv6) address literal. If supported, it could be a non-ASCII internationalized domain name.

Characters are NOT escaped.

Definition at line 152 of file nsIURI.idl.

attribute AUTF8String nsIURI::hostPort [inherited]

The host:port (or simply the host, if port == -1).

Characters are NOT escaped.

Definition at line 143 of file nsIURI.idl.

Return language type from list in nsIProgrammingLanguage.

Definition at line 98 of file nsIClassInfo.idl.

attribute AUTF8String nsIJARURI::JAREntry [inherited]

Returns the entry specified for this JAR URI.

eg ocean.html

Definition at line 63 of file nsIJARURI.idl.

Returns the root URI (the one for the actual JAR file) for this JAR.

eg http://www.big.com/blue.jar

Definition at line 57 of file nsIJARURI.idl.

Definition at line 105 of file nsIClassInfo.idl.

Definition at line 97 of file nsJARURI.h.

Definition at line 96 of file nsJARURI.h.

Definition at line 93 of file nsJARURI.h.

readonly attribute ACString nsIURI::originCharset [inherited]

The charset of the document from which this URI originated.

An empty value implies UTF-8.

If this value is something other than UTF-8 then the URI components (e.g., spec, prePath, username, etc.) will all be fully URL-escaped. Otherwise, the URI components may contain unescaped multibyte UTF-8 characters.

Definition at line 231 of file nsIURI.idl.

attribute AUTF8String nsIURL::param [inherited]

Returns the parameters specified after the ; in the URL.

Some characters may be escaped.

Definition at line 80 of file nsIURL.idl.

attribute AUTF8String nsIURI::password [inherited]

Definition at line 136 of file nsIURI.idl.

attribute AUTF8String nsIURI::path [inherited]

The path, typically including at least a leading '/' (but may also be empty, depending on the protocol).

Some characters may be escaped.

Definition at line 166 of file nsIURI.idl.

Definition at line 107 of file nsIClassInfo.idl.

A port value of -1 corresponds to the protocol's default port (eg.

-1 implies port 80 for http URIs).

Definition at line 158 of file nsIURI.idl.

readonly attribute AUTF8String nsIURI::prePath [inherited]

The prePath (eg.

scheme://user:password:port) returns the string before the path. This is useful for authentication or managing sessions.

Some characters may be escaped.

Definition at line 114 of file nsIURI.idl.

attribute AUTF8String nsIURL::query [inherited]

Returns the query portion (the part after the "?") of the URL.

If there isn't one, an empty string is returned.

Some characters may be escaped.

Definition at line 88 of file nsIURL.idl.

attribute AUTF8String nsIURL::ref [inherited]

Returns the reference portion (the part after the "#") of the URL.

If there isn't one, an empty string is returned.

Some characters may be escaped.

Definition at line 96 of file nsIURL.idl.

const PRUint32 nsIClassInfo::RESERVED = 1 << 31 [inherited]

Definition at line 118 of file nsIClassInfo.idl.

attribute ACString nsIURI::scheme [inherited]

The Scheme is the protocol to which this URI refers.

The scheme is restricted to the US-ASCII charset per RFC2396.

Definition at line 120 of file nsIURI.idl.

const PRUint32 nsIClassInfo::SINGLETON = 1 << 0 [inherited]

Bitflags for 'flags' attribute.

Definition at line 103 of file nsIClassInfo.idl.

attribute AUTF8String nsIURI::spec [inherited]

Returns a string representation of the URI.

Setting the spec causes the new spec to be parsed, initializing the URI.

Some characters may be escaped.

Definition at line 106 of file nsIURI.idl.

const PRUint32 nsIClassInfo::THREADSAFE = 1 << 1 [inherited]

Definition at line 104 of file nsIClassInfo.idl.

attribute AUTF8String nsIURI::username [inherited]

The optional username and password, assuming the preHost consists of username:password.

Some characters may be escaped.

Definition at line 135 of file nsIURI.idl.

attribute AUTF8String nsIURI::userPass [inherited]

The username:password (or username only if value doesn't contain a ':')

Some characters may be escaped.

Definition at line 127 of file nsIURI.idl.


The documentation for this class was generated from the following files: