Class DICOM_Util


  • public class DICOM_Util
    extends java.lang.Object
    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:
     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 
      Modifier and Type Field Description
      static int uniqueID  
    • Constructor Summary

      Constructors 
      Constructor Description
      DICOM_Util()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String addLeadingZeros​(int value, int length)
      Pads zeros to a number.
      static java.lang.String addLeadingZeros​(java.lang.String value, int length)
      Pads zeros to a string representation of a number.
      static void clearByteArray​(byte[] byteArray)
      Simple routine to fill a byte array with ' '
      static void copyByteArray​(byte[] dest, byte[] src)
      Copies the source byte array into the destination byte array.
      static java.lang.String determineSOPClassUID​(DICOM_Object dco, DICOM_Object ddo)
      Determines relevant SOP Class UID for a storage operation.
      static void determineSOPClassUIDAndPush​(java.lang.String UID, DICOM_Object dco, DICOM_Object ddo, DICOM_Object dcor)
      Puts the required SOP class UID into the DICOMObject (Command).
      static void fillByteArray​(byte[] byteArray, char charValue)
      Fills a byte array with some "char" value.
      static int getUniqueID()
      Returns a unique number for DICOM communiciton.
      static int getUniqueID16()
      Returns a unique number for DICOM communiciton.
      static int getUniqueID8()
      Returns a unique number for DICOM communiciton.
      static int getUniqueOddID()
      Returns an ODD unique number for DICOM communiciton.
      static int getUniqueOddID16()
      Returns an ODD unique number for DICOM communiciton.
      static int getUniqueOddID8()
      Returns an ODD unique number for DICOM communiciton.
      static java.lang.String padAndOrTruncate​(java.lang.String str, int length)
      Pads with spaces and/or truncates string.
      static java.lang.String timeStamper()
      Creates a string in the form of the time determined when this method is called.
      static java.lang.String toHexString​(int data)
      Converts an integer to a hex string of length 4 with leading zeros.
      static java.lang.String toHexString2​(int data)
      Converts an integer to a hex string of length 2 with leading zeros.
      static java.lang.String trimIgnorableChar​(java.lang.String str)
      Trims the numbers and special character from the file name.
      static java.lang.String truncate​(java.lang.String str, int length)
      Trims string to length.
      static java.lang.String unpadStringVal​(byte[] byteArray)
      Unpads a DICOM ASCII string.
      static void zeroByteArray​(byte[] byteArray)
      Fills a byte array with some zeros.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • uniqueID

        public static int uniqueID
    • Constructor Detail

      • DICOM_Util

        public DICOM_Util()
    • Method Detail

      • addLeadingZeros

        public static final java.lang.String addLeadingZeros​(java.lang.String value,
                                                             int length)
        Pads zeros to a string representation of a number.
        Parameters:
        value - string value to be padded
        length - total length of string
        Returns:
        a string with zero padding if necessary
      • addLeadingZeros

        public static final java.lang.String addLeadingZeros​(int value,
                                                             int length)
        Pads zeros to a number.
        Parameters:
        value - value to be padded
        length - 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 array
        src - source array
      • determineSOPClassUID

        public static java.lang.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 message
        ddo - the incoming DICOM data object
        Returns:
        the UID for the SOP class
        Throws:
        DICOM_Exception - DOCUMENT ME!
      • determineSOPClassUIDAndPush

        public static void determineSOPClassUIDAndPush​(java.lang.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 responding
        ddo - incoming DICOM data object to which we are sending with dcor
        dcor - 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 filled
        charValue - 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

        public static final java.lang.String padAndOrTruncate​(java.lang.String str,
                                                              int length)
        Pads with spaces and/or truncates string.
        Parameters:
        str - string to be modified
        length - length to modify to string to
        Returns:
        the modified string
      • timeStamper

        public static final java.lang.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

        public static final java.lang.String toHexString​(int data)
        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

        public static final java.lang.String toHexString2​(int data)
        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

        public static final java.lang.String trimIgnorableChar​(java.lang.String str)
        Trims the numbers and special character from the file name.
        Parameters:
        str - DOCUMENT ME!
        Returns:
        DOCUMENT ME!
      • truncate

        public static final java.lang.String truncate​(java.lang.String str,
                                                      int length)
        Trims string to length.
        Parameters:
        str - string to be trimmed
        length - length to trim string
        Returns:
        the trimmed string to length
      • unpadStringVal

        public static java.lang.String unpadStringVal​(byte[] byteArray)
        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