Package com.pixelmed.network
Class AssociationOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- com.pixelmed.network.AssociationOutputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public class AssociationOutputStream extends java.io.OutputStreamA specialized java.io.OutputStream which buffers and fragments data which is written to it into PDUs and sends them over the supplied OutputStream which is (presumably) that of the java.net.Socket of an established
Association.This stream buffers data that is written to it and when it is either flushed or closed or reaches the specified maximum PDU size, writes data (not command) PDU's to the supplied output stream.
Need to take care with "last fragment" flag ... that cannot be set until close() is called, and if the buffer is empty at that time, a zero length PDU will be sent.
-
-
Constructor Summary
Constructors Constructor Description AssociationOutputStream(java.io.OutputStream out, int maxPDUSize, int presentationContextID, int debugLevel)Construct a PDU buffering OutputStream on top of another OutputStream
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Sets the last fragment flag and flushes (which sends a zero length PDU if necessary, and pads to an even length, if necessary).voidflush()Do nothing.voidwrite(byte[] b)Buffer the supplied data, flushing (actually sending) PDUs when the buffer is filled.voidwrite(byte[] b, int off, int len)Buffer the supplied data, flushing (actually sending) PDUs when the buffer is filled.voidwrite(int i)Buffer the supplied data, flushing (actually sending) PDUs when the buffer is filled.
-
-
-
Constructor Detail
-
AssociationOutputStream
public AssociationOutputStream(java.io.OutputStream out, int maxPDUSize, int presentationContextID, int debugLevel) throws DicomNetworkExceptionConstruct a PDU buffering OutputStream on top of another OutputStream- Parameters:
out- where to send the buffered outputmaxPDUSize- how large to make the buffer (i.e. the PDU) sizepresentationContextID- included in the header of each PDUdebugLevel- 0 for no debugging, > 0 for increasingly verbose debugging- Throws:
DicomNetworkException
-
-
Method Detail
-
write
public void write(int i) throws java.io.IOExceptionBuffer the supplied data, flushing (actually sending) PDUs when the buffer is filled.- Specified by:
writein classjava.io.OutputStream- Parameters:
i-- Throws:
java.io.IOException
-
write
public void write(byte[] b) throws java.io.IOExceptionBuffer the supplied data, flushing (actually sending) PDUs when the buffer is filled.- Overrides:
writein classjava.io.OutputStream- Parameters:
b-- Throws:
java.io.IOException
-
write
public void write(byte[] b, int off, int len) throws java.io.IOExceptionBuffer the supplied data, flushing (actually sending) PDUs when the buffer is filled.- Overrides:
writein classjava.io.OutputStream- Parameters:
b-off-len-- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOExceptionSets the last fragment flag and flushes (which sends a zero length PDU if necessary, and pads to an even length, if necessary). Does NOT actually close the underlying stream, since that may well be used for other operations later.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.OutputStream- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOExceptionDo nothing.- Specified by:
flushin interfacejava.io.Flushable- Overrides:
flushin classjava.io.OutputStream- Throws:
java.io.IOException
-
-