Class DICOM_Util

java.lang.Object
gov.nih.mipav.model.dicomcomm.DICOM_Util

public class DICOM_Util extends 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 Details

    • uniqueID

      public static int uniqueID
  • Constructor Details

    • DICOM_Util

      public DICOM_Util()
  • Method Details

    • addLeadingZeros

      public static final String addLeadingZeros(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 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 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(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 String padAndOrTruncate(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 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 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 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 String trimIgnorableChar(String str)
      Trims the numbers and special character from the file name.
      Parameters:
      str - DOCUMENT ME!
      Returns:
      DOCUMENT ME!
    • truncate

      public static final String truncate(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 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