Package gov.nih.mipav.model.dicomcomm
Class DICOM_Util
java.lang.Object
gov.nih.mipav.model.dicomcomm.DICOM_Util
Static DICOM and general utilities to support DICOM interfacing.
This DICOM communication package was originally based on the Java Dicom Package, whose license is below:
This DICOM communication package was originally based on the Java Dicom Package, whose license is below:
Java Dicom Package (com.zmed.dicom) Copyright (c) 1996-1997 Z Medical Imaging Systems, Inc. This software is provided, as is, for non-commercial educational purposes only. Use or incorporation of this software or derivative works in commercial applications requires written consent from Z Medical Imaging Systems, Inc. Z MEDICAL IMAGING SYSTEMS MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, OR CONFORMANCE TO ANY SPECIFICATION OR STANDARD. Z MEDICAL IMAGING SYSTEMS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING OR MODIFYING THIS SOFTWARE OR ITS DERIVATIVES. ============================================================================= This software package is implemented similarly to the UC Davis public domain C++ DICOM implementation which contains the following copyright notice: Copyright (C) 1995, University of California, Davis THIS SOFTWARE IS MADE AVAILABLE, AS IS, AND THE UNIVERSITY OF CALIFORNIA DOES NOT MAKE ANY WARRANTY ABOUT THE SOFTWARE, ITS PERFORMANCE, ITS MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES OR ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH THE USER. Copyright of the software and supporting documentation is owned by the University of California, and free access is hereby granted as a license to use this software, copy this software and prepare derivative works based upon this software. However, any distribution of this software source code or supporting documentation or derivative works (source code and supporting documentation) must include this copyright notice. The UC Davis C++ source code is publicly available from the following anonymous ftp site: ftp://imrad.ucdmc.ucdavis.edu/pub/dicom/UCDMC/
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final StringaddLeadingZeros(int value, int length) Pads zeros to a number.static final StringaddLeadingZeros(String value, int length) Pads zeros to a string representation of a number.static final voidclearByteArray(byte[] byteArray) Simple routine to fill a byte array with ' 'static final voidcopyByteArray(byte[] dest, byte[] src) Copies the source byte array into the destination byte array.static StringdetermineSOPClassUID(DICOM_Object dco, DICOM_Object ddo) Determines relevant SOP Class UID for a storage operation.static voiddetermineSOPClassUIDAndPush(String UID, DICOM_Object dco, DICOM_Object ddo, DICOM_Object dcor) Puts the required SOP class UID into the DICOMObject (Command).static final voidfillByteArray(byte[] byteArray, char charValue) Fills a byte array with some "char" value.static final intReturns a unique number for DICOM communiciton.static final intReturns a unique number for DICOM communiciton.static final intReturns a unique number for DICOM communiciton.static final intReturns an ODD unique number for DICOM communiciton.static final intReturns an ODD unique number for DICOM communiciton.static final intReturns an ODD unique number for DICOM communiciton.static final StringpadAndOrTruncate(String str, int length) Pads with spaces and/or truncates string.static final StringCreates a string in the form of the time determined when this method is called.static final StringtoHexString(int data) Converts an integer to a hex string of length 4 with leading zeros.static final StringtoHexString2(int data) Converts an integer to a hex string of length 2 with leading zeros.static final StringtrimIgnorableChar(String str) Trims the numbers and special character from the file name.static final StringTrims string to length.static StringunpadStringVal(byte[] byteArray) Unpads a DICOM ASCII string.static final voidzeroByteArray(byte[] byteArray) Fills a byte array with some zeros.
-
Field Details
-
uniqueID
public static int uniqueID
-
-
Constructor Details
-
DICOM_Util
public DICOM_Util()
-
-
Method Details
-
addLeadingZeros
Pads zeros to a string representation of a number.- Parameters:
value- string value to be paddedlength- total length of string- Returns:
- a string with zero padding if necessary
-
addLeadingZeros
Pads zeros to a number.- Parameters:
value- value to be paddedlength- total length of string- Returns:
- a string with zero padding if necessary
-
clearByteArray
public static final void clearByteArray(byte[] byteArray) Simple routine to fill a byte array with ' '- Parameters:
byteArray- array to be filled
-
copyByteArray
public static final void copyByteArray(byte[] dest, byte[] src) Copies the source byte array into the destination byte array.- Parameters:
dest- destintation arraysrc- source array
-
determineSOPClassUID
public static String determineSOPClassUID(DICOM_Object dco, DICOM_Object ddo) throws DICOM_Exception Determines relevant SOP Class UID for a storage operation.- Parameters:
dco- the incoming DICOM command messageddo- the incoming DICOM data object- Returns:
- the UID for the SOP class
- Throws:
DICOM_Exception- DOCUMENT ME!
-
determineSOPClassUIDAndPush
public static void determineSOPClassUIDAndPush(String UID, DICOM_Object dco, DICOM_Object ddo, DICOM_Object dcor) throws DICOM_Exception Puts the required SOP class UID into the DICOMObject (Command).- Parameters:
UID- UID (null if unknown)dco- incoming DICOM command message to which we are respondingddo- incoming DICOM data object to which we are sending with dcordcor- outgoing DICOM command message (the one to push the UID onto )- Throws:
DICOM_Exception- DOCUMENT ME!
-
fillByteArray
public static final void fillByteArray(byte[] byteArray, char charValue) Fills a byte array with some "char" value.- Parameters:
byteArray- array to be filledcharValue- value to fill the array (converted to byte)
-
getUniqueID
public static final int getUniqueID()Returns a unique number for DICOM communiciton.- Returns:
- a positive unique number
-
getUniqueID16
public static final int getUniqueID16()Returns a unique number for DICOM communiciton.- Returns:
- a positive 16 bit unique number
-
getUniqueID8
public static final int getUniqueID8()Returns a unique number for DICOM communiciton.- Returns:
- a positive 8 bit unique number
-
getUniqueOddID
public static final int getUniqueOddID()Returns an ODD unique number for DICOM communiciton.- Returns:
- an ODD, positive, 8 bit unique number
-
getUniqueOddID16
public static final int getUniqueOddID16()Returns an ODD unique number for DICOM communiciton.- Returns:
- an ODD, positive, 16 bit unique number
-
getUniqueOddID8
public static final int getUniqueOddID8()Returns an ODD unique number for DICOM communiciton.- Returns:
- an ODD, positive, 8 bit unique number
-
padAndOrTruncate
Pads with spaces and/or truncates string.- Parameters:
str- string to be modifiedlength- length to modify to string to- Returns:
- the modified string
-
timeStamper
Creates a string in the form of the time determined when this method is called.- Returns:
- the time in the form a String
-
toHexString
Converts an integer to a hex string of length 4 with leading zeros.- Parameters:
data- integer to be converted- Returns:
- the new string in Hex format of the supplied integer value
-
toHexString2
Converts an integer to a hex string of length 2 with leading zeros.- Parameters:
data- integer to be converted- Returns:
- the new string in Hex format of the supplied integer value
-
trimIgnorableChar
Trims the numbers and special character from the file name.- Parameters:
str- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
truncate
Trims string to length.- Parameters:
str- string to be trimmedlength- length to trim string- Returns:
- the trimmed string to length
-
unpadStringVal
Unpads a DICOM ASCII string. It truncates an odd lengthed byte array which ends in a space or a null and returns a String- Parameters:
byteArray- ASCII byte array to be converted to a String- Returns:
- the unpadded String
-
zeroByteArray
public static final void zeroByteArray(byte[] byteArray) Fills a byte array with some zeros.- Parameters:
byteArray- array to be filled
-