Package com.pixelmed.network
Class Association
- java.lang.Object
-
- com.pixelmed.network.Association
-
public abstract class Association extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description protected intassociationNumberprotected java.lang.StringcalledAETitleprotected java.lang.StringcallingAETitleprotected java.io.InputStreaminprotected java.lang.StringlocalHostNameprotected intmaximumLengthReceivedprotected java.io.OutputStreamoutprotected java.util.LinkedListpresentationContextsprotected java.lang.StringremoteHostNameprotected java.util.LinkedListscuSCPRoleSelectionsprotected java.net.Socketsocket
-
Constructor Summary
Constructors Modifier Constructor Description protectedAssociation()protectedAssociation(int debugLevel)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidabort()Send an A-ABORT-RQ.intgetAssociationNumber()AssociationOutputStreamgetAssociationOutputStream(byte presentationContextID)A factory method to build anAssociationOutputStreamfor this Association, on which to send data which is fragmented as appropriate into PDUs.abstract java.lang.StringgetCalledAEHostName()abstract intgetCalledAEPort()java.lang.StringgetCalledAETitle()abstract java.lang.StringgetCallingAEHostName()abstract intgetCallingAEPort()java.lang.StringgetCallingAETitle()java.lang.StringgetEndpointDescription()protected java.lang.StringgetLocalHostName()protected intgetLocalPort()protected java.lang.StringgetRemoteHostName()protected intgetRemotePort()protected static byte[]getRestOfPDU(java.io.InputStream in, byte[] startBuffer, int pduLength)bytegetSuitablePresentationContextID(java.lang.String abstractSyntaxUID)Find a Presentation Context for the a particular SOP Class UID, using any available Transfer Syntax but preferring compressed then, Explicit VR Little Endian, then any Explicit VR, over Implicit VR.bytegetSuitablePresentationContextID(java.lang.String abstractSyntaxUID, java.lang.String transferSyntaxUID)Find a Presentation Context for a particular combination of SOP Class UID and Transfer Syntax.java.lang.StringgetTransferSyntaxForPresentationContextID(byte identifier)Get the Transfer Syntax UID of the Presentation Context specified by the Presentation Context ID.protected static voidreadInsistently(java.io.InputStream in, byte[] b, int offset, int length, java.lang.String what)voidrelease()Send an A-RELEASE-RQ.voidsend(byte presentationContextID, byte[] command, byte[] data)Send a command and/or data in a single PDU, each PDV with the last fragment flag set.voidsetReceivedDataHandler(ReceivedDataHandler h)Register aReceivedDataHandlerto handle each PDU as it is received.protected voidsetSocketOptions(java.net.Socket socket, int ourMaximumLengthReceived, int socketReceiveBufferSize, int socketSendBufferSize)Set the socket options for either initiator or acceptor.protected voidsetSocketOptions(java.net.Socket socket, int ourMaximumLengthReceived, int socketReceiveBufferSize, int socketSendBufferSize, int debugLevel)Set the socket options for either initiator or acceptor.java.lang.StringtoString()voidwaitForCommandPDataPDUs()Continue to transfer data (remain in State 6) until the last fragment of a command has been received.voidwaitForDataPDataPDUs()Continue to transfer data (remain in State 6) until the last fragment of data has been received.voidwaitForOnePDataPDU()Continue to transfer data (remain in State 6) until one PDU has been received.voidwaitForPDataPDUs(int count, boolean stopAfterLastFragmentOfCommand, boolean stopAfterLastFragmentOfData, boolean stopAfterHandlerReportsDone)Continue to transfer data (remain in State 6) until the specified number of PDUs have been received or the specified conditions are satisfied.voidwaitForPDataPDUsUntilHandlerReportsDone()Continue to transfer data (remain in State 6) until the data handler reports that it is done.
-
-
-
Field Detail
-
associationNumber
protected int associationNumber
-
calledAETitle
protected java.lang.String calledAETitle
-
callingAETitle
protected java.lang.String callingAETitle
-
presentationContexts
protected java.util.LinkedList presentationContexts
-
scuSCPRoleSelections
protected java.util.LinkedList scuSCPRoleSelections
-
maximumLengthReceived
protected int maximumLengthReceived
-
socket
protected java.net.Socket socket
-
in
protected java.io.InputStream in
-
out
protected java.io.OutputStream out
-
remoteHostName
protected java.lang.String remoteHostName
-
localHostName
protected java.lang.String localHostName
-
-
Method Detail
-
setSocketOptions
protected void setSocketOptions(java.net.Socket socket, int ourMaximumLengthReceived, int socketReceiveBufferSize, int socketSendBufferSize, int debugLevel) throws java.io.IOExceptionSet the socket options for either initiator or acceptor.
Must be called before using the socket or the options won't set.
- Parameters:
socket- the socket whose options to setourMaximumLengthReceived- the maximum PDU length that we will offer to receivesocketReceiveBufferSize- the TCP socket receive buffer size to set (if possible), 0 means leave at the defaultsocketSendBufferSize- the TCP socket send buffer size to set (if possible), 0 means leave at the defaultdebugLevel- ignored- Throws:
java.io.IOException
-
setSocketOptions
protected void setSocketOptions(java.net.Socket socket, int ourMaximumLengthReceived, int socketReceiveBufferSize, int socketSendBufferSize) throws java.io.IOExceptionSet the socket options for either initiator or acceptor.
Must be called before using the socket or the options won't set.
- Parameters:
socket- the socket whose options to setourMaximumLengthReceived- the maximum PDU length that we will offer to receivesocketReceiveBufferSize- the TCP socket receive buffer size to set (if possible), 0 means leave at the defaultsocketSendBufferSize- the TCP socket send buffer size to set (if possible), 0 means leave at the default- Throws:
java.io.IOException
-
readInsistently
protected static void readInsistently(java.io.InputStream in, byte[] b, int offset, int length, java.lang.String what) throws DicomNetworkException, java.io.IOException- Parameters:
in-b-offset-length-what-- Throws:
java.io.IOExceptionDicomNetworkException
-
getRestOfPDU
protected static byte[] getRestOfPDU(java.io.InputStream in, byte[] startBuffer, int pduLength) throws DicomNetworkException, java.io.IOException- Parameters:
in-startBuffer-pduLength-- Throws:
java.io.IOExceptionDicomNetworkException
-
release
public void release() throws DicomNetworkExceptionSend an A-RELEASE-RQ. This is a confirmed service, so a normal return is the A-RELEASE confirmation primitive.- Throws:
DicomNetworkException
-
abort
public void abort() throws DicomNetworkExceptionSend an A-ABORT-RQ. This is an unconfirmed service, so a normal return is expected.- Throws:
DicomNetworkException
-
send
public void send(byte presentationContextID, byte[] command, byte[] data) throws DicomNetworkExceptionSend a command and/or data in a single PDU, each PDV with the last fragment flag set.- Parameters:
presentationContextID- included in the header of each PDUcommand- the command PDV payload, or null if nonedata- the data PDV payload, or null if none- Throws:
DicomNetworkException
-
getAssociationOutputStream
public AssociationOutputStream getAssociationOutputStream(byte presentationContextID) throws DicomNetworkException
A factory method to build anAssociationOutputStreamfor this Association, on which to send data which is fragmented as appropriate into PDUs.- Parameters:
presentationContextID- included in the header of each PDU- Throws:
DicomNetworkException
-
setReceivedDataHandler
public void setReceivedDataHandler(ReceivedDataHandler h) throws DicomNetworkException
Register aReceivedDataHandlerto handle each PDU as it is received.- Parameters:
h- an implementation of the abstract classReceivedDataHandler- Throws:
DicomNetworkException
-
waitForPDataPDUs
public void waitForPDataPDUs(int count, boolean stopAfterLastFragmentOfCommand, boolean stopAfterLastFragmentOfData, boolean stopAfterHandlerReportsDone) throws DicomNetworkException, AReleaseExceptionContinue to transfer data (remain in State 6) until the specified number of PDUs have been received or the specified conditions are satisfied. The registered receivedDataHandler is sent a PDataIndication.- Parameters:
count- the number of PDUs to be transferred, or -1 if no limit (stop only when conditions satisfied)stopAfterLastFragmentOfCommand- stop after the last fragment of a command has been receivedstopAfterLastFragmentOfData- stop after the last fragment of data has been receivedstopAfterHandlerReportsDone- stop after data handler reports that it is done- Throws:
DicomNetworkException- A-ABORT or A-P-ABORT indicationAReleaseException- A-RELEASE indication; transport connection is closed
-
waitForOnePDataPDU
public void waitForOnePDataPDU() throws DicomNetworkException, AReleaseExceptionContinue to transfer data (remain in State 6) until one PDU has been received. The registered receivedDataHandler is sent a PDataIndication.- Throws:
DicomNetworkException- A-ABORT or A-P-ABORT indicationAReleaseException- A-RELEASE indication; transport connection is closed
-
waitForCommandPDataPDUs
public void waitForCommandPDataPDUs() throws DicomNetworkException, AReleaseExceptionContinue to transfer data (remain in State 6) until the last fragment of a command has been received. The registered receivedDataHandler is sent a PDataIndication.- Throws:
DicomNetworkException- A-ABORT or A-P-ABORT indicationAReleaseException- A-RELEASE indication; transport connection is closed
-
waitForDataPDataPDUs
public void waitForDataPDataPDUs() throws DicomNetworkException, AReleaseExceptionContinue to transfer data (remain in State 6) until the last fragment of data has been received. The registered receivedDataHandler is sent a PDataIndication.- Throws:
DicomNetworkException- A-ABORT or A-P-ABORT indicationAReleaseException- A-RELEASE indication; transport connection is closed
-
waitForPDataPDUsUntilHandlerReportsDone
public void waitForPDataPDUsUntilHandlerReportsDone() throws DicomNetworkException, AReleaseExceptionContinue to transfer data (remain in State 6) until the data handler reports that it is done. The registered receivedDataHandler is sent a PDataIndication.- Throws:
DicomNetworkException- A-ABORT or A-P-ABORT indicationAReleaseException- A-RELEASE indication; transport connection is closed
-
getSuitablePresentationContextID
public byte getSuitablePresentationContextID(java.lang.String abstractSyntaxUID) throws DicomNetworkExceptionFind a Presentation Context for the a particular SOP Class UID, using any available Transfer Syntax but preferring compressed then, Explicit VR Little Endian, then any Explicit VR, over Implicit VR.- Parameters:
abstractSyntaxUID- the SOP Class UID for which to find a suitable Presentation Context- Returns:
- the Presentation Context ID of a suitable Presentation Context
- Throws:
DicomNetworkException- thrown if no suitable Presentation Context
-
getSuitablePresentationContextID
public byte getSuitablePresentationContextID(java.lang.String abstractSyntaxUID, java.lang.String transferSyntaxUID) throws DicomNetworkExceptionFind a Presentation Context for a particular combination of SOP Class UID and Transfer Syntax.- Parameters:
abstractSyntaxUID- the SOP Class UID for which to find a suitable Presentation ContexttransferSyntaxUID- the Transfer Syntax UID for which to find a suitable Presentation Context- Returns:
- the Presentation Context ID of a suitable Presentation Context
- Throws:
DicomNetworkException- thrown if no suitable Presentation Context
-
getTransferSyntaxForPresentationContextID
public java.lang.String getTransferSyntaxForPresentationContextID(byte identifier) throws DicomNetworkExceptionGet the Transfer Syntax UID of the Presentation Context specified by the Presentation Context ID.- Parameters:
identifier- the Presentation Context ID- Returns:
- the only or first Transfer Syntax UID
- Throws:
DicomNetworkException- thrown if no such Presentation Context or no Transfer Syntax for that Presentation Context (e.g. it was rejected)
-
getAssociationNumber
public int getAssociationNumber()
-
getCalledAETitle
public java.lang.String getCalledAETitle()
-
getCallingAETitle
public java.lang.String getCallingAETitle()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getEndpointDescription
public java.lang.String getEndpointDescription()
-
getRemoteHostName
protected java.lang.String getRemoteHostName()
-
getLocalHostName
protected java.lang.String getLocalHostName()
-
getCallingAEHostName
public abstract java.lang.String getCallingAEHostName()
-
getCalledAEHostName
public abstract java.lang.String getCalledAEHostName()
-
getRemotePort
protected int getRemotePort()
-
getLocalPort
protected int getLocalPort()
-
getCallingAEPort
public abstract int getCallingAEPort()
-
getCalledAEPort
public abstract int getCalledAEPort()
-
-