Class Attributes

java.lang.Object
org.aoju.bus.image.galaxy.data.Attributes
All Implemented Interfaces:
Serializable

public class Attributes extends Object implements Serializable
Since:
Java 17+
Author:
Kimi Liu
See Also:
  • Constructor Details

    • Attributes

      public Attributes()
    • Attributes

      public Attributes(boolean bigEndian)
    • Attributes

      public Attributes(int initialCapacity)
    • Attributes

      public Attributes(boolean bigEndian, int initialCapacity)
    • Attributes

      public Attributes(Attributes other)
    • Attributes

      public Attributes(Attributes other, boolean bigEndian)
    • Attributes

      public Attributes(Attributes other, int... selection)
    • Attributes

      public Attributes(Attributes other, boolean bigEndian, int... selection)
    • Attributes

      public Attributes(Attributes other, boolean bigEndian, Attributes selection)
  • Method Details

    • createFileMetaInformation

      public static Attributes createFileMetaInformation(String iuid, String cuid, String tsuid)
    • unifyCharacterSets

      public static void unifyCharacterSets(Attributes... attrsList)
    • clear

      public void clear()
    • getProperties

      public Map<String,Object> getProperties()
    • setProperties

      public void setProperties(Map<String,Object> properties)
    • getProperty

      public Object getProperty(String key, Object defVal)
    • setProperty

      public Object setProperty(String key, Object value)
    • clearProperty

      public Object clearProperty(String key)
    • isRoot

      public final boolean isRoot()
    • getLevel

      public final int getLevel()
    • bigEndian

      public final boolean bigEndian()
    • getParent

      public final Attributes getParent()
    • getRoot

      public final Attributes getRoot()
    • getLength

      public final int getLength()
    • getItemPosition

      public final long getItemPosition()
    • setItemPosition

      public final void setItemPosition(long itemPosition)
    • isEmpty

      public final boolean isEmpty()
    • size

      public final int size()
    • tags

      public int[] tags()
    • trimToSize

      public void trimToSize()
    • trimToSize

      public void trimToSize(boolean recursive)
    • internalizeStringValues

      public void internalizeStringValues(boolean decode)
    • getNestedDataset

      public Attributes getNestedDataset(int sequenceTag)
    • getNestedDataset

      public Attributes getNestedDataset(int sequenceTag, int itemIndex)
    • getNestedDataset

      public Attributes getNestedDataset(String privateCreator, int sequenceTag)
    • getNestedDataset

      public Attributes getNestedDataset(String privateCreator, int sequenceTag, int itemIndex)
    • getNestedDataset

      public Attributes getNestedDataset(ItemPointer... itemPointers)
    • getNestedDataset

      public Attributes getNestedDataset(List<ItemPointer> itemPointers)
    • tagOf

      public int tagOf(String privateCreator, int tag)
    • getSpecificCharacterSet

      public SpecificCharacterSet getSpecificCharacterSet(VR vr)
    • contains

      public boolean contains(int tag)
    • contains

      public boolean contains(String privateCreator, int tag)
    • containsValue

      public boolean containsValue(int tag)
    • containsValue

      public boolean containsValue(String privateCreator, int tag)
    • containsTagInRange

      public boolean containsTagInRange(int firstTag, int lastTag)
      Test whether at least one tag within the given range is contained.
      Parameters:
      firstTag - first tag (inclusive)
      lastTag - last tag (inclusive)
      Returns:
      whether at least one tag within the given range is contained
    • privateCreatorOf

      public String privateCreatorOf(int tag)
    • getValue

      public Object getValue(int tag)
    • getValue

      public Object getValue(int tag, VR.Holder vr)
    • getValue

      public Object getValue(String privateCreator, int tag)
    • getValue

      public Object getValue(String privateCreator, int tag, VR.Holder vr)
    • getVR

      public VR getVR(int tag)
    • getVR

      public VR getVR(String privateCreator, int tag)
    • getSequence

      public Sequence getSequence(int tag)
    • getSequence

      public Sequence getSequence(String privateCreator, int tag)
    • getBytes

      public byte[] getBytes(int tag) throws IOException
      Throws:
      IOException
    • getBytes

      public byte[] getBytes(String privateCreator, int tag) throws IOException
      Throws:
      IOException
    • getSafeBytes

      public byte[] getSafeBytes(int tag)
    • getSafeBytes

      public byte[] getSafeBytes(String privateCreator, int tag)
    • getString

      public String getString(int tag)
    • getString

      public String getString(int tag, String defVal)
    • getString

      public String getString(int tag, int valueIndex)
    • getString

      public String getString(int tag, int valueIndex, String defVal)
    • getString

      public String getString(String privateCreator, int tag)
    • getString

      public String getString(String privateCreator, int tag, String defVal)
    • getString

      public String getString(String privateCreator, int tag, VR vr)
    • getString

      public String getString(String privateCreator, int tag, VR vr, String defVal)
    • getString

      public String getString(String privateCreator, int tag, int valueIndex)
    • getString

      public String getString(String privateCreator, int tag, int valueIndex, String defVal)
    • getString

      public String getString(String privateCreator, int tag, VR vr, int valueIndex)
    • getString

      public String getString(String privateCreator, int tag, VR vr, int valueIndex, String defVal)
    • getStrings

      public String[] getStrings(int tag)
    • getStrings

      public String[] getStrings(String privateCreator, int tag)
    • getStrings

      public String[] getStrings(String privateCreator, int tag, VR vr)
    • getInt

      public int getInt(int tag, int defVal)
    • getInt

      public int getInt(int tag, int valueIndex, int defVal)
    • getInt

      public int getInt(String privateCreator, int tag, int defVal)
    • getInt

      public int getInt(String privateCreator, int tag, VR vr, int defVal)
    • getInt

      public int getInt(String privateCreator, int tag, int valueIndex, int defVal)
    • getInt

      public int getInt(String privateCreator, int tag, VR vr, int valueIndex, int defVal)
    • getInts

      public int[] getInts(int tag)
    • getInts

      public int[] getInts(String privateCreator, int tag)
    • getInts

      public int[] getInts(String privateCreator, int tag, VR vr)
    • getFloat

      public float getFloat(int tag, float defVal)
    • getFloat

      public float getFloat(int tag, int valueIndex, float defVal)
    • getFloat

      public float getFloat(String privateCreator, int tag, float defVal)
    • getFloat

      public float getFloat(String privateCreator, int tag, VR vr, float defVal)
    • getFloat

      public float getFloat(String privateCreator, int tag, int valueIndex, float defVal)
    • getFloat

      public float getFloat(String privateCreator, int tag, VR vr, int valueIndex, float defVal)
    • getFloats

      public float[] getFloats(int tag)
    • getFloats

      public float[] getFloats(String privateCreator, int tag)
    • getFloats

      public float[] getFloats(String privateCreator, int tag, VR vr)
    • getDouble

      public double getDouble(int tag, double defVal)
    • getDouble

      public double getDouble(int tag, int valueIndex, double defVal)
    • getDouble

      public double getDouble(String privateCreator, int tag, double defVal)
    • getDouble

      public double getDouble(String privateCreator, int tag, VR vr, double defVal)
    • getDouble

      public double getDouble(String privateCreator, int tag, int valueIndex, double defVal)
    • getDouble

      public double getDouble(String privateCreator, int tag, VR vr, int valueIndex, double defVal)
    • getDoubles

      public double[] getDoubles(int tag)
    • getDoubles

      public double[] getDoubles(String privateCreator, int tag)
    • getDoubles

      public double[] getDoubles(String privateCreator, int tag, VR vr)
    • getDate

      public Date getDate(int tag)
    • getDate

      public Date getDate(int tag, DatePrecision precision)
    • getDate

      public Date getDate(int tag, Date defVal)
    • getDate

      public Date getDate(int tag, Date defVal, DatePrecision precision)
    • getDate

      public Date getDate(int tag, int valueIndex)
    • getDate

      public Date getDate(int tag, int valueIndex, DatePrecision precision)
    • getDate

      public Date getDate(int tag, int valueIndex, Date defVal)
    • getDate

      public Date getDate(int tag, int valueIndex, Date defVal, DatePrecision precision)
    • getDate

      public Date getDate(String privateCreator, int tag)
    • getDate

      public Date getDate(String privateCreator, int tag, DatePrecision precision)
    • getDate

      public Date getDate(String privateCreator, int tag, Date defVal, DatePrecision precision)
    • getDate

      public Date getDate(String privateCreator, int tag, VR vr)
    • getDate

      public Date getDate(String privateCreator, int tag, VR vr, DatePrecision precision)
    • getDate

      public Date getDate(String privateCreator, int tag, VR vr, Date defVal)
    • getDate

      public Date getDate(String privateCreator, int tag, VR vr, Date defVal, DatePrecision precision)
    • getDate

      public Date getDate(String privateCreator, int tag, int valueIndex)
    • getDate

      public Date getDate(String privateCreator, int tag, int valueIndex, DatePrecision precision)
    • getDate

      public Date getDate(String privateCreator, int tag, int valueIndex, Date defVal)
    • getDate

      public Date getDate(String privateCreator, int tag, int valueIndex, Date defVal, DatePrecision precision)
    • getDate

      public Date getDate(String privateCreator, int tag, VR vr, int valueIndex)
    • getDate

      public Date getDate(String privateCreator, int tag, VR vr, int valueIndex, DatePrecision precision)
    • getDate

      public Date getDate(String privateCreator, int tag, VR vr, int valueIndex, Date defVal)
    • getDate

      public Date getDate(String privateCreator, int tag, VR vr, int valueIndex, Date defVal, DatePrecision precision)
    • getDate

      public Date getDate(long tag)
    • getDate

      public Date getDate(long tag, DatePrecision precision)
    • getDate

      public Date getDate(long tag, Date defVal)
    • getDate

      public Date getDate(long tag, Date defVal, DatePrecision precision)
    • getDate

      public Date getDate(String privateCreator, long tag)
    • getDate

      public Date getDate(String privateCreator, long tag, DatePrecision precision)
    • getDate

      public Date getDate(String privateCreator, long tag, Date defVal)
    • getDate

      public Date getDate(String privateCreator, long tag, Date defVal, DatePrecision precision)
    • getDates

      public Date[] getDates(int tag)
    • getDates

      public Date[] getDates(int tag, DatePrecision precisions)
    • getDates

      public Date[] getDates(String privateCreator, int tag)
    • getDates

      public Date[] getDates(String privateCreator, int tag, DatePrecision precisions)
    • getDates

      public Date[] getDates(String privateCreator, int tag, VR vr)
    • getDates

      public Date[] getDates(String privateCreator, int tag, VR vr, DatePrecision precisions)
    • getDates

      public Date[] getDates(long tag)
    • getDates

      public Date[] getDates(long tag, DatePrecision precisions)
    • getDates

      public Date[] getDates(String privateCreator, long tag)
    • getDates

      public Date[] getDates(String privateCreator, long tag, DatePrecision precisions)
    • getDateRange

      public DateRange getDateRange(int tag)
    • getDateRange

      public DateRange getDateRange(int tag, DateRange defVal)
    • getDateRange

      public DateRange getDateRange(String privateCreator, int tag)
    • getDateRange

      public DateRange getDateRange(String privateCreator, int tag, DateRange defVal)
    • getDateRange

      public DateRange getDateRange(String privateCreator, int tag, VR vr)
    • getDateRange

      public DateRange getDateRange(String privateCreator, int tag, VR vr, DateRange defVal)
    • getDateRange

      public DateRange getDateRange(long tag)
    • getDateRange

      public DateRange getDateRange(long tag, DateRange defVal)
    • getDateRange

      public DateRange getDateRange(String privateCreator, long tag)
    • getDateRange

      public DateRange getDateRange(String privateCreator, long tag, DateRange defVal)
    • getSpecificCharacterSet

      public SpecificCharacterSet getSpecificCharacterSet()
    • setSpecificCharacterSet

      public void setSpecificCharacterSet(String... codes)
      Set Specific Character Set (0008,0005) to specified internal(s) and re-encode contained LO, LT, PN, SH, ST, UT attributes accordingly.
      Parameters:
      codes - new value(s) of Specific Character Set (0008,0005)
    • getDefaultTimeZone

      public TimeZone getDefaultTimeZone()
    • setDefaultTimeZone

      public void setDefaultTimeZone(TimeZone tz)
    • getTimeZone

      public TimeZone getTimeZone()
    • setTimezoneOffsetFromUTC

      public void setTimezoneOffsetFromUTC(String utcOffset)
      Set Timezone Offset From UTC (0008,0201) to specified value and adjust contained DA, DT and TM attributs accordingly
      Parameters:
      utcOffset - offset from UTC as (+|-)HHMM
    • setTimezone

      public void setTimezone(TimeZone tz)
      Set the Default Time Zone to specified value and adjust contained DA, DT and TM attributs accordingly. If the Time Zone does not use Daylight Saving Time, attribute Timezone Offset From UTC (0008,0201) will be also set accordingly. If the Time zone uses Daylight Saving Time, a previous existing attribute Timezone Offset From UTC (0008,0201) will be removed.
      Parameters:
      tz - Time Zone
      See Also:
    • getPrivateCreator

      public String getPrivateCreator(int tag)
    • remove

      public Object remove(int tag)
    • remove

      public Object remove(String privateCreator, int tag)
    • setNull

      public Object setNull(int tag, VR vr)
    • setNull

      public Object setNull(String privateCreator, int tag, VR vr)
    • setBytes

      public Object setBytes(int tag, VR vr, byte[] b)
    • setBytes

      public Object setBytes(String privateCreator, int tag, VR vr, byte[] b)
    • setString

      public Object setString(int tag, VR vr, String s)
    • setString

      public Object setString(String privateCreator, int tag, VR vr, String s)
    • setString

      public Object setString(int tag, VR vr, String... ss)
    • setString

      public Object setString(String privateCreator, int tag, VR vr, String... ss)
    • setInt

      public Object setInt(int tag, VR vr, int... is)
    • setInt

      public Object setInt(String privateCreator, int tag, VR vr, int... is)
    • setFloat

      public Object setFloat(int tag, VR vr, float... fs)
    • setFloat

      public Object setFloat(String privateCreator, int tag, VR vr, float... fs)
    • setDouble

      public Object setDouble(int tag, VR vr, double... ds)
    • setDouble

      public Object setDouble(String privateCreator, int tag, VR vr, double... ds)
    • setDate

      public Object setDate(int tag, VR vr, Date... ds)
    • setDate

      public Object setDate(int tag, VR vr, DatePrecision precision, Date... ds)
    • setDate

      public Object setDate(String privateCreator, int tag, VR vr, Date... ds)
    • setDate

      public Object setDate(String privateCreator, int tag, VR vr, DatePrecision precision, Date... ds)
    • setDate

      public void setDate(long tag, Date dt)
    • setDate

      public void setDate(long tag, DatePrecision precision, Date dt)
    • setDate

      public void setDate(String privateCreator, long tag, Date dt)
    • setDate

      public void setDate(String privateCreator, long tag, DatePrecision precision, Date dt)
    • setDateRange

      public Object setDateRange(int tag, VR vr, DateRange range)
    • setDateRange

      public Object setDateRange(int tag, VR vr, DatePrecision precision, DateRange range)
    • setDateRange

      public Object setDateRange(String privateCreator, int tag, VR vr, DateRange range)
    • setDateRange

      public Object setDateRange(String privateCreator, int tag, VR vr, DatePrecision precision, DateRange range)
    • setDateRange

      public void setDateRange(long tag, DateRange dr)
    • setDateRange

      public void setDateRange(String privateCreator, long tag, DateRange range)
    • setValue

      public Object setValue(int tag, VR vr, Object value)
    • setValue

      public Object setValue(String privateCreator, int tag, VR vr, Object value)
    • newSequence

      public Sequence newSequence(int tag, int initialCapacity)
    • newSequence

      public Sequence newSequence(String privateCreator, int tag, int initialCapacity)
    • ensureSequence

      public Sequence ensureSequence(int tag, int initialCapacity)
    • ensureSequence

      public Sequence ensureSequence(String privateCreator, int tag, int initialCapacity)
    • newFragments

      public Fragments newFragments(int tag, VR vr, int initialCapacity)
    • newFragments

      public Fragments newFragments(String privateCreator, int tag, VR vr, int initialCapacity)
    • addAll

      public boolean addAll(Attributes other)
    • addAll

      public boolean addAll(Attributes other, boolean mergeOriginalAttributesSequence)
    • addSelected

      public boolean addSelected(Attributes other, Attributes selection)
    • addSelected

      public boolean addSelected(Attributes other, String privateCreator, int tag)
    • addSelected

      public boolean addSelected(Attributes other, int... selection)
      Add selected attributes from another Attributes object to this. The specified array of tag values must be sorted (as by the Arrays.sort(int[]) method) prior to making this call.
      Parameters:
      other - the other Attributes object
      selection - sorted tag values
      Returns:
      true if one ore more attributes were added
    • addSelected

      public boolean addSelected(Attributes other, int[] selection, int fromIndex, int toIndex)
      Add selected attributes from another Attributes object to this. The specified array of tag values must be sorted (as by the Arrays.sort(int[], int, int) method) prior to making this call.
      Parameters:
      other - the other Attributes object
      selection - sorted tag values
      fromIndex - the index of the first tag (inclusive)
      toIndex - the index of the last tag (exclusive)
      Returns:
      true if one ore more attributes were added
    • addNotSelected

      public boolean addNotSelected(Attributes other, int... selection)
      Add not selected attributes from another Attributes object to this. The specified array of tag values must be sorted (as by the Arrays.sort(int[]) method) prior to making this call.
      Parameters:
      other - the other Attributes object
      selection - sorted tag values
      Returns:
      true if one ore more attributes were added
    • addNotSelected

      public boolean addNotSelected(Attributes other, int[] selection, int fromIndex, int toIndex)
      Add not selected attributes from another Attributes object to this. The specified array of tag values must be sorted (as by the Arrays.sort(int[]) method) prior to making this call.
      Parameters:
      other - the other Attributes object
      selection - sorted tag values
      fromIndex - the index of the first tag (inclusive)
      toIndex - the index of the last tag (exclusive)
      Returns:
      true if one ore more attributes were added
    • update

      public boolean update(Attributes.UpdatePolicy updatePolicy, Attributes newAttrs, Attributes modified)
    • update

      public boolean update(Attributes.UpdatePolicy updatePolicy, boolean mergeOriginalAttributesSequence, Attributes newAttrs, Attributes modified)
    • testUpdate

      public boolean testUpdate(Attributes.UpdatePolicy updatePolicy, Attributes newAttrs, Attributes modified)
    • updateSelected

      public boolean updateSelected(Attributes.UpdatePolicy updatePolicy, Attributes newAttrs, Attributes modified, int... selection)
      Add selected attributes from another Attributes object to this. Optionally, the original values of overwritten existing non-empty attributes are preserved in another Attributes object.
      Parameters:
      updatePolicy - the policy
      newAttrs - the other Attributes object
      modified - Attributes object to collect overwritten non-empty attributes with original values or null
      selection - sorted tag values
      Returns:
      true f one ore more attribute were added or overwritten with a different value
    • testUpdateSelected

      public boolean testUpdateSelected(Attributes.UpdatePolicy updatePolicy, Attributes newAttrs, Attributes modified, int... selection)
      Parameters:
      updatePolicy - the policy
      newAttrs - the other Attributes object
      modified - Attributes object to collect overwritten non-empty attributes with original values or true
      selection - sorted tag values
      Returns:
      true if one ore more attribute would be added or overwritten with a different value
    • updateNotSelected

      public boolean updateNotSelected(Attributes.UpdatePolicy updatePolicy, Attributes newAttrs, Attributes modified, int... selection)
      Add not selected attributes from another Attributes object to this. Optionally, the original values of overwritten existing non-empty attributes are preserved in another Attributes object. The specified array of tag values must be sorted (as by the Arrays.sort(int[]) method) prior to making this call.
      Parameters:
      updatePolicy - the policy
      newAttrs - the other Attributes object
      modified - Attributes object to collect overwritten non-empty attributes with original values or null
      selection - sorted tag values
      Returns:
      true if one ore more attribute were added or overwritten with a different value
    • testUpdateNotSelected

      public boolean testUpdateNotSelected(Attributes.UpdatePolicy updatePolicy, Attributes newAttrs, Attributes modified, int... selection)
      Parameters:
      updatePolicy - the policy
      newAttrs - the other Attributes object
      modified - Attributes object to collect overwritten non-empty attributes with original values or true
      selection - sorted tag values
      Returns:
      true if one ore more attribute would be added or overwritten with a different value
    • addOriginalAttributes

      public Attributes addOriginalAttributes(String sourceOfPreviousValues, Date modificationDateTime, String reasonForModification, String modifyingSystem, Attributes originalAttributes)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • equalValues

      public boolean equalValues(Attributes other, int tag)
    • equalValues

      public boolean equalValues(Attributes other, String privateCreator, int tag)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toString

      public String toString(int limit, int maxWidth)
    • toStringBuilder

      public StringBuilder toStringBuilder(StringBuilder sb)
    • toStringBuilder

      public StringBuilder toStringBuilder(int limit, int maxWidth, StringBuilder sb)
    • calcLength

      public int calcLength(ImageEncodingOptions encOpts, boolean explicitVR)
    • writeTo

      public void writeTo(ImageOutputStream out) throws IOException
      Throws:
      IOException
    • writeItemTo

      public void writeItemTo(ImageOutputStream out) throws IOException
      Throws:
      IOException
    • accept

      public boolean accept(Attributes.Visitor visitor, boolean visitNestedDatasets) throws Exception
      Invokes Attributes.Visitor.visit(org.aoju.bus.image.galaxy.data.Attributes, int, org.aoju.bus.image.galaxy.data.VR, java.lang.Object) for each attribute in this instance. The operation will be aborted if visitor.visit returns false .
      Parameters:
      visitor - the Visitor
      visitNestedDatasets - controls if visitor.visit is also invoked for attributes in nested datasets
      Returns:
      true if the operation was not aborted.
      Throws:
      Exception - exception
    • writeGroupTo

      public void writeGroupTo(ImageOutputStream out, int groupLengthTag) throws IOException
      Throws:
      IOException
    • createFileMetaInformation

      public Attributes createFileMetaInformation(String tsuid)
    • matches

      public boolean matches(Attributes keys, boolean ignorePNCase, boolean matchNoValue)
    • validate

      public ValidationResult validate(IOD iod)
    • validate

      public void validate(IOD.DataElement el, ValidationResult result)
    • getModified

      public Attributes getModified(Attributes other, Attributes result)
      Add attributes of this data set which were replaced in the specified other data set into the result data set. If no result data set is passed, a new result set will be instantiated.
      Parameters:
      other - data set
      result - data set or null
      Returns:
      result data set.
    • getRemovedOrModified

      public Attributes getRemovedOrModified(Attributes other)
      Returns attributes of this data set which were removed or replaced in the specified other data set.
      Parameters:
      other - data set
      Returns:
      attributes of this data set which were removed or replaced in the specified other data set.
    • diff

      public int diff(Attributes other, int[] selection, Attributes diff)
    • diff

      public int diff(Attributes other, int[] selection, Attributes diff, boolean onlyModified)
    • removeAllBulkData

      public int removeAllBulkData()
    • removePrivateAttributes

      public int removePrivateAttributes(String privateCreator, int groupNumber)
    • removePrivateAttributes

      public int removePrivateAttributes()
    • removeSelected

      public void removeSelected(int... selection)
    • replaceSelected

      public void replaceSelected(Attributes others, int... selection)
    • replaceUIDSelected

      public void replaceUIDSelected(int... selection)
    • removeCurveData

      public int removeCurveData()
    • removeOverlayData

      public int removeOverlayData()