Class Association

java.lang.Object
com.pixelmed.network.Association

public abstract class Association extends Object
  • Field Details

    • associationNumber

      protected int associationNumber
    • calledAETitle

      protected String calledAETitle
    • callingAETitle

      protected String callingAETitle
    • presentationContexts

      protected LinkedList presentationContexts
    • scuSCPRoleSelections

      protected LinkedList scuSCPRoleSelections
    • maximumLengthReceived

      protected int maximumLengthReceived
    • socket

      protected Socket socket
    • in

      protected InputStream in
    • out

      protected OutputStream out
    • remoteHostName

      protected String remoteHostName
    • localHostName

      protected String localHostName
  • Constructor Details

    • Association

      protected Association()
  • Method Details

    • setSocketOptions

      protected void setSocketOptions(Socket socket, int ourMaximumLengthReceived, int socketReceiveBufferSize, int socketSendBufferSize) throws 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
      Throws:
      IOException
    • readInsistently

      protected static void readInsistently(InputStream in, byte[] b, int offset, int length, String what) throws DicomNetworkException, IOException
      Parameters:
      in -
      b -
      offset -
      length -
      what -
      Throws:
      IOException
      DicomNetworkException
    • getRestOfPDU

      protected static byte[] getRestOfPDU(InputStream in, byte[] startBuffer, int pduLength) throws DicomNetworkException, IOException
      Parameters:
      in -
      startBuffer -
      pduLength -
      Throws:
      IOException
      DicomNetworkException
    • release

      public void release() throws DicomNetworkException
      Send 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 DicomNetworkException
      Send 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 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
    • getAssociationOutputStream

      public AssociationOutputStream getAssociationOutputStream(byte presentationContextID) throws DicomNetworkException
      A factory method to build an AssociationOutputStream for 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 a ReceivedDataHandler to handle each PDU as it is received.
      Parameters:
      h - an implementation of the abstract class ReceivedDataHandler
      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(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(String abstractSyntaxUID, 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 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 String getCalledAETitle()
    • getCallingAETitle

      public String getCallingAETitle()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getEndpointDescription

      public String getEndpointDescription()
    • getRemoteHostName

      protected String getRemoteHostName()
    • getLocalHostName

      protected String getLocalHostName()
    • getCallingAEHostName

      public abstract String getCallingAEHostName()
    • getCalledAEHostName

      public abstract String getCalledAEHostName()
    • getRemotePort

      protected int getRemotePort()
    • getLocalPort

      protected int getLocalPort()
    • getCallingAEPort

      public abstract int getCallingAEPort()
    • getCalledAEPort

      public abstract int getCalledAEPort()