Class Association


  • public abstract class Association
    extends java.lang.Object
    • Field Detail

      • associationNumber

        protected int associationNumber
      • debugLevel

        protected int debugLevel
      • 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
    • Constructor Detail

      • Association

        protected Association​(int debugLevel)
    • Method Detail

      • setSocketOptions

        protected void setSocketOptions​(java.net.Socket socket,
                                        int ourMaximumLengthReceived,
                                        int socketReceiveBufferSize,
                                        int socketSendBufferSize,
                                        int debugLevel)
                                 throws java.io.IOException

        Set 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 set
        ourMaximumLengthReceived - the maximum PDU length that we will offer to receive
        socketReceiveBufferSize - the TCP socket receive buffer size to set (if possible), 0 means leave at the default
        socketSendBufferSize - the TCP socket send buffer size to set (if possible), 0 means leave at the default
        debugLevel - 0 for no debugging, > 0 for increasingly verbose debugging
        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.IOException
        DicomNetworkException
      • 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.IOException
        DicomNetworkException
      • send

        public void send​(byte presentationContextID,
                         byte[] command,
                         byte[] data)
                  throws DicomNetworkException
        Send 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 PDU
        command - the command PDV payload, or null if none
        data - the data PDV payload, or null if none
        Throws:
        DicomNetworkException
      • waitForPDataPDUs

        public void waitForPDataPDUs​(int count,
                                     boolean stopAfterLastFragmentOfCommand,
                                     boolean stopAfterLastFragmentOfData,
                                     boolean stopAfterHandlerReportsDone)
                              throws DicomNetworkException,
                                     AReleaseException
        Continue 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 received
        stopAfterLastFragmentOfData - stop after the last fragment of data has been received
        stopAfterHandlerReportsDone - stop after data handler reports that it is done
        Throws:
        DicomNetworkException - A-ABORT or A-P-ABORT indication
        AReleaseException - A-RELEASE indication; transport connection is closed
      • waitForOnePDataPDU

        public void waitForOnePDataPDU()
                                throws DicomNetworkException,
                                       AReleaseException
        Continue 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 indication
        AReleaseException - A-RELEASE indication; transport connection is closed
      • waitForCommandPDataPDUs

        public void waitForCommandPDataPDUs()
                                     throws DicomNetworkException,
                                            AReleaseException
        Continue 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 indication
        AReleaseException - A-RELEASE indication; transport connection is closed
      • waitForDataPDataPDUs

        public void waitForDataPDataPDUs()
                                  throws DicomNetworkException,
                                         AReleaseException
        Continue 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 indication
        AReleaseException - A-RELEASE indication; transport connection is closed
      • waitForPDataPDUsUntilHandlerReportsDone

        public void waitForPDataPDUsUntilHandlerReportsDone()
                                                     throws DicomNetworkException,
                                                            AReleaseException
        Continue 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 indication
        AReleaseException - A-RELEASE indication; transport connection is closed
      • getSuitablePresentationContextID

        public byte getSuitablePresentationContextID​(java.lang.String abstractSyntaxUID)
                                              throws DicomNetworkException
        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.
        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 DicomNetworkException
        Find 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 Context
        transferSyntaxUID - 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 DicomNetworkException
        Get 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:
        toString in class java.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()