|
JSR-62 (Final) | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.microedition.io.Connector
This class is a placeholder for the static methods used to create all the connection objects.
This is done by dynamically looking up a class the name of which is formed from the platform name and the protocol of the requested connection. The parameter string describing the target conforms to the URL format as described in RFC 2396. This takes the general form:
{scheme}:[{target}][{parms}]
Where {scheme}
is the name of a protocol such as http}.
The {target}
is normally some kind of network address, but protocols may
regard this as a fairly flexible field when the connection is not network oriented.
Any {parms}
are formed as a series of equates on the form ";x=y" such as
;type=a.
An option second parameter may be specified to the open function. The is a mode flag that indicated to the protocol handler the intentions of the calling code. The options here are to specify if the connection is going to be read (READ), written (WRITE), or both (READ_WRITE). The validity of these flag settings is protocol dependent. For instance a connection for a printer would not allow read access, and would throw an IllegalArgumentException if this was attempted. Omitting this parameter results in READ_WRITE being used by default.
An optional third parameter is a boolean flag to indicate if the calling code has been written in such a way as to handle timeout exceptions. If this is selected the protocol may throw an InterruptedIOException when it detects a timeout condition. This flag is only a hint to the protocol handler and it is no guarantee that such exceptions will be throws. Omitting this parameter results in no exceptions being thrown. The timeout period is not specified in the open call because this is protocol specific. Protocol implementors can either hardwire an appropriate value or read them from an external source such as the system properties.
Because of the common occurrence of opening connections just to gain access to an input or
output stream four functions are provided for this purpose.
See also: DatagramConnection
for information relating to datagram addressing
Field Summary | |
static int |
READ
Access mode |
static int |
READ_WRITE
Access mode |
static int |
WRITE
Access mode |
Method Summary | |
static Connection |
open(String name)
Create and open a Connection |
static Connection |
open(String name,
int mode)
Create and open a Connection |
static Connection |
open(String name,
int mode,
boolean timeouts)
Create and open a Connection |
static DataInputStream |
openDataInputStream(String name)
Create and open a connection input stream |
static DataOutputStream |
openDataOutputStream(String name)
Create and open a connection output stream |
static InputStream |
openInputStream(String name)
Create and open a connection input stream |
static OutputStream |
openOutputStream(String name)
Create and open a connection output stream |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int READ
public static final int WRITE
public static final int READ_WRITE
Method Detail |
public static Connection open(String name) throws IOException
IllegalArgumentException
- If a parameter is invalid.
ConnectionNotFoundException
- if the requested connection
cannot be make, or the protocol type does not exist.
IOException
- If some other kind of I/O error occurs.public static Connection open(String name, int mode) throws IOException
mode
- The access mode.
IllegalArgumentException
- If a parameter is invalid.
ConnectionNotFoundException
- if the requested connection
cannot be make, or the protocol type does not exist.
IOException
- If some other kind of I/O error occurs.public static Connection open(String name, int mode, boolean timeouts) throws IOException
mode
- The access modetimeouts
- A flag to indicate that the called wants timeout exceptions
IllegalArgumentException
- If a parameter is invalid.
ConnectionNotFoundException
- if the requested connection
cannot be make, or the protocol type does not exist.
IOException
- If some other kind of I/O error occurs.public static DataInputStream openDataInputStream(String name) throws IOException
IllegalArgumentException
- If a parameter is invalid.
ConnectionNotFoundException
- If the connection cannot be found.
IOException
- If some other kind of I/O error occurs.public static DataOutputStream openDataOutputStream(String name) throws IOException
IllegalArgumentException
- If a parameter is invalid.
ConnectionNotFoundException
- If the connection cannot be found.
IOException
- If some other kind of I/O error occurs.public static InputStream openInputStream(String name) throws IOException
IllegalArgumentException
- If a parameter is invalid.
ConnectionNotFoundException
- If the connection cannot be found.
IOException
- If some other kind of I/O error occurs.public static OutputStream openOutputStream(String name) throws IOException
IllegalArgumentException
- If a parameter is invalid.
ConnectionNotFoundException
- If the connection cannot be found.
IOException
- If some other kind of I/O error occurs.
|
JSR-62 (Final) | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |