Class FileDicomTagTable

java.lang.Object
gov.nih.mipav.model.file.FileDicomTagTable
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
FileDicomSQItem

public class FileDicomTagTable extends Object implements Serializable, Cloneable
A table containing dicom tags. Common tags are not stored here and instead should be stored in the reference tag table. The reference tag table may refer to another table within a FileInfoDicom.
See Also:
  • Field Details

    • serialVersionUID

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

      protected FileDicomTagTable[] childTagTables
      A list of tag tables which point to this as their reference tag table.
    • isReferenceTagTable

      protected boolean isReferenceTagTable
      Whether this tag table is a reference table (meaning it contains all of the tags for a given fileInfo and does not need to refer anywhere else when retrieving values).
    • parentFileInfo

      protected FileInfoDicom parentFileInfo
      The dicom file info that this tag table belongs to. Used to update file info fields based on tag table changes.
    • referenceTagTable

      protected FileDicomTagTable referenceTagTable
      The reference table to check when a tag is not found in this table. If this table is a reference table, then the value should be this and no checking of the referenceTagTable should take place.
    • tagTable

      protected Hashtable<FileDicomKey,FileDicomTag> tagTable
      Tags unique to this slice, or all of the tags for this slice if this is a reference tag table.
    • vr_type

      protected FileInfoDicom.VRtype vr_type
      VR_type to indicate explicit/implicit nature of tags contained in tag table
  • Constructor Details

    • FileDicomTagTable

      public FileDicomTagTable(FileInfoDicom parent, FileInfoDicom.VRtype vr_type)
      Creates a new FileDicomTagTable object. Should be used for the tags from the first slice of an image volume.
      Parameters:
      parent - The dicom file info that this tag table belongs to.
    • FileDicomTagTable

      public FileDicomTagTable(FileInfoDicom parent, FileDicomTagTable firstSliceTags, FileInfoDicom.VRtype vr_type)
      Creates a new FileDicomTagTable object.
      Parameters:
      parent - The dicom file info that this tag table belongs to.
      firstSliceTags - A reference to the tag table for the first slice of the image volume
  • Method Details

    • sortTagsList

      public static final FileDicomTag[] sortTagsList(Dictionary<FileDicomKey,FileDicomTag> tagList)
      Sorts the list of tags and returns it as an array in order.
      Parameters:
      tagList - A table of tags to sort according to their keys.
      Returns:
      The sorted list.
    • sortTagsList

      public static final FileDicomTag[] sortTagsList(Collection<FileDicomTag> tagList)
      Sorts the list of tags and returns it as an array in order.
      Parameters:
      tagList - A collection of tags to sort according to their keys.
      Returns:
      The sorted list.
    • attachChildTagTables

      public final void attachChildTagTables(FileDicomTagTable[] children)
      Sets the list of tag tables which point to this as their reference tag table.
      Parameters:
      children - A list of tag tables which point to this as their reference tag table.
    • clone

      public Object clone()
      Perform a deep copy of this tag table.
      Overrides:
      clone in class Object
      Returns:
      A new copy of the tag table.
    • containsTag

      public final boolean containsTag(String keyStr)
      Returns whether the tag table contains a tag with the given key identifier, either in the reference tag table or the slice-specific table
      Parameters:
      keyStr - the string representing the key for this tag -- 'group,element'
      Returns:
      whether a tag matching the given key is contained in this tag table (checks reference tag table).
    • containsTag

      public final boolean containsTag(FileDicomKey key)
      Returns whether the tag table contains a tag with the given key identifier, either in the reference tag table or the slice-specific table
      Parameters:
      key - the key for this tag
      Returns:
      whether a tag matching the given key is contained in this tag table (checks reference tag table).
    • containsUniqueTag

      public final boolean containsUniqueTag(String keyStr)
      Returns whether this specific tag table contains a tag with the given key identifier, does not check the reference tag table
      Parameters:
      keyStr - the string representing the key for this tag -- 'group,element'
      Returns:
      whether a tag matching the given key is contained in this tag table (does not check reference tag table).
    • containsUniqueTag

      public final boolean containsUniqueTag(FileDicomKey key)
      Returns whether this specific tag table contains a tag with the given key identifier, does not check the reference tag table
      Parameters:
      key - the key for this tag
      Returns:
      whether a tag matching the given key is contained in this tag table (does not check the reference tag table).
    • get

      public final FileDicomTag get(String keyStr)
      Accessor that returns the tag with a certain hexadecimal key.
      Parameters:
      keyStr - the string representing the key for this tag -- 'group,element'
      Returns:
      the tag matching that key string
    • get

      public final FileDicomTag get(FileDicomKey key)
      Accessor that returns the tag with a certain hexadecimal key.
      Parameters:
      key - the key for this tag
      Returns:
      the tag matching that key
    • getDataLength

      public int getDataLength(boolean includeTagID)
      Calculates the number of bytes that the data (the object value) takes to be stored. This method returns the number of data items times the sizeof the data type. This method will be so much simpler when (if) the tags are separated out as individual classes.
      Returns:
      size of the value in bytes
    • getNumberOfElements

      public final int getNumberOfElements()
      Gets the number of elements in the data set (# of tags in item).
      Returns:
      the number of elements
    • getTagList

      public final Hashtable<FileDicomKey,FileDicomTag> getTagList()
      Deprecated.
      See getTagListCopy()
      Returns a copy of all of the tags in this table, including tags from the reference tag table.
      Returns:
      A copy of all of the dicom tags.
    • getTagListCopy

      public final Hashtable<FileDicomKey,FileDicomTag> getTagListCopy()
      Returns a copy of all of the tags in this table, including tags from the reference tag table.
      Returns:
      A copy of all of the dicom tags.
    • getTagListUnique

      public final Hashtable<FileDicomKey,FileDicomTag> getTagListUnique()
      Returns only the tags stored directly in this tag table, not including tags from the reference tag table.
      Returns:
      The tags stored directly in this table.
    • getSeqTagList

      public final Vector<FileDicomTag> getSeqTagList()
      Returns a list of the sequence tags in this tag table (and reference tag table).
      Returns:
      A list of the sequence tags in this tag table (and reference tag table).
    • getReferenceTagTable

      public final FileDicomTagTable getReferenceTagTable()
      Returns:
      the referenceTagTable
    • getValue

      public final Object getValue(FileDicomKey key)
      Returns the value matching the key as a meaningful (ie., non-coded) string . This is the equivalent of calling get(key).getValue(true).
      Parameters:
      key - the key to search for
      Returns:
      the value that this key matches to as a String for output
      See Also:
    • getValue

      public final Object getValue(FileDicomKey key, boolean parse)
      Returns the value matching the key as a Java data element get(key).getValue(parse).
      Parameters:
      key - the key to search for
      parse - whether to parse the tag value to a non-coded string
      Returns:
      the value that this key matches to as a String for output
      See Also:
    • getValue

      public final Object getValue(String keyStr)
      Returns the value matching the key as a meaningful (ie., non-coded) string . This is the equivalent of calling get(keyStr).getValue(true).
      Parameters:
      keyStr - the hexidecimal key to search for -- 'group,element'
      Returns:
      the value that this key matches to as a String for output
      See Also:
    • getValue

      public final Object getValue(String keyStr, boolean parse)
      Returns the value matching the key as a Java data element get(keyStr).getValue(parse).
      Parameters:
      keyStr - the hexidecimal key to search for -- 'group,element'
      parse - whether to parse the tag value to a non-coded string
      Returns:
      the value that this key matches to as a String for output
      See Also:
    • getVr_type

      public final FileInfoDicom.VRtype getVr_type()
      Returns:
      the vr_type
    • importTags

      public final void importTags(FileInfoDicom srcDicomInfo)
      Sets the tags in this tag table to match the tags contained in the tag table of a dicom file info. All tags already in this table are removed (does not effect tags in its reference tag table).
      Parameters:
      srcDicomInfo - The dicom file info to copy tags from.
    • putPrivateTagValue

      public final void putPrivateTagValue(FileDicomTagInfo info)
      Adds a private tag to the tag table using some dicom info.
      Parameters:
      info - information about the private dicom tag.
    • removeTag

      public final void removeTag(String keyStr)
      Remove a tag from this tag table (does not affect reference table, if this is a non-reference table). If this is a reference table, the removal is dumb and doesn't copy the tag to the child tag tables.
      Parameters:
      keyStr - the hexidecimal key to search for -- 'group,element'
    • removeTag

      public final void removeTag(FileDicomKey key)
      Remove a tag from this tag table (does not affect reference table, if this is a non-reference table). If this is a reference table, the removal is dumb and doesn't copy the tag to the child tag tables.
      Parameters:
      key - the key to search for
    • reset

      public final void reset()
      Remove all of the tags from this table (does not affect reference table, if this is a non-reference table).
    • setLength

      public final void setLength(FileDicomKey key, int length)
      Sets the length of the tag.
      Parameters:
      key - the key to search for
      length - length to set
    • setLength

      public final void setLength(String keyStr, int length)
      Sets the length of the tag.
      Parameters:
      keyStr - the hexidecimal key to search for -- 'group,element'
      length - length to set
    • setValue

      public final void setValue(String name, Object value)
      Sets the value of the DicomTag in the tagsList Hashtable with the same hexadecimal tag name. The tag names are unique and that's why they are the keys to the Hashtable. This function also sets modality and other important file information. Should not be used for the values of private tags, unless they are already in the tag table (through a call to putPrivateTagValue()), since the value representation is unknown.
      Parameters:
      value - the value to set the DicomTag to
      key - the key for the DicomTag in tagsList
    • setValue

      public void setValue(FileDicomKey key, Object value)
      Sets the value of the DicomTag in the tagsList Hashtable with the same hexadecimal tag name. The tag names are unique and that's why they are the keys to the Hashtable. This function also sets modality and other important file information. Should not be used for the values of private tags, unless they are already in the tag table (through a call to putPrivateTagValue()), since the value representation is unknown.
      Parameters:
      key - the key for the DicomTag in tagsList
      value - the value to set the DicomTag to
    • setValue

      public final void setValue(String name, Object value, int length)
      Sets the value of the DicomTag in the tagsList Hashtable with the same hexadecimal tag name. The tag names are unique and that's why they are the keys to the Hashtable. This function also sets modality and other important file information. Should not be used for the values of private tags, unless they are already in the tag table (through a call to putPrivateTagValue()), since the value representation is unknown.
      Parameters:
      name - the key for the DicomTag in tagsList (Group, element)
      value - the value to set the DicomTag to
      length - the length of the tag
    • setValue

      public final void setValue(FileDicomKey key, Object value, int length)
      Sets the value of the DicomTag in the tagsList Hashtable with the same hexadecimal tag name. The tag names are unique and that's why they are the keys to the Hashtable. This function also sets modality and other important file information. Should not be used for the values of private tags, unless they are already in the tag table (through a call to putPrivateTagValue()), since the value representation is unknown.
      Parameters:
      key - the key for the DicomTag in tagsList
      value - the value to set the DicomTag to
      length - the length of the tag
    • setValue

      public final void setValue(FileDicomKey key, FileDicomTag tag, Object value, int length)
      Sets the value of the DicomTag in the tagsList Hashtable with the same hexadecimal tag name. The tag names are unique and that's why they are the keys to the Hashtable. This function also sets modality and other important file information. This function handles private tags appropriately without them first being added to the tagTable.
      Parameters:
      key - the key for the DicomTag in tagsList
      value - the value to set the DicomTag to
      length - the length of the tag
    • setVr_type

      public final void setVr_type(FileInfoDicom.VRtype vr_type)
      Parameters:
      vr_type - the vr_type to set
    • toString

      public String toString()
      Returns a string containing information about this tag table.
      Overrides:
      toString in class Object
      Returns:
      The contents of this tag table.
    • isTagSameAsReferenceTag

      protected final boolean isTagSameAsReferenceTag(FileDicomTag tag)
      Returns true if a given tag is in the reference tag table and has the same value as the tag in the reference table. Returns false if called from the reference tag table.
      Parameters:
      tag - The tag to check against the reference tag table.
      Returns:
      Whether the tag is the same as the one in the reference tag table, false otherwise or if this is the reference tag table.
    • put

      protected final void put(FileDicomTag tag)
      Adds a tag to the tag table, overwriting if a value is already in the table under this tag's key. If this is a reference tag table, then the current value in the tag table must be copied over to all of the tag tables which refer to this one.
      Parameters:
      tag - A tag to add to the table.
    • finalize

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

      public boolean isReferenceTagTable()
      Returns true if this dicom tag table is a root tag table, not attached to a reference table.
      Returns:
      true if this dicom tag table is a root tag table, not attached to a reference table.