SunSPOT API V3.0


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

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

public class Protocol
extends ConnectionBase
implements RemotePrintConnection

Implementor of RemotePrintConnection using the Generic Connection Framework (GCF) used by J2ME.

We want each newline ('\n') to automatically flush the buffer and send the line over the radio connection to the remote print server to be displayed. We cannot just use a Radio stream directly since it does not autoflush. So we use a RemotePrintOutputStream and connect it to a RadioOutputStream.

Author:
Ron Goldman
See Also:
RemotePrintConnection

Constructor Summary
Protocol()
           
 
Method Summary
 void close()
          Close this remoteprint connection.
 Connection open(String protocolName, String name, int mode, boolean timeouts)
          Open a new "remoteprint" connection to the specified SPOT.
 InputStream openInputStream()
          Open an InputStream for this connection.
 OutputStream openOutputStream()
          Open an OutputStream for 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

open

public Connection open(String protocolName,
                       String name,
                       int mode,
                       boolean timeouts)
Open a new "remoteprint" connection to the specified SPOT.

Note: the actual "radio" stream connection is opened by RemotePrintOutputStream.

Specified by:
open in class ConnectionBase
Parameters:
protocolName - = "remoteprint:"
name - the IEEE radio address of the SPOT to connect to and the port to use for the connection, e.g. "123456:119"
mode - the access mode (ignored)
timeouts - a flag to indicate that the caller wants timeout exceptions (ignored)
Returns:
the new remoteprint conection
See Also:
ConnectionBase.open(java.lang.String, java.lang.String, int, boolean)

close

public void close()
           throws IOException
Close this remoteprint connection.

Note: this does not close the radio stream used by the remote printing.

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

openInputStream

public InputStream openInputStream()
Open an InputStream for this connection.

Note: remoteprint connections do not support an InputStream.

Specified by:
openInputStream in interface InputConnection
Overrides:
openInputStream in class ConnectionBase
Returns:
null
See Also:
ConnectionBase.openInputStream()

openOutputStream

public OutputStream openOutputStream()
Open an OutputStream for this connection.

Note: all "remoteprint" connections from this SPOT to the remote print server will share the same OutputStream.

Specified by:
openOutputStream in interface OutputConnection
Overrides:
openOutputStream in class ConnectionBase
Returns:
an OutputStream that goes to the remote print server
See Also:
ConnectionBase.openOutputStream()

SunSPOT API V3.0


Copyright © 2006, 2007 Sun Microsystems, Inc. All Rights Reserved.