|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.sun.cdc.io.ConnectionBaseAdapter
public abstract class ConnectionBaseAdapter
Protocol classes extend this class to gain some of the common functionality needed to implement a CDC 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 |
connectionOpen
Flag indicating if the connection is open. |
protected static int |
iStreams
Number of input streams that were opened. |
protected int |
maxIStreams
Maximum number of open input streams. |
protected int |
maxOStreams
Maximum number of output streams. |
protected static int |
oStreams
Number 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. |
protected void |
checkForPermission()
Overridden by Protocols to check for permissions. |
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 |
connect(String name,
int mode,
boolean timeouts)
Connect to a target. |
protected abstract void |
disconnect()
Free up the connection resources. |
protected void |
ensureNoStreamsOpen()
Check if the streams are open. |
protected void |
ensureOpen()
Check if the connection is open. |
protected void |
flush()
Forces any buffered output bytes to be written out. |
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 mark and
reset methods. |
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. |
Connection |
openPrim(String name)
Check for required permission and open a connection to a target. |
Connection |
openPrim(String name,
int mode,
boolean timeouts)
Check for required permission and open a connection to a target. |
protected abstract int |
readBytes(byte[] b,
int off,
int len)
Reads up to len bytes 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 mark method was last called on this input stream. |
protected abstract int |
writeBytes(byte[] b,
int off,
int len)
Writes len bytes from the specified byte array
starting at offset off to this output stream. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected boolean connectionOpen
protected static int iStreams
protected int maxIStreams
protected static int oStreams
protected int maxOStreams
| Constructor Detail |
|---|
public ConnectionBaseAdapter()
| Method Detail |
|---|
public Connection openPrim(String name,
int mode,
boolean timeouts)
throws IOException
openPrim in interface ConnectionBaseInterfacename - 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.
protected void checkForPermission()
throws SecurityException,
InterruptedIOException
token - security token of the calling class or nullname - the URL of the connection without the protocol
SecurityException - if permissions are not granted
InterruptedIOException - if I/O associated with permissions is interrupted
public Connection openPrim(String name)
throws IOException
token - security token of the calling classname - URL for the connection, without the
without the protocol part
IllegalArgumentException - If a parameter is invalid.
ConnectionNotFoundException - If the connection cannot
be found.
IOException - If some other kind of I/O error occurs.
public InputStream openInputStream()
throws IOException
openInputStream in interface InputConnectionIOException - if an I/O error occurs when creating the
output stream.
public DataInputStream openDataInputStream()
throws IOException
openDataInputStream in interface InputConnectionIOException - If an I/O error occurs
public OutputStream openOutputStream()
throws IOException
openOutputStream in interface OutputConnectionIOException - if an I/O error occurs when creating the
output stream.
public DataOutputStream openDataOutputStream()
throws IOException
openDataOutputStream in interface OutputConnectionIOException - If an I/O error occurs
public void close()
throws IOException
close in interface ConnectionIOException - 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 one
protected void ensureOpen()
throws IOException
IOException - is thrown, if the stream is not open.
protected void ensureNoStreamsOpen()
throws IOException
IOException - is thrown, if the stream is still open.
protected abstract void connect(String name,
int mode,
boolean timeouts)
throws IOException
name - URL for the connection, without the protocol
partmode - I/O access mode, see Connectortimeouts - flag to indicate that the called 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.
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
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||