activemq-cpp-3.9.5
decaf::net::URLStreamHandler Class Referenceabstract

The abstract class URLStreamHandler is the common superclass for all stream protocol handlers. More...

#include <src/main/decaf/net/URLStreamHandler.h>

Inheritance diagram for decaf::net::URLStreamHandler:

Public Member Functions

virtual ~URLStreamHandler ()
 

Protected Member Functions

virtual URLConnectionopenConnection (const URL &url)=0
 Establishes a new connection to the resource specified by the given URL.
 
virtual URLConnectionopenConnection (const URL &url, const Proxy *proxy)
 Establishes a new connection to the resource specified by the given URL.
 
virtual bool equals (const URL &source, const URL &other) const
 Provides the default equals calculation.
 
virtual int hashCode (const URL &url) const
 Provides the default hashCode calculation.
 
virtual bool hostsEqual (const URL &source, const URL &other) const
 Compares the host components of two URLs.
 
virtual bool sameFile (const URL &source, const URL &other) const
 Compare two URLs to see whether they refer to the same file, i.e., having the same protocol, host, port, and path.
 
virtual decaf::lang::String toExternalForm (const URL &url) const
 Converts the URL into a string representation.
 
virtual InetAddress getHostAddress (const URL &url) const
 Attempts to get the IP address of the host.
 
virtual int getDefaultPort () const
 Returns the default port for a URL parsed by this handler.
 
virtual void parseURL (URL &url, const decaf::lang::String &spec, int start, int limit)
 Parses the clear text URL in spec into a URL object.
 
void setURL (URL &url, const decaf::lang::String &protocol, const decaf::lang::String &host, int port, const decaf::lang::String &authority, const decaf::lang::String &userInfo, const decaf::lang::String &path, const decaf::lang::String &query, const decaf::lang::String &ref)
 Sets the fields of the URL This method is only intended to be used by subclasses of URLStreamHandler so it is kept protected.
 

Friends

class URL
 

Detailed Description

The abstract class URLStreamHandler is the common superclass for all stream protocol handlers.

A stream protocol handler knows how to make a connection for a particular protocol type, such as http, ftp, or https etc.

In most cases, an instance of a URLStreamHandler subclass is not created directly by an application. Rather, the first time a protocol name is encountered when constructing a URL, the appropriate stream protocol handler is automatically created from a registered stream handler factory.

Since
1.0

Constructor & Destructor Documentation

◆ ~URLStreamHandler()

virtual decaf::net::URLStreamHandler::~URLStreamHandler ( )
virtual

Member Function Documentation

◆ equals()

virtual bool decaf::net::URLStreamHandler::equals ( const URL & source,
const URL & other ) const
protectedvirtual

Provides the default equals calculation.

May be overridden by handlers for other protocols that have different requirements for equals().

Parameters
sourceThe URL class that is invoking this comparison.
otherThe URL that is being compared to source.
Returns
true if the two URL instances are considered equal.

References URL.

◆ getDefaultPort()

virtual int decaf::net::URLStreamHandler::getDefaultPort ( ) const
protectedvirtual

Returns the default port for a URL parsed by this handler.

This method should be overidden by handlers with knowledge of the default port numbers as the default implementation simply returns -1.

Returns
the default port number for this URL's protocol.

Reimplemented in decaf::internal::net::file::FileHandler, decaf::internal::net::http::HttpHandler, and decaf::internal::net::https::HttpsHandler.

◆ getHostAddress()

virtual InetAddress decaf::net::URLStreamHandler::getHostAddress ( const URL & url) const
protectedvirtual

Attempts to get the IP address of the host.

Based on DNS errors or other conditions it's possible this method will return an empty string.

Parameters
urlThe URL to construct the string from.
Returns
the INetAddress object that the host points to.

References URL.

◆ hashCode()

virtual int decaf::net::URLStreamHandler::hashCode ( const URL & url) const
protectedvirtual

Provides the default hashCode calculation.

May be overridden by handlers for other protocols that have different algorithms for computing a hash code..

Parameters
urlThe URL class that is invoking this hash code computation.

References URL.

◆ hostsEqual()

virtual bool decaf::net::URLStreamHandler::hostsEqual ( const URL & source,
const URL & other ) const
protectedvirtual

Compares the host components of two URLs.

Parameters
sourceThe URL class that is invoking this comparison.
otherThe URL that is being compared to source.
Returns
true if the two URL instances are considered to point to the same host.

References URL.

◆ openConnection() [1/2]

virtual URLConnection * decaf::net::URLStreamHandler::openConnection ( const URL & url)
protectedpure virtual

Establishes a new connection to the resource specified by the given URL.

Since different protocols also have unique ways of connecting, it must be overridden by the subclass.

Parameters
urlthe URL to the resource where a connection has to be opened.
Returns
pointer to the opened URLConnection to the specified resource.
Exceptions
IOExceptionif an I/O error occurs during opening the connection.

Implemented in decaf::internal::net::file::FileHandler, decaf::internal::net::http::HttpHandler, and decaf::internal::net::https::HttpsHandler.

References URL.

◆ openConnection() [2/2]

virtual URLConnection * decaf::net::URLStreamHandler::openConnection ( const URL & url,
const Proxy * proxy )
protectedvirtual

Establishes a new connection to the resource specified by the given URL.

The version uses a Proxy to establish the connection if proxying is supported by the URLConnection implementation in use, otherwise the proxy is ignored.

Parameters
urlthe URL to the resource where a connection has to be opened.
proxythe Proxy through which the connection should be made.
Returns
pointer to the opened URLConnection to the specified resource.
Exceptions
IOExceptionif an I/O error occurs during opening the connection.
UnsupportedOperationExceptionif the protocol in use doesn't support this.

Reimplemented in decaf::internal::net::file::FileHandler, decaf::internal::net::http::HttpHandler, and decaf::internal::net::https::HttpsHandler.

References URL.

◆ parseURL()

virtual void decaf::net::URLStreamHandler::parseURL ( URL & url,
const decaf::lang::String & spec,
int start,
int limit )
protectedvirtual

Parses the clear text URL in spec into a URL object.

URL strings generally have the following format:

http://www.company.com/java/file1.java#reference

The string is parsed in HTTP format. If the protocol has a different URL format this method must be overridden.

Parameters
urlthe URL to fill in the parsed clear text URL parts.
specthe URL string that is to be parsed.
startthe string position from where to begin parsing.
limitthe string position to stop parsing.

References URL.

◆ sameFile()

virtual bool decaf::net::URLStreamHandler::sameFile ( const URL & source,
const URL & other ) const
protectedvirtual

Compare two URLs to see whether they refer to the same file, i.e., having the same protocol, host, port, and path.

Parameters
sourceThe URL class that is invoking this comparison.
otherThe URL that is being compared to source.
Returns
true if the two URL instances are considered to be the same file.

References URL.

◆ setURL()

void decaf::net::URLStreamHandler::setURL ( URL & url,
const decaf::lang::String & protocol,
const decaf::lang::String & host,
int port,
const decaf::lang::String & authority,
const decaf::lang::String & userInfo,
const decaf::lang::String & path,
const decaf::lang::String & query,
const decaf::lang::String & ref )
protected

Sets the fields of the URL This method is only intended to be used by subclasses of URLStreamHandler so it is kept protected.

Parameters
protocolthe name of the protocol to use.
hostthe name of the host.
portthe specific port number of the URL. Value of -1 represents the default port of the protocol.
authoritythe authority value.
userInfothe user info value.
paththe path value.
querythe query value.
refthe internal reference in the URL
Exceptions
SecurityExceptionif the protocol handler of the URL is not this instance.

References URL.

◆ toExternalForm()

virtual decaf::lang::String decaf::net::URLStreamHandler::toExternalForm ( const URL & url) const
protectedvirtual

Converts the URL into a string representation.

Parameters
urlThe URL to construct the string from.
Returns
string form of the provided URL.

References URL.

Friends And Related Symbol Documentation

◆ URL


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