Package com.pixelmed.network
Class AssociationOutputStream
java.lang.Object
java.io.OutputStream
com.pixelmed.network.AssociationOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
A 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
ConstructorsConstructorDescriptionAssociationOutputStream
(OutputStream out, int maxPDUSize, int presentationContextID) Construct a PDU buffering OutputStream on top of another OutputStreamAssociationOutputStream
(OutputStream out, int maxPDUSize, int presentationContextID, int debugLevel) Construct a PDU buffering OutputStream on top of another OutputStream -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Sets the last fragment flag and flushes (which sends a zero length PDU if necessary, and pads to an even length, if necessary).void
flush()
Do nothing.void
write
(byte[] b) Buffer the supplied data, flushing (actually sending) PDUs when the buffer is filled.void
write
(byte[] b, int off, int len) Buffer the supplied data, flushing (actually sending) PDUs when the buffer is filled.void
write
(int i) Buffer the supplied data, flushing (actually sending) PDUs when the buffer is filled.Methods inherited from class java.io.OutputStream
nullOutputStream
-
Constructor Details
-
AssociationOutputStream
public AssociationOutputStream(OutputStream out, int maxPDUSize, int presentationContextID, int debugLevel) throws DicomNetworkException Construct 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
- ignored- Throws:
DicomNetworkException
-
AssociationOutputStream
public AssociationOutputStream(OutputStream out, int maxPDUSize, int presentationContextID) throws DicomNetworkException Construct 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 PDU- Throws:
DicomNetworkException
-
-
Method Details
-
write
Buffer the supplied data, flushing (actually sending) PDUs when the buffer is filled.- Specified by:
write
in classOutputStream
- Parameters:
i
-- Throws:
IOException
-
write
Buffer the supplied data, flushing (actually sending) PDUs when the buffer is filled.- Overrides:
write
in classOutputStream
- Parameters:
b
-- Throws:
IOException
-
write
Buffer the supplied data, flushing (actually sending) PDUs when the buffer is filled.- Overrides:
write
in classOutputStream
- Parameters:
b
-off
-len
-- Throws:
IOException
-
close
Sets 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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-
flush
Do nothing.- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
-