loci.formats.dicom

## Class DicomTag

- java.lang.Object
- - loci.formats.dicom.DicomTag

- All Implemented Interfaces:
    java.lang.Comparable<DicomTag>

      public class DicomTag
      extends java.lang.Object
      implements java.lang.Comparable<DicomTag>

  Represents a complete DICOM tag, including the dictionary attribute, actual VR, value, and any "child" tags (in the case of a sequence).

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `DicomAttribute` | `attribute`
    `private boolean` | `bigEndianTransferSyntax`
    `java.util.List<DicomTag>` | `children`
    `int` | `elementLength`
    `java.lang.String` | `key`
    `private boolean` | `oddLocations`
    `DicomTag` | `parent`
    `private long` | `start`
    `ResolutionStrategy` | `strategy`
    `int` | `tag`
    `java.lang.Object` | `value`
    `DicomVR` | `vr`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DicomTag(DicomAttribute attribute)`
    `DicomTag(DicomAttribute attribute, DicomVR vr)`
    `DicomTag(int tag, DicomVR vr)`
    `DicomTag(loci.common.RandomAccessInputStream in, boolean bigEndian, long location, boolean oddLocations)` Read a complete tag and value from the given input stream.
    `DicomTag(loci.common.RandomAccessInputStream in, boolean bigEndian, long location, boolean oddLocations, boolean readValue)` Read a complete tag and optionally a value from the given input stream.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `compareTo(DicomTag o)`
    `long` | `getEndPointer()` Get the file pointer at which the value ends (useful for sequences and byte streams).
    `private int` | `getLength(loci.common.RandomAccessInputStream in)` Get the length of the next value in the given input stream.
    `private int` | `getNextTag(loci.common.RandomAccessInputStream in)` Get the next 4 byte DICOM tag from the given input stream.
    `java.lang.Number` | `getNumberValue()` Get a number representation of the current value, or null if not a number.
    `java.lang.String` | `getStringValue()` Get a string representation of the current value.
    `long` | `getValueStartPointer()` Get the file pointer at which the value starts (useful for sequences and byte streams).
    `boolean` | `isPrivateContentCreator()` See https://dicom.nema.org/dicom/2013/output/chtml/part05/sect_7.8.html
    `DicomTag` | `lookupChild(DicomAttribute attr)` Find the first child tag with the given attribute, or null if one does not exist.
    `java.lang.String` | `toString()`
    `boolean` | `validate(java.util.List<DicomTag> tags)` Check this tag against a list of existing tags.
    `void` | `validateValue()` Compare the value type to the VR.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### parent

          public DicomTag parent

    - #### children

          public java.util.List<DicomTag> children

    - #### tag

          public int tag

    - #### attribute

          public DicomAttribute attribute

    - #### vr

          public DicomVR vr

    - #### key

          public java.lang.String key

    - #### value

          public java.lang.Object value

    - #### elementLength

          public int elementLength

    - #### start

          private long start

    - #### bigEndianTransferSyntax

          private boolean bigEndianTransferSyntax

    - #### oddLocations

          private boolean oddLocations

    - #### strategy

          public ResolutionStrategy strategy

  - ### Constructor Detail

    - #### DicomTag

          public DicomTag(DicomAttribute attribute)

    - #### DicomTag

          public DicomTag(DicomAttribute attribute,
                          DicomVR vr)

    - #### DicomTag

          public DicomTag(int tag,
                          DicomVR vr)

    - #### DicomTag

          public DicomTag(loci.common.RandomAccessInputStream in,
                          boolean bigEndian,
                          long location,
                          boolean oddLocations)
                   throws FormatException,
                          java.io.IOException

      Read a complete tag and value from the given input stream.
      Throws:
        `FormatException`
        `java.io.IOException`

    - #### DicomTag

          public DicomTag(loci.common.RandomAccessInputStream in,
                          boolean bigEndian,
                          long location,
                          boolean oddLocations,
                          boolean readValue)
                   throws FormatException,
                          java.io.IOException

      Read a complete tag and optionally a value from the given input stream.
      Throws:
        `FormatException`
        `java.io.IOException`

  - ### Method Detail

    - #### getNextTag

          private int getNextTag(loci.common.RandomAccessInputStream in)
                          throws FormatException,
                                 java.io.IOException

      Get the next 4 byte DICOM tag from the given input stream.
      Throws:
        `FormatException`
        `java.io.IOException`

    - #### getLength

          private int getLength(loci.common.RandomAccessInputStream in)
                         throws java.io.IOException

      Get the length of the next value in the given input stream.
      Throws:
        `java.io.IOException`

    - #### getStringValue

          public java.lang.String getStringValue()

      Get a string representation of the current value.

    - #### getNumberValue

          public java.lang.Number getNumberValue()

      Get a number representation of the current value, or null if not a number.

    - #### getValueStartPointer

          public long getValueStartPointer()

      Get the file pointer at which the value starts (useful for sequences and byte streams).

    - #### getEndPointer

          public long getEndPointer()

      Get the file pointer at which the value ends (useful for sequences and byte streams).

    - #### lookupChild

          public DicomTag lookupChild(DicomAttribute attr)

      Find the first child tag with the given attribute, or null if one does not exist.

    - #### validate

          public boolean validate(java.util.List<DicomTag> tags)

      Check this tag against a list of existing tags. If this tag is a duplicate of an existing tag or otherwise deemed invalid, return false. Otherwise return true.

    - #### validateValue

          public void validateValue()

      Compare the value type to the VR. If the two types do not match, attempt to conver the value into the VR's type. Usually this means parsing numerical values from a String.

    - #### isPrivateContentCreator

          public boolean isPrivateContentCreator()

      See https://dicom.nema.org/dicom/2013/output/chtml/part05/sect_7.8.html
      Returns:
        true if this is a private content creator tag

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### compareTo

          public int compareTo(DicomTag o)

      Specified by:
        `compareTo` in interface `java.lang.Comparable<DicomTag>`

Copyright © 2026 Open Microscopy Environment