Class AttributeFactory

java.lang.Object
com.pixelmed.dicom.AttributeFactory

public class AttributeFactory extends Object

The AttributeFactory class is a factory class of static methods for creating concrete instances of the abstract class Attribute based on their value representation.

This class is primarily used when reading a parsing a DICOM dataset, and needing to create attributes based on their value representation, either from a dictionary or from the explicit value representation in the dataset.

See Also:
  • Method Details

    • getClassOfAttributeFromValueRepresentation

      public static Class getClassOfAttributeFromValueRepresentation(AttributeTag tag, byte[] vr, boolean explicit, int bytesPerSample, boolean leaveOtherDataOnDisk, boolean isSignedPixelRepresentation)

      A static method to determine the Class appropriate for storing an attribute based on the supplied value representation.

      Parameters:
      tag - the AttributeTag tag of the attribute (to check whether or not pixel data)
      vr - the value representation of the attribute
      explicit - a flag indicating that the stream to read or write uses explicit value representation (affects pixel data encoding choice)
      bytesPerSample - 1 or 2 bytes per sample indicating whether to use OB or OW for pixel data
      leaveOtherDataOnDisk - whether or not to leave OB or OW on disk or read it into memory
      isSignedPixelRepresentation - the PixelRepresentation is signed (needed to choose VR for US/SS VR data elements)
      Returns:
      the class appropriate for the attribute
    • getClassOfAttributeFromValueRepresentation

      public static Class getClassOfAttributeFromValueRepresentation(AttributeTag tag, byte[] vr, boolean explicit, int bytesPerSample, long vl, boolean isFile, boolean isSignedPixelRepresentation)

      A static method to determine the Class appropriate for storing an attribute based on the supplied value representation.

      Parameters:
      tag - the AttributeTag tag of the attribute (to check whether or not pixel data)
      vr - the value representation of the attribute
      explicit - a flag indicating that the stream to read or write uses explicit value representation (affects pixel data encoding choice)
      bytesPerSample - 1 or 2 bytes per sample indicating whether to use OB or OW for pixel data
      vl - the value length, used to decide whether or not to leave OB or OW on disk (if in a file) or read it into memory
      isFile - the attribute is stored in a file
      isSignedPixelRepresentation - the PixelRepresentation is signed (needed to choose VR for US/SS VR data elements)
      Returns:
      the class appropriate for the attribute
    • newAttribute

      public static Attribute newAttribute(AttributeTag tag) throws DicomException

      A static method to create an Attribute based on the value representation from the standard dictionary.

      Will return a UN attribute if the tag is unrecognized.

      The PixelRepresentation is assumed to be unsigned (US will be used for US/SS VR data elements).

      Parameters:
      tag - the AttributeTag tag of the attribute to create
      Returns:
      the attribute of an appropriate class, with no value
      Throws:
      DicomException - if cannot instantiate a new attribute
    • newAttribute

      public static Attribute newAttribute(AttributeTag tag, byte[] vr) throws DicomException

      A static method to create an Attribute based on the supplied value representation.

      The PixelRepresentation is assumed to be unsigned (US will be used for US/SS VR data elements if the supplied VR from the dictionary is 'XS').

      Parameters:
      tag - the AttributeTag tag of the attribute to create
      vr - the value representation of the attribute to create (such as read from the stream, or from the dictionary)
      Returns:
      the attribute of an appropriate class, with no value
      Throws:
      DicomException - if cannot instantiate a new attribute
    • newAttribute

      public static Attribute newAttribute(AttributeTag tag, byte[] vr, SpecificCharacterSet specificCharacterSet) throws DicomException

      A static method to create an Attribute based on the supplied value representation.

      The PixelRepresentation is assumed to be unsigned (US will be used for US/SS VR data elements if the supplied VR from the dictionary is 'XS').

      Parameters:
      tag - the AttributeTag tag of the attribute to create
      vr - the value representation of the attribute to create (such as read from the stream, or from the dictionary)
      specificCharacterSet - the SpecificCharacterSet to be used text values
      Returns:
      the attribute of an appropriate class, with no value
      Throws:
      DicomException - if cannot instantiate a new attribute
    • newAttribute

      public static Attribute newAttribute(AttributeTag tag, byte[] vr, boolean explicit, int bytesPerSample) throws DicomException

      A static method to create an Attribute based on the supplied value representation.

      The PixelRepresentation is assumed to be unsigned (US will be used for US/SS VR data elements if the supplied VR from the dictionary is 'XS').

      Parameters:
      tag - the AttributeTag tag of the attribute to create
      vr - the value representation of the attribute to create (such as read from the stream, or from the dictionary)
      explicit - a flag indicating that the stream is explicit value representation (affects pixel data encoding choice)
      bytesPerSample - 1 or 2 bytes per sample indicating whether to use OB or OW for pixel data
      Returns:
      the attribute of an appropriate class, with no value
      Throws:
      DicomException - if cannot instantiate a new attribute
    • newAttribute

      public static Attribute newAttribute(AttributeTag tag, byte[] vr, SpecificCharacterSet specificCharacterSet, boolean explicit, int bytesPerSample, boolean isSignedPixelRepresentation) throws DicomException

      A static method to create an Attribute based on the supplied value representation.

      Parameters:
      tag - the AttributeTag tag of the attribute to create
      vr - the value representation of the attribute to create (such as read from the stream, or from the dictionary)
      specificCharacterSet - the SpecificCharacterSet to be used text values
      explicit - a flag indicating that the stream is explicit value representation (affects pixel data encoding choice)
      bytesPerSample - 1 or 2 bytes per sample indicating whether to use OB or OW for pixel data
      isSignedPixelRepresentation - the PixelRepresentation is signed (needed to choose VR for US/SS VR data elements)
      Returns:
      the attribute of an appropriate class, with no value
      Throws:
      DicomException - if cannot instantiate a new attribute
    • newAttribute

      public static Attribute newAttribute(AttributeTag tag, byte[] vr, SpecificCharacterSet specificCharacterSet, boolean explicit, int bytesPerSample) throws DicomException

      A static method to create an Attribute based on the supplied value representation.

      The PixelRepresentation is assumed to be unsigned (US will be used for US/SS VR data elements).

      Parameters:
      tag - the AttributeTag tag of the attribute to create
      vr - the value representation of the attribute to create (such as read from the stream, or from the dictionary)
      specificCharacterSet - the SpecificCharacterSet to be used text values
      explicit - a flag indicating that the stream is explicit value representation (affects pixel data encoding choice)
      bytesPerSample - 1 or 2 bytes per sample indicating whether to use OB or OW for pixel data
      Returns:
      the attribute of an appropriate class, with no value
      Throws:
      DicomException - if cannot instantiate a new attribute
    • newAttribute

      public static Attribute newAttribute(AttributeTag tag, byte[] vr, long vl, DicomInputStream i, SpecificCharacterSet specificCharacterSet, boolean explicit, int bytesPerSample, long byteOffset, boolean isSignedPixelRepresentation) throws DicomException

      A static method to create and read an Attribute from a DicomInputStream.

      The stream is left positioned at the start of the next attribute.

      Parameters:
      tag - the AttributeTag tag of the attribute to create (already read from the stream)
      vr - the value representation of the attribute to create (already read from the stream, if present, else from the dictionary)
      vl - the value length of the attribute to create (already read from the stream)
      i - the DicomInputStream to read the attribute from, positioned at the start of the value(s) to read
      specificCharacterSet - the SpecificCharacterSet to be used text values
      explicit - a flag indicating that the stream is explicit value representation (affects pixel data encoding choice)
      bytesPerSample - 1 or 2 bytes per sample indicating whether to use OB or OW for pixel data
      byteOffset - the byte offset from the beginning of the DicomInputStream
      isSignedPixelRepresentation - the PixelRepresentation is signed (needed to choose VR for US/SS VR data elements)
      Returns:
      the attribute of an appropriate class populated with the value(s) read from the stream
      Throws:
      DicomException - if cannot instantiate a new attribute
    • newAttribute

      public static Attribute newAttribute(AttributeTag tag, byte[] vr, long vl, DicomInputStream i, SpecificCharacterSet specificCharacterSet, boolean explicit, int bytesPerSample, long byteOffset) throws DicomException

      A static method to create and read an Attribute from a DicomInputStream.

      The stream is left positioned at the start of the next attribute.

      The PixelRepresentation is assumed to be unsigned (US will be used for US/SS VR data elements).

      Parameters:
      tag - the AttributeTag tag of the attribute to create (already read from the stream)
      vr - the value representation of the attribute to create (already read from the stream, if present, else from the dictionary)
      vl - the value length of the attribute to create (already read from the stream)
      i - the DicomInputStream to read the attribute from, positioned at the start of the value(s) to read
      specificCharacterSet - the SpecificCharacterSet to be used text values
      explicit - a flag indicating that the stream is explicit value representation (affects pixel data encoding choice)
      bytesPerSample - 1 or 2 bytes per sample indicating whether to use OB or OW for pixel data
      byteOffset - the byte offset from the beginning of the DicomInputStream
      Returns:
      the attribute of an appropriate class populated with the value(s) read from the stream
      Throws:
      DicomException - if cannot instantiate a new attribute