Cross-Platform C++

ot::net
class URLStreamHandler  (abstract)

#include "ot/net/URLStreamHandler.h"

ot::ManagedObject An abstract base class for dealing with the protocol-specific aspects of URL handling. Instances of URLStreamHandler are created by the registered URLStreamHandlerFactory.

See also:
URLStreamHandlerFactory



Method Summary
protected  virtual int getDefaultPort() const
         Returns the default port number which servers for the protocol usually listen on.
protected  virtual bool hostsEqual(const URL& first, const URL& second) const
         Compares the hosts from two URLs for equality.
protected  virtual RefPtr< URLConnection > openConnection(const URL& url) const=0
         Opens a URLConnection to the resource identified by a URL.
protected  virtual String parsePath(const String& context, const String& path) const
         Protected helper function called by ParseURL() to process the path name of a URL.
protected  virtual void parseURL(URL& urlRet, const String& spec) const
         Extracts the component parts of the URL from the passed string and sets the values in urlRet accordingly.
protected  virtual bool sameFile(const URL& first, const URL& second) const
         Compares two URLs to see if they relate to the same file.
protected  void setURL(URL& url, const String& protocol, const String& host, int port, const String& authority, const String& userInfo, const String& path, const String& query, const String& ref) const
         Protected helper function which provides update access to the individual components of a URL.
protected  virtual String toExternalForm(const URL& url) const
         Converts a URL into a valid string representation.

Methods inherited from class ot::ManagedObject
addRef, getRefCount, onFinalRelease, operator=, release

Method Detail

getDefaultPort

protected virtual int getDefaultPort() const
Returns the default port number which servers for the protocol usually listen on. This is used when comparing URLs where one has a port and the other doesn't to see if they would actually contact the same remote server.

Returns:
the default port number for the protocol (e.g. port 80 for HTTP)

hostsEqual

protected virtual bool hostsEqual(const URL& first,
                                  const URL& second) const
Compares the hosts from two URLs for equality. Two hostnames are considered the same if they compare equal using a case-insensitive comparison, or if they both resolve to the same Internet address.

Parameters:
first - the first URL to compare
second - the second URL to compare
Returns:
true if first and second refer to the same network host.

openConnection

protected virtual RefPtr< URLConnectionopenConnection(const URL& url) const=0
Opens a URLConnection to the resource identified by a URL. This is a protected member. Applications should not call this member directly, rather they should make use of the URL class.

Parameters:
url - the URL to connect to
Returns:
a URLConnection instance for the URL.
Exceptions:
IOException - if an I/O error occurs while opening the connection
See also:
URL::openConnection()

parsePath

protected virtual String parsePath(const String& context,
                                   const String& path) const
Protected helper function called by ParseURL() to process the path name of a URL. The base class implementation performs the following normalization of filenames:


parseURL

protected virtual void parseURL(URL& urlRet,
                                const String& spec) const
Extracts the component parts of the URL from the passed string and sets the values in urlRet accordingly. This base-class version assumes an hierarchical HTTP-like URL syntax.

The caller (URL constructor) will already have stripped the protocol and ref parts from the specification string.


sameFile

protected virtual bool sameFile(const URL& first,
                                const URL& second) const
Compares two URLs to see if they relate to the same file. The base class implementation compares the protocol, host, port and filename components.

Host names are compared by the hostsEqual() method. Port numbers are considered equal when they have the same value, or when one isn't specified and the other has the default port number specified.

Parameters:
first - the first URL to compare
second - the second URL to compare
Returns:
true if first and second refer to the same network file.

setURL

protected void setURL(URL& url,
                      const String& protocol,
                      const String& host,
                      int port,
                      const String& authority,
                      const String& userInfo,
                      const String& path,
                      const String& query,
                      const String& ref) const
Protected helper function which provides update access to the individual components of a URL.


toExternalForm

protected virtual String toExternalForm(const URL& url) const
Converts a URL into a valid string representation.

Parameters:
url - the URL to convert


Cross-Platform C++

Found a bug or missing feature? Please email us at support@elcel.com

Copyright © 2000-2003 ElCel Technology   Trademark Acknowledgements