1.0.0

org.eclipse.soda.dk.connection.service
Interface ConnectionService

All Known Subinterfaces:
FileConnectionService, RandomAccessFileConnectionService, SerialConnectionService, TcpipConnectionService, TcpipServerConnectionService, UrlConnectionService
All Known Implementing Classes:
Connection, EchoConnection, FileConnection, RandomAccessFileConnection, SerialConnection, StreamConnection, TcpipConnection, TcpipServerConnection, TraceConnection, UrlConnection

public interface ConnectionService

The ConnectionService interface defines the ConnectionService concept. A ConnectionService is an encapsulation of a pair of streams, one input and one output. A user of a connection can open and close a connection, get each stream, and test if a stream is open. Generally, after opening a ConnectionService, and getting the streams, a ConnectionService user will read and write to the streams, closing the ConnectionService when finished.

Version:
1.0.0
See Also:
Connection

Field Summary
static java.lang.String CONNECTION_KEY
          Define the connection key (String) constant.
static java.lang.String DEFAULT_CONNECTION
          Define the default connection (String) constant.
static java.lang.String SERVICE_NAME
          Define the OSGi service name.
 
Method Summary
 void close()
          Perform the close action method.
 void exit()
          Request the connection to exit.
 void flush()
          Flush any data to be written.
 boolean isOpen()
          Gets the boolean open property value.
 void open()
          Perform the open action method.
 int read(byte[] bytes)
          Read data into the bytes specified.
 int read(byte[] bytes, int offset, int length)
          Read data into the bytes specified.
 void write(byte[] bytes)
          Writes the bytes from the byte array.
 void write(byte[] bytes, int offset, int count)
          Writes count bytes from the byte array buffer starting at offset.
 

Field Detail

SERVICE_NAME

static final java.lang.String SERVICE_NAME
Define the OSGi service name.

See Also:
Constant Field Values

CONNECTION_KEY

static final java.lang.String CONNECTION_KEY
Define the connection key (String) constant.

See Also:
Constant Field Values

DEFAULT_CONNECTION

static final java.lang.String DEFAULT_CONNECTION
Define the default connection (String) constant.

See Also:
Constant Field Values
Method Detail

close

void close()
           throws java.io.IOException
Perform the close action method. This API closes the ConnectionService, including the contained Streams. It may throw an IOException if it fails while closing either stream. href="java.io.IOException.html">IOException Thrown if the IOException exception condition occurs.

Throws:
java.io.IOException

exit

void exit()
          throws java.io.IOException
Request the connection to exit. The connection will be closed. It will no longer read or write. All resources will be released. After an exit, the connection service can not be restarted.

Throws:
IOException.
java.io.IOException

flush

void flush()
           throws java.io.IOException
Flush any data to be written. an error occurs attempting to flush this Writer.

Throws:
java.io.IOException

isOpen

boolean isOpen()
Gets the boolean open property value. This API returns a boolean which tells whether or not the ConnectionService contains valid, open streams.

Returns:
Results of the is open (boolean) value.

open

void open()
          throws java.io.IOException
Perform the open action method. This API opens the ConnectionService, including the contained Streams. It may throw an IOException if it fails while opening either stream. href="java.io.IOException.html">IOException Thrown if the IOException exception condition occurs.

Throws:
java.io.IOException

read

int read(byte[] bytes)
         throws java.io.IOException
Read data into the bytes specified. the byte array in which to store the read bytes.

Parameters:
bytes - The bytes (byte[]) parameter.
Returns:
the number of bytes actually read or -1 if end of stream. If the stream is already closed or another IOException occurs.
Throws:
java.io.IOException
See Also:
read(byte[],int,int)

read

int read(byte[] bytes,
         int offset,
         int length)
         throws java.io.IOException
Read data into the bytes specified. the byte array in which to store the read bytes. the offset in b to store the read bytes. the maximum number of bytes to store in b.

Parameters:
bytes - The bytes (byte[]) parameter.
offset - The offset (int) parameter.
length - The length (int) parameter.
Returns:
the number of bytes actually read or -1 if end of stream. If the stream is already closed or another IOException occurs.
Throws:
java.io.IOException
See Also:
read(byte[])

write

void write(byte[] bytes)
           throws java.io.IOException
Writes the bytes from the byte array. the buffer to be written an error occurs attempting to write to this OutputStream. If offset or count are outside of bounds.

Parameters:
bytes - The bytes (byte[]) parameter.
Throws:
java.io.IOException
See Also:
write(byte[],int,int)

write

void write(byte[] bytes,
           int offset,
           int count)
           throws java.io.IOException
Writes count bytes from the byte array buffer starting at offset. the buffer to be written offset in buffer to get bytes number of bytes in buffer to write an error occurs attempting to write to this OutputStream. If offset or count are outside of bounds.

Parameters:
bytes - The bytes (byte[]) parameter.
offset - The offset (int) parameter.
count - The count (int) parameter.
Throws:
java.io.IOException
See Also:
write(byte[])

1.0.0

Copyright (c) 1999, 2007 IBM