SunSPOT API V5.0


com.sun.squawk.io.j2me.edemoserial
Class Protocol

java.lang.Object
  extended by com.sun.squawk.io.ConnectionBase
      extended by com.sun.squawk.io.j2me.edemoserial.Protocol
All Implemented Interfaces:
ITimeoutableConnection, Connection, InputConnection, OutputConnection, StreamConnection

public class Protocol
extends ConnectionBase
implements StreamConnection, ITimeoutableConnection

serial.Protocol - provides read access to the serial/USB port for an eSPOT

Author:
arshan CHANGELOG - 8/20/07 modified the serial Protocol.java from spotlib to this -arshan - 7/ 1/08 allow databits, parity and stopbits declaration - arshan

Constructor Summary
Protocol()
           
 
Method Summary
 void close()
          Close
 long getTimeout()
          Get the timeout for receiving information on this connection
 Connection open(String protocol, String name, int mode, boolean timeouts)
          Open a connection to a target.
 InputStream openInputStream()
          Open and return a data input stream for a connection.
 OutputStream openOutputStream()
          Open and return a data output stream for a connection.
static void setResourceRegistry(IResourceRegistry resourceRegistry)
          This method is provided for test purposes only.
 void setTimeout(long timeout)
          Set the timeout for receiving information on this connection
 
Methods inherited from class com.sun.squawk.io.ConnectionBase
openDataInputStream, openDataOutputStream
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.microedition.io.InputConnection
openDataInputStream
 
Methods inherited from interface javax.microedition.io.OutputConnection
openDataOutputStream
 

Constructor Detail

Protocol

public Protocol()
Method Detail

setResourceRegistry

public static void setResourceRegistry(IResourceRegistry resourceRegistry)
This method is provided for test purposes only. It should not be used by normal applications.

Parameters:
resourceRegistry -

open

public Connection open(String protocol,
                       String name,
                       int mode,
                       boolean timeouts)
                throws IOException
Description copied from class: ConnectionBase
Open a connection to a target.

Specified by:
open in class ConnectionBase
Parameters:
protocol - The URL protocol
name - The URL for the connection
mode - The access mode
timeouts - A flag to indicate that the caller wants timeout exceptions
Returns:
A new Connection object
Throws:
IOException - If some other kind of I/O error occurs.

close

public void close()
           throws IOException
Description copied from class: ConnectionBase
Close

Specified by:
close in interface Connection
Overrides:
close in class ConnectionBase
Throws:
IOException - If an I/O error occurs

setTimeout

public void setTimeout(long timeout)
Set the timeout for receiving information on this connection

Specified by:
setTimeout in interface ITimeoutableConnection
Parameters:
timeout - Timeout period in milliseconds. Set this to 0 to turn off timeouts (infinite wait), or to > 0 to wait that long for data before throwing a TimeoutException.

getTimeout

public long getTimeout()
Get the timeout for receiving information on this connection

Specified by:
getTimeout in interface ITimeoutableConnection
Returns:
Timeout period in milliseconds. (= 0 for infinite wait)

openInputStream

public InputStream openInputStream()
                            throws IOException
Description copied from class: ConnectionBase
Open and return a data input stream for a connection.

Specified by:
openInputStream in interface InputConnection
Overrides:
openInputStream in class ConnectionBase
Returns:
An input stream
Throws:
IOException - If an I/O error occurs

openOutputStream

public OutputStream openOutputStream()
                              throws IOException
Description copied from class: ConnectionBase
Open and return a data output stream for a connection.

Specified by:
openOutputStream in interface OutputConnection
Overrides:
openOutputStream in class ConnectionBase
Returns:
An input stream
Throws:
IOException - If an I/O error occurs

SunSPOT API V5.0


Copyright � 2006-2008 Sun Microsystems, Inc. All Rights Reserved.