|
SunSPOT API V3.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.microedition.io.Connector
public class Connector
This class is a placeholder for the static methods that are used for creating all the Connection objects.
The creation of Connections is performed dynamically by looking up a protocol implementation class whose name is formed from the platform name (read from a system property) and the protocol name of the requested connection (extracted from the parameter string supplied by the application programmer.) The parameter string that describes the target should conform 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.
Any {parms}
are formed as a series of equates
of the form ";x=y". Example: ";type=a".
An optional second parameter may be specified to the open function. This is a mode flag that indicates to the protocol handler the intentions of the calling code. The options here 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 the mode parameter is not specified, READ_WRITE is used by default.
An optional third parameter is a boolean flag that indicates if the calling code can handle timeout exceptions. If this flag is set, the protocol implementation may throw an InterruptedIOException when it detects a timeout condition. This flag is only a hint to the protocol handler, and it does not guarantee that such exceptions will actually be thrown. If this parameter is not set, no timeout exceptions will be thrown.
Because connections are frequently opened just to gain access
to a specific input or output stream, four convenience
functions are provided for this purpose.
See also: DatagramConnection
for information relating to datagram addressing
Field Summary | |
---|---|
static int |
READ
Access mode READ. |
static int |
READ_WRITE
Access mode READ_WRITE. |
static int |
WRITE
Access mode WRITE. |
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 |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int READ
public static final int READ_WRITE
public static final int WRITE
Method Detail |
---|
public static Connection open(String name) throws IOException
name
- The URL for the connection.
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
name
- The URL for the connection.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
name
- The URL for the connectionmode
- The access modetimeouts
- A flag to indicate that the caller
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
name
- The URL for the connection.
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
name
- The URL for the connection.
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
name
- The URL for the connection.+
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
name
- The URL for the connection.
IllegalArgumentException
- If a parameter is invalid.
ConnectionNotFoundException
- If the connection cannot
be found.
IOException
- If some other kind of I/O error occurs.
|
SunSPOT API V3.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |