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 int
associationNumber
protected java.lang.String
calledAETitle
protected java.lang.String
callingAETitle
protected int
debugLevel
protected java.io.InputStream
in
protected java.lang.String
localHostName
protected int
maximumLengthReceived
protected java.io.OutputStream
out
protected java.util.LinkedList
presentationContexts
protected java.lang.String
remoteHostName
protected java.util.LinkedList
scuSCPRoleSelections
protected java.net.Socket
socket
-
Constructor Summary
Constructors Modifier Constructor Description protected
Association(int debugLevel)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
abort()
Send an A-ABORT-RQ.int
getAssociationNumber()
AssociationOutputStream
getAssociationOutputStream(byte presentationContextID)
A factory method to build anAssociationOutputStream
for this Association, on which to send data which is fragmented as appropriate into PDUs.abstract java.lang.String
getCalledAEHostName()
abstract int
getCalledAEPort()
java.lang.String
getCalledAETitle()
abstract java.lang.String
getCallingAEHostName()
abstract int
getCallingAEPort()
java.lang.String
getCallingAETitle()
java.lang.String
getEndpointDescription()
protected java.lang.String
getLocalHostName()
protected int
getLocalPort()
protected java.lang.String
getRemoteHostName()
protected int
getRemotePort()
protected static byte[]
getRestOfPDU(java.io.InputStream in, byte[] startBuffer, int pduLength)
byte
getSuitablePresentationContextID(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.byte
getSuitablePresentationContextID(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.String
getTransferSyntaxForPresentationContextID(byte identifier)
Get the Transfer Syntax UID of the Presentation Context specified by the Presentation Context ID.protected static void
readInsistently(java.io.InputStream in, byte[] b, int offset, int length, java.lang.String what)
void
release()
Send an A-RELEASE-RQ.void
send(byte presentationContextID, byte[] command, byte[] data)
Send a command and/or data in a single PDU, each PDV with the last fragment flag set.void
setReceivedDataHandler(ReceivedDataHandler h)
Register aReceivedDataHandler
to handle each PDU as it is received.protected void
setSocketOptions(java.net.Socket socket, int ourMaximumLengthReceived, int socketReceiveBufferSize, int socketSendBufferSize, int debugLevel)
Set the socket options for either initiator or acceptor.java.lang.String
toString()
void
waitForCommandPDataPDUs()
Continue to transfer data (remain in State 6) until the last fragment of a command has been received.void
waitForDataPDataPDUs()
Continue to transfer data (remain in State 6) until the last fragment of data has been received.void
waitForOnePDataPDU()
Continue to transfer data (remain in State 6) until one PDU has been received.void
waitForPDataPDUs(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.void
waitForPDataPDUsUntilHandlerReportsDone()
Continue to transfer data (remain in State 6) until the data handler reports that it is done.
-
-
-
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
-
-
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 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
- 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
-
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 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 anAssociationOutputStream
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 aReceivedDataHandler
to 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, 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 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, 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 indicationAReleaseException
- 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 indicationAReleaseException
- 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 indicationAReleaseException
- 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 indicationAReleaseException
- 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 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 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 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()
-
-