public class Connector extends Object
Connection
from an URL.
The URL format (which complies with RFC 2396) is on the following format:
[protocol]:[name](;[param])*Where:
protocol
defines the connection protocol (for example: comm
, http
)name
is the name of the connection to open (for example: /dev/ttyS0
, 192.168.1.1
)param
is a connection specific parameter
The factory corresponding to the extracted protocol is dynamically bound and its ConnectionFactory.open(java.lang.String, int, boolean)
method is called on the specified URL.
ConnectionFactory
Modifier and Type | Field and Description |
---|---|
static int |
READ
Access mode READ.
|
static int |
READ_WRITE
Access mode READ/WRITE.
|
static int |
WRITE
Access mode WRITE.
|
Modifier and Type | Method and Description |
---|---|
static Connection |
open(String url)
Create and open a Connection from an URL.
|
static Connection |
open(String url,
int mode)
Create and open a Connection.
|
static Connection |
open(String url,
int mode,
boolean timeouts)
Create and open a Connection.
|
static Connection |
open(String packageName,
String url,
int mode,
boolean timeouts)
Create and open a Connection with the specified
ConnectionFactory package name. |
public static final int READ
public static final int READ_WRITE
public static final int WRITE
public static Connection open(String url) throws IOException
url
- the connection URL to openConnection
.ConnectionNotFoundException
- if connection protocol is not foundIOException
- if an I/O error occursSecurityException
- if a security manager exists and it does not allow the caller to open such kind of connectionpublic static Connection open(String url, int mode) throws IOException
url
- the connection URL to openConnection
.ConnectionNotFoundException
- if connection protocol is not foundIOException
- if an I/O error occursSecurityException
- if a security manager exists and it does not allow the caller to open such kind of connectionpublic static Connection open(String url, int mode, boolean timeouts) throws IOException
url
- the connection URL to openConnection
.ConnectionNotFoundException
- if connection protocol is not foundIOException
- if an I/O error occursSecurityException
- if a security manager exists and it does not allow the caller to open such kind of connectionpublic static Connection open(String packageName, String url, int mode, boolean timeouts) throws IOException
ConnectionFactory
package name.url
- the connection URL to openpackageName
- the package name prefix of the ConnectionFactory
to bindConnection
.ConnectionNotFoundException
- if connection protocol is not foundIOException
- if an I/O error occursSecurityException
- if a security manager exists and it does not allow the caller to open such kind of connectionConnectionFactory