Methods Summary |
---|
private void | checkOpen()check if the stream is open
if (!isOpen) {
throw new IOException("the output stream has been closed");
}
|
public void | close()Close the SDPOutputStream and send the message held by the
sip connection
if (!isOpen) {
throw new IOException("stream already closed");
}
setOpen(false);
outputStream.close();
if (connection instanceof SipClientConnectionImpl) {
SipClientConnectionImpl sipClientConnection =
(SipClientConnectionImpl)connection;
// If the client connection is in a STREAM_OPEN state and
// the request is an ACK
// The connection goes into the COMPLETED state
if (sipClientConnection.state ==
SipClientConnectionImpl.STREAM_OPEN) {
if (sipClientConnection.getMethod().equals(Request.ACK)) {
sipClientConnection.state =
SipClientConnectionImpl.COMPLETED;
try {
super.close();
} catch (IOException ioe) {
ioe.printStackTrace();
}
return;
}
}
}
try {
connection.send();
} catch (IOException ioe) {
ioe.printStackTrace();
}
try {
super.close();
} catch (IOException ioe) {
ioe.printStackTrace();
}
|
public void | flush()Flushes this output stream and forces any buffered output bytes
to be written out. The general contract of flush is
that calling it is an indication that, if any bytes previously
written have been buffered by the implementation of the output
stream, such bytes should immediately be written to their
intended destination.
The flush method of OutputStream does nothing.
outputStream.flush();
|
protected java.io.ByteArrayOutputStream | getByteArrayOutputStream()Return the ByteArrayOutputStream object wrapped by this class.
The problem is that ByteArrayOutputStream methods do not throw
IOException, while SDPOutputStream methods should.
return outputStream;
|
public boolean | isOpen()Return the status of the output stream (open or closed).
When the stream is closed, write() throws an IOException.
The open or closed status does not affect the internal
ByteArrayOutputStream object.
return isOpen;
|
protected void | setOpen(boolean newOpenState)The send() functions use this function to toggle the stream state.
(send() cannot call close() because it's done vice versa:
close() calls send())
isOpen = newOpenState;
|
public java.lang.String | toString()Convert to a string containing debugging information.
return super.toString()+" isOpen="+isOpen;
|
public void | write(int b)Writes the specified byte to the wrapped byte array output stream.
checkOpen();
outputStream.write(b);
|
public void | write(byte[] b)Writes b.length bytes from the specified byte array to the
wrapped output stream. The general contract for write(b)
is that it should have exactly the same effect as the call
write(b, 0, b.length) .
checkOpen();
outputStream.write(b);
|
public void | write(byte[] b, int off, int len)Writes len bytes from the specified byte array
starting at offset off to the wrapped byte
array output stream.
checkOpen();
outputStream.write(b, off, len);
|