Class FileDicomKey

All Implemented Interfaces:
Serializable, Cloneable, Comparable<FileDicomKey>
Direct Known Subclasses:
PrivateFileDicomKey

public class FileDicomKey extends ModelSerialCloneable implements Comparable<FileDicomKey>
FileDicomKey goes along with FileDicomTag - it is the key into the hashtable that corresponds to a tag. For most of the tags it is simply a String that is the unique combination of group name and element name (e.g., "0002,0010"). But there are some tags given in the element dictionary as "50xx,0010" or "60xx,0050". The "x"s are wildcards meaning that there can be any number of group names that start with "50" or "60". In this case we want the hashtable to recognize the tag in order to get the pertinent information from elmdict (such as "Overlay Origin" and what type of data this is) while still storing the tags as unique. This is accomplished through this class and some code in FileInfoDicom.getEntry(String).
Author:
Neva Cherniavsky
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected String
    The dicom tag identifier in the format 'group,element'.
    private static final long
    Use serialVersionUID for interoperability.
  • Constructor Summary

    Constructors
    Constructor
    Description
    FileDicomKey(int group, int element)
    Creates a Key from the given group and element numbers provided.
    Creates new key with the given String as the unique identifier.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    boolean
    Objects are equal if both are of type FileDicomKey, and both refer to the same value; if the input type is a String and the String representation of the key matches.
    void
    Prepares this class for cleanup.
    final String
    returns only the element portion of the DICOM key.
    final int
    Returns the element portion of a DICOM key as an integer.
    final String
    returns only the group portion of the DICOM key.
    final int
    returns the group portion of the DICOM key as an integer.
    final String
    Gets the unique identifier.
    int
    Returns the unique identifier's hash code.
    final void
    Sets the unique identifier.
    Returns the unique identifier.
    static boolean
    verify(String keyStr)
    Checks that the String s indeed refers to a String that is a valid key, two comma-separated hexidecimal numbers in the format of "[four digit Group number],[four digit element number]".

    Methods inherited from class gov.nih.mipav.model.structures.ModelSerialCloneable

    clone, nativeClone

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Use serialVersionUID for interoperability.
      See Also:
    • key

      protected String key
      The dicom tag identifier in the format 'group,element'. 'x' is allowed in the group number for wildcards in the dicom dictionary. E.g., '0002,0010' or '50xx,00E1'.
  • Constructor Details

    • FileDicomKey

      public FileDicomKey(String keyStr)
      Creates new key with the given String as the unique identifier. The string is checked for proper format, that it specifies 2 hexadecimal strings, separated by a comma.
      Parameters:
      keyStr - Unique identifier.
      Throws:
      IllegalArgumentException - if s is null, or formatted incorrectly.
    • FileDicomKey

      public FileDicomKey(int group, int element) throws NumberFormatException
      Creates a Key from the given group and element numbers provided. Example call: new FileDicomKey(0x0080,0x001F);
      Parameters:
      group - Dicom tag group number.
      element - Dicom tag element number.
      Throws:
      NumberFormatException - If there is a problem converting the group and element numbers to hexidecimal strings.
  • Method Details

    • verify

      public static boolean verify(String keyStr)
      Checks that the String s indeed refers to a String that is a valid key, two comma-separated hexidecimal numbers in the format of "[four digit Group number],[four digit element number]". The Group number must be four digits, but the final 2 digits may be the character "xx", which is used to represent a variable group.
      Parameters:
      keyStr - a String which is in the format 'group,element' with 'xx' possibly replacing the last 2 digits of the group id
      Returns:
      true if the string input can be used to represent a DICOM key, false if it cannot.
      Throws:
      IllegalArgumentException - If the inputted string cannot be used to represent a DICOM key.
    • equals

      public boolean equals(Object obj)
      Objects are equal if both are of type FileDicomKey, and both refer to the same value; if the input type is a String and the String representation of the key matches. This equals method will check that the keys are exactly are equal or they are equal except for place-holding "x" characters.
      Overrides:
      equals in class Object
      Parameters:
      obj - Object to compare to.
      Returns:
      true if equal.
    • finalize

      public void finalize()
      Prepares this class for cleanup.
      Overrides:
      finalize in class Object
    • getElement

      public final String getElement()
      returns only the element portion of the DICOM key.
      Returns:
      The Element portion of the DICOM key.
    • getElementNumber

      public final int getElementNumber()
      Returns the element portion of a DICOM key as an integer.
      Returns:
      the element number as an integer of the key.
      Throws:
      NumberFormatException - if the element is a partially defined value and cannot be converted without some effort (eg, the element number is ("51xx")). This is possible, but should not be discovered in elements, only in groups.
      See Also:
    • getGroup

      public final String getGroup()
      returns only the group portion of the DICOM key.
      Returns:
      The group portion of the DICOM key.
    • getGroupNumber

      public final int getGroupNumber() throws NumberFormatException
      returns the group portion of the DICOM key as an integer.
      Returns:
      The Group number as an integer of the key.
      Throws:
      NumberFormatException - if the element is a partially defined value and cannot be converted without some idea of what the number really is, and therefor some effort. Group numbers may be only partially specified (eg., "60xx").
    • getKey

      public final String getKey()
      Gets the unique identifier.
      Returns:
      The unique identifier.
    • hashCode

      public int hashCode()
      Returns the unique identifier's hash code.
      Overrides:
      hashCode in class Object
      Returns:
      The hash code.
    • setKey

      public final void setKey(String key)
      Sets the unique identifier.
      Parameters:
      key - The unique identifier.
      Throws:
      IllegalArgumentException - If the inputted string cannot be used to represent a DICOM key.
    • toString

      public String toString()
      Returns the unique identifier.
      Overrides:
      toString in class Object
      Returns:
      The unique identifier.
    • compareTo

      public int compareTo(FileDicomKey toCompare)
      Specified by:
      compareTo in interface Comparable<FileDicomKey>