| 
 | " 2013 FRC Java API" | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.squawk.io.ConnectionBase
com.sun.squawk.io.ConnectionBaseAdapter
public abstract class ConnectionBaseAdapter
Protocol classes extend this class to gain some of the common functionality needed to implement a CLDC Generic Connection.
The common functionality includes:
InputStream.read(byte[], int, int), which is called by
 InputStream.read()
 OutputStream.write(byte[], int, int), which is called by
 OutputStream.write(int)
 Class Relationship Diagram
 
| Field Summary | |
|---|---|
| protected  boolean | connectionOpenFlag indicating if the connection is open. | 
| protected  int | iStreamsNumber of input streams that were opened. | 
| protected  int | maxIStreamsMaximum number of open input streams. | 
| protected  int | maxOStreamsMaximum number of output streams. | 
| protected  int | oStreamsNumber of output streams were opened. | 
| Constructor Summary | |
|---|---|
| ConnectionBaseAdapter() | |
| Method Summary | |
|---|---|
|  int | available()Returns the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream. | 
|  void | close()Close the connection. | 
| protected  void | closeInputStream()Called once by each child input stream. | 
| protected  void | closeOutputStream()Called once by each child output stream. | 
| protected abstract  void | disconnect()Free up the connection resources. | 
| protected  void | ensureOpen()Check if the connection is open. | 
| protected  void | flush()Forces any buffered output bytes to be written out. | 
|  void | initStreamConnection(int mode)Check the mode argument and initialize the StreamConnection. | 
|  void | mark(int readlimit)Marks the current position in input stream for a connection. | 
|  boolean | markSupported()Tests if input stream for a connection supports the markandresetmethods. | 
| protected  void | notifyClosedInput()Notify blocked Java threads waiting for an input data that all InputStream instances of the connection are closed | 
| protected  void | notifyClosedOutput()Notify blocked Java threads trying to output data that all OutputStream instances of the connection are closed | 
|  DataInputStream | openDataInputStream()Open and return a data input stream for a connection. | 
|  DataOutputStream | openDataOutputStream()Open and return a data output stream for a connection. | 
|  InputStream | openInputStream()Returns an input stream. | 
|  OutputStream | openOutputStream()Returns an output stream. | 
| abstract  Connection | openPrim(String name,
         int mode,
         boolean timeouts)Initialize the StreamConnection and return it. | 
| protected abstract  int | readBytes(byte[] b,
          int off,
          int len)Reads up to lenbytes of data from the input stream into
 an array of bytes, blocks until at least one byte is available. | 
|  void | reset()Repositions input stream for a connection to the position at the time the markmethod was last called on this input stream. | 
| protected abstract  int | writeBytes(byte[] b,
           int off,
           int len)Writes lenbytes from the specified byte array
 starting at offsetoffto this output stream. | 
| Methods inherited from class com.sun.squawk.io.ConnectionBase | 
|---|
| open | 
| Methods inherited from class java.lang.Object | 
|---|
| equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
protected boolean connectionOpen
protected int iStreams
protected int maxIStreams
protected int oStreams
protected int maxOStreams
| Constructor Detail | 
|---|
public ConnectionBaseAdapter()
| Method Detail | 
|---|
public abstract Connection openPrim(String name,
                                    int mode,
                                    boolean timeouts)
                             throws IOException
name - URL for the connection, without the
                         without the protocol partmode - I/O access mode, see Connectortimeouts - flag to indicate that the caller
                         wants timeout exceptions
IllegalArgumentException - If a parameter is invalid.
ConnectionNotFoundException - If the connection cannot
                                        be found.
IOException - If some other kind of I/O error occurs.
public void initStreamConnection(int mode)
                          throws IOException
mode - I/O access mode, see Connector
IllegalArgumentException - If a parameter is invalid.
IOException - If some other kind of I/O error occurs.
public InputStream openInputStream()
                            throws IOException
openInputStream in interface InputConnectionopenInputStream in class ConnectionBaseIOException - if an I/O error occurs when creating the
                          output stream.
public DataInputStream openDataInputStream()
                                    throws IOException
openDataInputStream in interface InputConnectionopenDataInputStream in class ConnectionBaseIOException - If an I/O error occurs
public OutputStream openOutputStream()
                              throws IOException
openOutputStream in interface OutputConnectionopenOutputStream in class ConnectionBaseIOException - if an I/O error occurs when creating the
                          output stream.
public DataOutputStream openDataOutputStream()
                                      throws IOException
openDataOutputStream in interface OutputConnectionopenDataOutputStream in class ConnectionBaseIOException - If an I/O error occurs
public void close()
           throws IOException
close in interface Connectionclose in class ConnectionBaseIOException - if an I/O error occurs when closing the
                          connection.
protected void closeInputStream()
                         throws IOException
IOException - if the subclass throws one
protected void closeOutputStream()
                          throws IOException
IOException - if the subclass throws oneprotected void notifyClosedInput()
protected void notifyClosedOutput()
protected void ensureOpen()
                   throws IOException
IOException - is thrown, if the stream is not open.
protected abstract void disconnect()
                            throws IOException
IOException - if an I/O error occurs.
protected abstract int readBytes(byte[] b,
                                 int off,
                                 int len)
                          throws IOException
len bytes of data from the input stream into
 an array of bytes, blocks until at least one byte is available.
b - the buffer into which the data is read.off - the start offset in array b
                   at which the data is written.len - the maximum number of bytes to read.
-1 if there is no more data because the end of
             the stream has been reached.
IOException - if an I/O error occurs.
public int available()
              throws IOException
0. It is up to subclasses to override this method.
IOException - if an I/O error occurs.
protected abstract int writeBytes(byte[] b,
                                  int off,
                                  int len)
                           throws IOException
len bytes from the specified byte array
 starting at offset off to this output stream.
 Polling the native code is done here to allow for simple asynchronous native code to be written. Not all implementations work this way (they block in the native code) but the same Java code works for both.
b - the data.off - the start offset in the data.len - the number of bytes to write.
IOException - if an I/O error occurs. In particular,
             an IOException is thrown if the output
             stream is closed.
protected void flush()
              throws IOException
flush is
 that calling it is an indication that, if any bytes previously
 written that have been buffered by the connection,
 should immediately be written to their intended destination.
 
 The flush method of ConnectionBaseAdapter
 does nothing.
IOException - if an I/O error occurs.public boolean markSupported()
mark and
 reset methods.
  The markSupported method of
 ConnectionBaseAdapter returns false.
 
Subclasses should override this method if they support own mark/reset functionality.
true if input stream for this connection supports
           the mark and reset methods;
           false otherwise.InputStream.mark(int), 
InputStream.reset()public void mark(int readlimit)
reset method repositions this
 stream at the last marked position so that subsequent reads re-read
 the same bytes.
  The mark method of ConnectionBaseAdapter
  does nothing.
 
Subclasses should override this method if they support own mark/reset functionality.
readlimit - the maximum limit of bytes that can be read before
                      the mark position becomes invalid.InputStream.reset()
public void reset()
           throws IOException
mark method was last called on this input stream.
  The method reset for ConnectionBaseAdapter
 class does nothing and always throws an IOException.
 
Subclasses should override this method if they support own mark/reset functionality.
IOException - if this stream has not been marked or if the
                          mark has been invalidated.InputStream.reset(), 
InputStream.mark(int), 
IOException| 
 | " 2013 FRC Java API" | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||