Class FileDicomKey

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<FileDicomKey>
    Direct Known Subclasses:
    PrivateFileDicomKey

    public class FileDicomKey
    extends ModelSerialCloneable
    implements java.lang.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:
    FileDicomTag, FileInfoDicom, Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String key
      The dicom tag identifier in the format 'group,element'.
      private static long serialVersionUID
      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.
      FileDicomKey​(java.lang.String keyStr)
      Creates new key with the given String as the unique identifier.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(FileDicomKey toCompare)  
      boolean equals​(java.lang.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.
      void finalize()
      Prepares this class for cleanup.
      java.lang.String getElement()
      returns only the element portion of the DICOM key.
      int getElementNumber()
      Returns the element portion of a DICOM key as an integer.
      java.lang.String getGroup()
      returns only the group portion of the DICOM key.
      int getGroupNumber()
      returns the group portion of the DICOM key as an integer.
      java.lang.String getKey()
      Gets the unique identifier.
      int hashCode()
      Returns the unique identifier's hash code.
      void setKey​(java.lang.String key)
      Sets the unique identifier.
      java.lang.String toString()
      Returns the unique identifier.
      static boolean verify​(java.lang.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 java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • serialVersionUID

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

        protected java.lang.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 Detail

      • FileDicomKey

        public FileDicomKey​(java.lang.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:
        java.lang.IllegalArgumentException - if s is null, or formatted incorrectly.
      • FileDicomKey

        public FileDicomKey​(int group,
                            int element)
                     throws java.lang.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:
        java.lang.NumberFormatException - If there is a problem converting the group and element numbers to hexidecimal strings.
    • Method Detail

      • verify

        public static boolean verify​(java.lang.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:
        java.lang.IllegalArgumentException - If the inputted string cannot be used to represent a DICOM key.
      • equals

        public boolean equals​(java.lang.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 java.lang.Object
        Parameters:
        obj - Object to compare to.
        Returns:
        true if equal.
      • finalize

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

        public final java.lang.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:
        java.lang.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:
        getGroupNumber()
      • getGroup

        public final java.lang.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 java.lang.NumberFormatException
        returns the group portion of the DICOM key as an integer.
        Returns:
        The Group number as an integer of the key.
        Throws:
        java.lang.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 java.lang.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 java.lang.Object
        Returns:
        The hash code.
      • setKey

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

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

        public int compareTo​(FileDicomKey toCompare)
        Specified by:
        compareTo in interface java.lang.Comparable<FileDicomKey>