public abstract class Attribute
extends java.lang.Object
The Attribute
class is an abstract class that contains the core
functionality for storing, accessing and maintaining values of a DICOM Attribute.
Though instances of concrete sub-classes of this abstract class may be created
using their constructors, there is also a factory class, AttributeFactory
.
AttributeFactory
,
AttributeList
Modifier and Type | Field and Description |
---|---|
protected long |
valueLength |
protected int |
valueMultiplicity |
Modifier | Constructor and Description |
---|---|
protected |
Attribute(AttributeTag t)
Construct an (empty) attribute; called only by concrete sub-classes.
|
Modifier and Type | Method and Description |
---|---|
void |
addValue(byte v)
Add a(nother) byte value after any existing values of this attribute.
|
void |
addValue(double v)
Add a(nother) double value after any existing values of this attribute.
|
void |
addValue(float v)
Add a(nother) float value after any existing values of this attribute.
|
void |
addValue(int v)
Add a(nother) int value after any existing values of this attribute.
|
void |
addValue(long v)
Add a(nother) long value after any existing values of this attribute.
|
void |
addValue(short v)
Add a(nother) short value after any existing values of this attribute.
|
void |
addValue(java.lang.String v)
Add a(nother)
String value after any existing values of this attribute. |
byte[] |
getByteValues()
Get the values of this attribute as a byte array, if the values are byte order insensitive.
|
byte[] |
getByteValues(boolean big)
Get the values of this attribute as a byte array, accounting for byte ordering of values that are larger than one byte.
|
static java.lang.String |
getDelimitedStringValuesOrDefault(AttributeList list,
AttributeTag tag,
java.lang.String dflt)
Get all the string values for a named attribute in an attribute list, separated by the appropriate delimiter.
|
static java.lang.String |
getDelimitedStringValuesOrDefault(AttributeList list,
AttributeTag tag,
java.lang.String dflt,
java.text.NumberFormat format)
Get all the string values for a named attribute in an attribute list, separated by the appropriate delimiter.
|
static java.lang.String |
getDelimitedStringValuesOrDefault(Attribute a,
java.lang.String dflt)
Get all the string values for a supplied attribute that may be null, separated by the appropriate delimiter.
|
static java.lang.String |
getDelimitedStringValuesOrDefault(Attribute a,
java.lang.String dflt,
java.text.NumberFormat format)
Get all the string values for a supplied attribute that may be null, separated by the appropriate delimiter.
|
java.lang.String |
getDelimitedStringValuesOrDefault(java.lang.String dflt)
Get all the string values for the attribute, separated by the appropriate delimiter.
|
java.lang.String |
getDelimitedStringValuesOrDefault(java.lang.String dflt,
java.text.NumberFormat format)
Get all the string values for the attribute, separated by the appropriate delimiter.
|
java.lang.String |
getDelimitedStringValuesOrEmptyString()
Get all the string values for the attribute, separated by the appropriate delimiter.
|
static java.lang.String |
getDelimitedStringValuesOrEmptyString(Attribute a)
Get all the string values for a supplied attribute that may be null, separated by the appropriate delimiter.
|
static java.lang.String |
getDelimitedStringValuesOrEmptyString(AttributeList list,
AttributeTag tag)
Get all the string values for a named attribute in an attribute list, separated by the appropriate delimiter.
|
static java.lang.String |
getDelimitedStringValuesOrEmptyString(AttributeList list,
AttributeTag tag,
java.text.NumberFormat format)
Get all the string values for a named attribute in an attribute list, separated by the appropriate delimiter.
|
static java.lang.String |
getDelimitedStringValuesOrEmptyString(Attribute a,
java.text.NumberFormat format)
Get all the string values for a supplied attribute that may be null, separated by the appropriate delimiter.
|
java.lang.String |
getDelimitedStringValuesOrEmptyString(java.text.NumberFormat format)
Get all the string values for the attribute, separated by the appropriate delimiter.
|
java.lang.String |
getDelimitedStringValuesOrNull()
Get all the string values for the attribute, separated by the appropriate delimiter.
|
static java.lang.String |
getDelimitedStringValuesOrNull(Attribute a)
Get all the string values for a supplied attribute that may be null, separated by the appropriate delimiter.
|
static java.lang.String |
getDelimitedStringValuesOrNull(AttributeList list,
AttributeTag tag)
Get all the string values for a named attribute in an attribute list, separated by the appropriate delimiter.
|
static java.lang.String |
getDelimitedStringValuesOrNull(AttributeList list,
AttributeTag tag,
java.text.NumberFormat format)
Get all the string values for a named attribute in an attribute list, separated by the appropriate delimiter.
|
static java.lang.String |
getDelimitedStringValuesOrNull(Attribute a,
java.text.NumberFormat format)
Get all the string values for a supplied attribute that may be null, separated by the appropriate delimiter.
|
java.lang.String |
getDelimitedStringValuesOrNull(java.text.NumberFormat format)
Get all the string values for the attribute, separated by the appropriate delimiter.
|
double[] |
getDoubleValues()
Get the values of this attribute as a double array.
|
static double[] |
getDoubleValues(Attribute a)
Get the values of a supplied attribute that may be null, as an array of double.
|
static double[] |
getDoubleValues(AttributeList list,
AttributeTag tag)
Get the values of a named attribute in an attribute list, as an array of double.
|
int |
getElement()
Get the element of the tag of this attribute.
|
float[] |
getFloatValues()
Get the values of this attribute as a float array.
|
static float[] |
getFloatValues(Attribute a)
Get the values of a supplied attribute that may be null, as an array of float.
|
static float[] |
getFloatValues(AttributeList list,
AttributeTag tag)
Get the values of a named attribute in an attribute list, as an array of float.
|
int |
getGroup()
Get the group of the tag of this attribute.
|
int[] |
getIntegerValues()
Get the values of this attribute as an int array.
|
static int[] |
getIntegerValues(Attribute a)
Get the values of a supplied attribute that may be null, as an array of int.
|
static int[] |
getIntegerValues(AttributeList list,
AttributeTag tag)
Get the values of a named attribute in an attribute list, as an array of int.
|
long |
getLengthOfEncodedValue()
Get the number of bytes encoded for the value of this attribute.
|
long[] |
getLongValues()
Get the values of this attribute as a long array.
|
static long[] |
getLongValues(Attribute a)
Get the values of a supplied attribute that may be null, as an array of long.
|
static long[] |
getLongValues(AttributeList list,
AttributeTag tag)
Get the values of a named attribute in an attribute list, as an array of long.
|
java.lang.String[] |
getOriginalStringValues()
Get the values of this attribute as strings, the way they were originally inserted or read.
|
long |
getPaddedVL()
Get the value length of this attribute, accounting for the need for even-length padding.
|
short[] |
getShortValues()
Get the values of this attribute as a short array.
|
static double |
getSingleDoubleValueOrDefault(Attribute a,
double dflt)
Get a single double value of a supplied attribute that may be null.
|
static double |
getSingleDoubleValueOrDefault(AttributeList list,
AttributeTag tag,
double dflt)
Get a single double value of a named attribute in an attribute list.
|
double |
getSingleDoubleValueOrDefault(double dflt)
Get a single double value for the attribute.
|
static float |
getSingleFloatValueOrDefault(Attribute a,
float dflt)
Get a single float value of a supplied attribute that may be null.
|
static float |
getSingleFloatValueOrDefault(AttributeList list,
AttributeTag tag,
float dflt)
Get a single float value of a named attribute in an attribute list.
|
float |
getSingleFloatValueOrDefault(float dflt)
Get a single float value for the attribute.
|
static int |
getSingleIntegerValueOrDefault(Attribute a,
int dflt)
Get a single int value of a supplied attribute that may be null.
|
static int |
getSingleIntegerValueOrDefault(AttributeList list,
AttributeTag tag,
int dflt)
Get a single int value of a named attribute in an attribute list.
|
int |
getSingleIntegerValueOrDefault(int dflt)
Get a single int value for the attribute.
|
static long |
getSingleLongValueOrDefault(AttributeList list,
AttributeTag tag,
long dflt)
Get a single long value of a named attribute in an attribute list.
|
static long |
getSingleLongValueOrDefault(Attribute a,
long dflt)
Get a single long value of a supplied attribute that may be null.
|
long |
getSingleLongValueOrDefault(long dflt)
Get a single long value for the attribute.
|
static java.lang.String |
getSingleStringValueOrDefault(AttributeList list,
AttributeTag tag,
java.lang.String dflt)
Get a single string value for a named attribute in an attribute list.
|
static java.lang.String |
getSingleStringValueOrDefault(AttributeList list,
AttributeTag tag,
java.lang.String dflt,
java.text.NumberFormat format)
Get a single string value for a named attribute in an attribute list.
|
static java.lang.String |
getSingleStringValueOrDefault(Attribute a,
java.lang.String dflt)
Get a single string value for a supplied attribute that may be null.
|
static java.lang.String |
getSingleStringValueOrDefault(Attribute a,
java.lang.String dflt,
java.text.NumberFormat format)
Get a single string value for a supplied attribute that may be null.
|
java.lang.String |
getSingleStringValueOrDefault(java.lang.String dflt)
Get a single string value for the attribute.
|
java.lang.String |
getSingleStringValueOrDefault(java.lang.String dflt,
java.text.NumberFormat format)
Get a single string value for the attribute.
|
java.lang.String |
getSingleStringValueOrEmptyString()
Get a single string value for the attribute.
|
static java.lang.String |
getSingleStringValueOrEmptyString(Attribute a)
Get a single string value for a supplied attribute that may be null.
|
static java.lang.String |
getSingleStringValueOrEmptyString(AttributeList list,
AttributeTag tag)
Get a single string value for a named attribute in an attribute list.
|
static java.lang.String |
getSingleStringValueOrEmptyString(AttributeList list,
AttributeTag tag,
java.text.NumberFormat format)
Get a single string value for a named attribute in an attribute list.
|
static java.lang.String |
getSingleStringValueOrEmptyString(Attribute a,
java.text.NumberFormat format)
Get a single string value for a supplied attribute that may be null.
|
java.lang.String |
getSingleStringValueOrEmptyString(java.text.NumberFormat format)
Get a single string value for the attribute.
|
java.lang.String |
getSingleStringValueOrNull()
Get a single string value for the attribute.
|
static java.lang.String |
getSingleStringValueOrNull(Attribute a)
Get a single string value for a supplied attribute that may be null.
|
static java.lang.String |
getSingleStringValueOrNull(AttributeList list,
AttributeTag tag)
Get a single string value for a named attribute in an attribute list.
|
static java.lang.String |
getSingleStringValueOrNull(AttributeList list,
AttributeTag tag,
java.text.NumberFormat format)
Get a single string value for a named attribute in an attribute list.
|
static java.lang.String |
getSingleStringValueOrNull(Attribute a,
java.text.NumberFormat format)
Get a single string value for a supplied attribute that may be null.
|
java.lang.String |
getSingleStringValueOrNull(java.text.NumberFormat format)
Get a single string value for the attribute.
|
java.lang.String[] |
getStringValues()
Get the values of this attribute as strings.
|
static java.lang.String[] |
getStringValues(Attribute a)
Get the values of a supplied attribute that may be null, as an array of strings.
|
static java.lang.String[] |
getStringValues(AttributeList list,
AttributeTag tag)
Get the values of a named attribute in an attribute list, as an array of strings.
|
static java.lang.String[] |
getStringValues(AttributeList list,
AttributeTag tag,
java.text.NumberFormat format)
Get the values of a named attribute in an attribute list, as an array of strings.
|
static java.lang.String[] |
getStringValues(Attribute a,
java.text.NumberFormat format)
Get the values of a supplied attribute that may be null, as an array of strings.
|
java.lang.String[] |
getStringValues(java.text.NumberFormat format)
Get the values of this attribute as strings.
|
AttributeTag |
getTag()
Get the tag of this attribute.
|
long |
getVL()
Get the value length of this attribute.
|
int |
getVM()
Get the value multiplicity of this attribute.
|
byte[] |
getVR()
Get the value representation of this attribute.
|
java.lang.String |
getVRAsString()
Get the value representation of this attribute.
|
boolean |
isValid()
Do the values of this attribute comply with standard VR requirements?
E.g., Are only valid characters are present (for string and text attributes) and length is within limits?
|
abstract void |
removeValues()
Remove any existing values, making the attribute empty (zero length).
|
boolean |
repairValues()
Repair any existing values of this attribute to make them comply with standard VR requirements.
|
void |
setValue(byte v)
Set a single byte value after any existing values of this attribute.
|
void |
setValue(double v)
Set a single double value after any existing values of this attribute.
|
void |
setValue(float v)
Set a single float value after any existing values of this attribute.
|
void |
setValue(int v)
Set a single int value after any existing values of this attribute.
|
void |
setValue(long v)
Set a single long value after any existing values of this attribute.
|
void |
setValue(short v)
Set a single short value after any existing values of this attribute.
|
void |
setValue(java.lang.String v)
Set a single
String value after any existing values of this attribute. |
void |
setValues(byte[] v)
Replace any existing values with the supplied array of byte.
|
void |
setValues(byte[] v,
boolean big)
Replace any existing values with the supplied array of byte, accounting for byte ordering of values that are larger than one byte.
|
void |
setValues(double[] v)
Replace any existing values with the supplied array of double.
|
void |
setValues(float[] v)
Replace any existing values with the supplied array of float.
|
void |
setValues(int[] v)
Replace any existing values with the supplied array of int.
|
void |
setValues(long[] v)
Replace any existing values with the supplied array of long.
|
void |
setValues(short[] v)
Replace any existing values with the supplied array of short.
|
java.lang.String |
toString()
Dump the contents of the attribute as a human-readable string.
|
java.lang.String |
toString(DicomDictionary dictionary)
Dump the contents of the attribute as a human-readable string.
|
abstract void |
write(DicomOutputStream o)
Write the entire attribute (including values) to the output stream.
|
protected void |
writeBase(DicomOutputStream o)
Write the common preamble of an attribute to the output stream.
|
protected long valueLength
protected int valueMultiplicity
protected Attribute(AttributeTag t)
Construct an (empty) attribute; called only by concrete sub-classes.
t
- the tag of the attributepublic void addValue(byte v) throws DicomException
v
- value to addDicomException
- thrown if value of this type is not valid for this concrete attribute classpublic void addValue(double v) throws DicomException
v
- value to addDicomException
- thrown if value of this type is not valid for this concrete attribute classpublic void addValue(float v) throws DicomException
v
- value to addDicomException
- thrown if value of this type is not valid for this concrete attribute classpublic void addValue(int v) throws DicomException
v
- value to addDicomException
- thrown if value of this type is not valid for this concrete attribute classpublic void addValue(long v) throws DicomException
v
- value to addDicomException
- thrown if value of this type is not valid for this concrete attribute classpublic void addValue(short v) throws DicomException
v
- value to addDicomException
- thrown if value of this type is not valid for this concrete attribute classpublic void addValue(java.lang.String v) throws DicomException
String
value after any existing values of this attribute.v
- value to addDicomException
- thrown if value of this type is not valid for this concrete attribute classpublic byte[] getByteValues() throws DicomException
Get the values of this attribute as a byte array, if the values are byte order insensitive.
DicomException
- thrown if values are not available (such as not supported for this concrete attribute class)public byte[] getByteValues(boolean big) throws DicomException
Get the values of this attribute as a byte array, accounting for byte ordering of values that are larger than one byte.
big
- whether or not to intepret the values larger than bytes as big endian or notDicomException
- thrown if values are not available (such as not supported for this concrete attribute class)public static java.lang.String getDelimitedStringValuesOrDefault(AttributeList list, AttributeTag tag, java.lang.String dflt)
Get all the string values for a named attribute in an attribute list, separated by the appropriate delimiter.
If there is no such attribute, the supplied default is returned.
If there is no string value, the supplied default is returned.
If there is an exception trying to fetch the values, the supplied default is returned.
A canonicalized (unpadded) form is returned, not the original string.
list
- the list of attributes in which to look for the attributetag
- the tag of the attribute to finddflt
- what to return if there are no (valid) string valuesString
public static java.lang.String getDelimitedStringValuesOrDefault(AttributeList list, AttributeTag tag, java.lang.String dflt, java.text.NumberFormat format)
Get all the string values for a named attribute in an attribute list, separated by the appropriate delimiter.
If there is no such attribute, the supplied default is returned.
If there is no string value, the supplied default is returned.
If there is an exception trying to fetch the values, the supplied default is returned.
A canonicalized (unpadded) form is returned, not the original string.
list
- the list of attributes in which to look for the attributetag
- the tag of the attribute to finddflt
- what to return if there are no (valid) string valuesformat
- the format to use for each numerical or decimal valueString
public static java.lang.String getDelimitedStringValuesOrDefault(Attribute a, java.lang.String dflt)
Get all the string values for a supplied attribute that may be null, separated by the appropriate delimiter.
If there is no such attribute, the supplied default is returned.
If there is no string value, the supplied default is returned.
If there is an exception trying to fetch the values, the supplied default is returned.
A canonicalized (unpadded) form is returned, not the original string.
Sequences and nested sequence item lists are recursively included with appropriate delimiters.
a
- the attribute, which may be nulldflt
- what to return if there are no (valid) string valuesString
public static java.lang.String getDelimitedStringValuesOrDefault(Attribute a, java.lang.String dflt, java.text.NumberFormat format)
Get all the string values for a supplied attribute that may be null, separated by the appropriate delimiter.
If there is no such attribute, the supplied default is returned.
If there is no string value, the supplied default is returned.
If there is an exception trying to fetch the values, the supplied default is returned.
A canonicalized (unpadded) form is returned, not the original string.
a
- the attribute, which may be nulldflt
- what to return if there are no (valid) string valuesformat
- the format to use for each numerical or decimal valueString
public java.lang.String getDelimitedStringValuesOrDefault(java.lang.String dflt)
Get all the string values for the attribute, separated by the appropriate delimiter.
If there is no string value, the supplied default is returned.
If there is an exception trying to fetch the values, the supplied default is returned.
A canonicalized (unpadded) form is returned, not the original string.
Sequences and nested sequence item lists are recursively included with appropriate delimiters.
dflt
- what to return if there are no (valid) string valuesString
public java.lang.String getDelimitedStringValuesOrDefault(java.lang.String dflt, java.text.NumberFormat format)
Get all the string values for the attribute, separated by the appropriate delimiter.
If there is no string value, the supplied default is returned.
If there is an exception trying to fetch the values, the supplied default is returned.
A canonicalized (unpadded) form is returned, not the original string.
Sequences and nested sequence item lists are recursively included with appropriate delimiters.
dflt
- what to return if there are no (valid) string valuesformat
- the format to use for each numerical or decimal value (null if none)String
public java.lang.String getDelimitedStringValuesOrEmptyString()
Get all the string values for the attribute, separated by the appropriate delimiter.
If there is no string value, an empty string is returned.
If there is an exception trying to fetch the values, an empty string is returned.
A canonicalized (unpadded) form is returned, not the original string.
Sequences and nested sequence item lists are recursively included with appropriate delimiters.
String
public static java.lang.String getDelimitedStringValuesOrEmptyString(Attribute a)
Get all the string values for a supplied attribute that may be null, separated by the appropriate delimiter.
If there is no such attribute, an empty string is returned.
If there is no string value, an empty string is returned.
If there is an exception trying to fetch the values, an empty string is returned.
A canonicalized (unpadded) form is returned, not the original string.
a
- the attribute, which may be nullString
public static java.lang.String getDelimitedStringValuesOrEmptyString(AttributeList list, AttributeTag tag)
Get all the string values for a named attribute in an attribute list, separated by the appropriate delimiter.
If there is no such attribute, an empty string is returned.
If there is no string value, an empty string is returned.
If there is an exception trying to fetch the values, an empty string is returned.
A canonicalized (unpadded) form is returned, not the original string.
list
- the list of attributes in which to look for the attributetag
- the tag of the attribute to findString
public static java.lang.String getDelimitedStringValuesOrEmptyString(AttributeList list, AttributeTag tag, java.text.NumberFormat format)
Get all the string values for a named attribute in an attribute list, separated by the appropriate delimiter.
If there is no such attribute, an empty string is returned.
If there is no string value, an empty string is returned.
If there is an exception trying to fetch the values, an empty string is returned.
A canonicalized (unpadded) form is returned, not the original string.
list
- the list of attributes in which to look for the attributetag
- the tag of the attribute to findformat
- the format to use for each numerical or decimal valueString
public static java.lang.String getDelimitedStringValuesOrEmptyString(Attribute a, java.text.NumberFormat format)
Get all the string values for a supplied attribute that may be null, separated by the appropriate delimiter.
If there is no such attribute, an empty string is returned.
If there is no string value, an empty string is returned.
If there is an exception trying to fetch the values, an empty string is returned.
A canonicalized (unpadded) form is returned, not the original string.
a
- the attribute, which may be nullformat
- the format to use for each numerical or decimal valueString
public java.lang.String getDelimitedStringValuesOrEmptyString(java.text.NumberFormat format)
Get all the string values for the attribute, separated by the appropriate delimiter.
If there is no string value, an empty string is returned.
If there is an exception trying to fetch the values, an empty string is returned.
A canonicalized (unpadded) form is returned, not the original string.
Sequences and nested sequence item lists are recursively included with appropriate delimiters.
format
- the format to use for each numerical or decimal valueString
public java.lang.String getDelimitedStringValuesOrNull()
Get all the string values for the attribute, separated by the appropriate delimiter.
If there is no string value, null
is returned.
If there is an exception trying to fetch the values, null
is returned.
A canonicalized (unpadded) form is returned, not the original string.
Sequences and nested sequence item lists are recursively included with appropriate delimiters.
String
public static java.lang.String getDelimitedStringValuesOrNull(Attribute a)
Get all the string values for a supplied attribute that may be null, separated by the appropriate delimiter.
If there is no such attribute, null
is returned.
If there is no string value, null
is returned.
If there is an exception trying to fetch the values, null
is returned.
A canonicalized (unpadded) form is returned, not the original string.
a
- the attribute, which may be nullString
public static java.lang.String getDelimitedStringValuesOrNull(AttributeList list, AttributeTag tag)
Get all the string values for a named attribute in an attribute list, separated by the appropriate delimiter.
If there is no such attribute, null
is returned.
If there is no string value, null
is returned.
If there is an exception trying to fetch the values, null
is returned.
A canonicalized (unpadded) form is returned, not the original string.
list
- the list of attributes in which to look for the attributetag
- the tag of the attribute to findString
public static java.lang.String getDelimitedStringValuesOrNull(AttributeList list, AttributeTag tag, java.text.NumberFormat format)
Get all the string values for a named attribute in an attribute list, separated by the appropriate delimiter.
If there is no such attribute, null
is returned.
If there is no string value, null
is returned.
If there is an exception trying to fetch the values, null
is returned.
A canonicalized (unpadded) form is returned, not the original string.
list
- the list of attributes in which to look for the attributetag
- the tag of the attribute to findformat
- the format to use for each numerical or decimal valueString
public static java.lang.String getDelimitedStringValuesOrNull(Attribute a, java.text.NumberFormat format)
Get all the string values for a supplied attribute that may be null, separated by the appropriate delimiter.
If there is no such attribute, null
is returned.
If there is no string value, null
is returned.
If there is an exception trying to fetch the values, null
is returned.
A canonicalized (unpadded) form is returned, not the original string.
a
- the attribute, which may be nullformat
- the format to use for each numerical or decimal valueString
public java.lang.String getDelimitedStringValuesOrNull(java.text.NumberFormat format)
Get all the string values for the attribute, separated by the appropriate delimiter.
If there is no string value, null
is returned.
If there is an exception trying to fetch the values, null
is returned.
A canonicalized (unpadded) form is returned, not the original string.
Sequences and nested sequence item lists are recursively included with appropriate delimiters.
format
- the format to use for each numerical or decimal valueString
public double[] getDoubleValues() throws DicomException
Get the values of this attribute as a double array.
DicomException
- thrown if values are not available (such as not supported for this concrete attribute class)public static double[] getDoubleValues(Attribute a)
Get the values of a supplied attribute that may be null, as an array of double.
If there is no such attribute, null
is returned.
If there is an exception trying to fetch the values, null
is returned.
a
- the attribute, which may be nullpublic static double[] getDoubleValues(AttributeList list, AttributeTag tag)
Get the values of a named attribute in an attribute list, as an array of double.
If there is no such attribute, null
is returned.
If there is an exception trying to fetch the values, null
is returned.
list
- the list of attributes in which to look for the attributetag
- the tag of the attribute to findpublic int getElement()
Get the element of the tag of this attribute.
public float[] getFloatValues() throws DicomException
Get the values of this attribute as a float array.
DicomException
- thrown if values are not available (such as not supported for this concrete attribute class)public static float[] getFloatValues(Attribute a)
Get the values of a supplied attribute that may be null, as an array of float.
If there is no such attribute, null
is returned.
If there is an exception trying to fetch the values, null
is returned.
a
- the attribute, which may be nullpublic static float[] getFloatValues(AttributeList list, AttributeTag tag)
Get the values of a named attribute in an attribute list, as an array of float.
If there is no such attribute, null
is returned.
If there is an exception trying to fetch the values, null
is returned.
list
- the list of attributes in which to look for the attributetag
- the tag of the attribute to findpublic int getGroup()
Get the group of the tag of this attribute.
public int[] getIntegerValues() throws DicomException
Get the values of this attribute as an int array.
DicomException
- thrown if values are not available (such as not supported for this concrete attribute class)public static int[] getIntegerValues(Attribute a)
Get the values of a supplied attribute that may be null, as an array of int.
If there is no such attribute, null
is returned.
If there is an exception trying to fetch the values, null
is returned.
a
- the attribute, which may be nullpublic static int[] getIntegerValues(AttributeList list, AttributeTag tag)
Get the values of a named attribute in an attribute list, as an array of int.
If there is no such attribute, null
is returned.
If there is an exception trying to fetch the values, null
is returned.
list
- the list of attributes in which to look for the attributetag
- the tag of the attribute to findpublic long getLengthOfEncodedValue()
Get the number of bytes encoded for the value of this attribute.
Accounts for delimited Sequence and Encapsulated Pixel Data OB attributes.
public long[] getLongValues() throws DicomException
Get the values of this attribute as a long array.
DicomException
- thrown if values are not available (such as not supported for this concrete attribute class)public static long[] getLongValues(Attribute a)
Get the values of a supplied attribute that may be null, as an array of long.
If there is no such attribute, null
is returned.
If there is an exception trying to fetch the values, null
is returned.
a
- the attribute, which may be nullpublic static long[] getLongValues(AttributeList list, AttributeTag tag)
Get the values of a named attribute in an attribute list, as an array of long.
If there is no such attribute, null
is returned.
If there is an exception trying to fetch the values, null
is returned.
list
- the list of attributes in which to look for the attributetag
- the tag of the attribute to findpublic java.lang.String[] getOriginalStringValues() throws DicomException
Get the values of this attribute as strings, the way they were originally inserted or read.
String
DicomException
- thrown if values are not available (such as not supported for this concrete attribute class)public long getPaddedVL()
Get the value length of this attribute, accounting for the need for even-length padding.
public short[] getShortValues() throws DicomException
Get the values of this attribute as a short array.
DicomException
- thrown if values are not available (such as not supported for this concrete attribute class)public static double getSingleDoubleValueOrDefault(Attribute a, double dflt)
Get a single double value of a supplied attribute that may be null.
If there is more than one value, only the first is returned.
If there is no value, the supplied default is returned.
If there is an exception trying to fetch the value, the supplied default is returned.
a
- the attribute, which may be nulldflt
- what to return if there is no (valid) valuepublic static double getSingleDoubleValueOrDefault(AttributeList list, AttributeTag tag, double dflt)
Get a single double value of a named attribute in an attribute list.
If there is more than one value, only the first is returned.
If there is no value, the supplied default is returned.
If there is an exception trying to fetch the value, the supplied default is returned.
list
- the list of attributes in which to look for the attributetag
- the tag of the attribute to finddflt
- what to return if there is no (valid) valuepublic double getSingleDoubleValueOrDefault(double dflt)
Get a single double value for the attribute.
If there is more than one value, only the first is returned.
If there is no value, the supplied default is returned.
If there is an exception trying to fetch the value, the supplied default is returned.
dflt
- what to return if there is no (valid) valuepublic static float getSingleFloatValueOrDefault(Attribute a, float dflt)
Get a single float value of a supplied attribute that may be null.
If there is more than one value, only the first is returned.
If there is no value, the supplied default is returned.
If there is an exception trying to fetch the value, the supplied default is returned.
a
- the attribute, which may be nulldflt
- what to return if there is no (valid) valuepublic static float getSingleFloatValueOrDefault(AttributeList list, AttributeTag tag, float dflt)
Get a single float value of a named attribute in an attribute list.
If there is more than one value, only the first is returned.
If there is no value, the supplied default is returned.
If there is an exception trying to fetch the value, the supplied default is returned.
list
- the list of attributes in which to look for the attributetag
- the tag of the attribute to finddflt
- what to return if there is no (valid) valuepublic float getSingleFloatValueOrDefault(float dflt)
Get a single float value for the attribute.
If there is more than one value, only the first is returned.
If there is no value, the supplied default is returned.
If there is an exception trying to fetch the value, the supplied default is returned.
dflt
- what to return if there is no (valid) valuepublic static int getSingleIntegerValueOrDefault(Attribute a, int dflt)
Get a single int value of a supplied attribute that may be null.
If there is more than one value, only the first is returned.
If there is no value, the supplied default is returned.
If there is an exception trying to fetch the value, the supplied default is returned.
a
- the attribute, which may be nulldflt
- what to return if there is no (valid) valuepublic static int getSingleIntegerValueOrDefault(AttributeList list, AttributeTag tag, int dflt)
Get a single int value of a named attribute in an attribute list.
If there is more than one value, only the first is returned.
If there is no value, the supplied default is returned.
If there is an exception trying to fetch the value, the supplied default is returned.
list
- the list of attributes in which to look for the attributetag
- the tag of the attribute to finddflt
- what to return if there is no (valid) valuepublic int getSingleIntegerValueOrDefault(int dflt)
Get a single int value for the attribute.
If there is more than one value, only the first is returned.
If there is no value, the supplied default is returned.
If there is an exception trying to fetch the value, the supplied default is returned.
dflt
- what to return if there is no (valid) valuepublic static long getSingleLongValueOrDefault(AttributeList list, AttributeTag tag, long dflt)
Get a single long value of a named attribute in an attribute list.
If there is more than one value, only the first is returned.
If there is no value, the supplied default is returned.
If there is an exception trying to fetch the value, the supplied default is returned.
list
- the list of attributes in which to look for the attributetag
- the tag of the attribute to finddflt
- what to return if there is no (valid) valuepublic static long getSingleLongValueOrDefault(Attribute a, long dflt)
Get a single long value of a supplied attribute that may be null.
If there is more than one value, only the first is returned.
If there is no value, the supplied default is returned.
If there is an exception trying to fetch the value, the supplied default is returned.
a
- the attribute, which may be nulldflt
- what to return if there is no (valid) valuepublic long getSingleLongValueOrDefault(long dflt)
Get a single long value for the attribute.
If there is more than one value, only the first is returned.
If there is no value, the supplied default is returned.
If there is an exception trying to fetch the value, the supplied default is returned.
dflt
- what to return if there is no (valid) valuepublic static java.lang.String getSingleStringValueOrDefault(AttributeList list, AttributeTag tag, java.lang.String dflt)
Get a single string value for a named attribute in an attribute list.
If there is no such attribute, the supplied default is returned.
If there is more than one string value, only the first is returned.
If there is no string value, the supplied default is returned.
If there is an exception trying to fetch the value, the supplied default is returned.
A canonicalized (unpadded) form is returned, not the original string.
list
- the list of attributes in which to look for the attributetag
- the tag of the attribute to finddflt
- what to return if there is no (valid) string valueString
valuepublic static java.lang.String getSingleStringValueOrDefault(AttributeList list, AttributeTag tag, java.lang.String dflt, java.text.NumberFormat format)
Get a single string value for a named attribute in an attribute list.
If there is no such attribute, the supplied default is returned.
If there is more than one string value, only the first is returned.
If there is no string value, the supplied default is returned.
If there is an exception trying to fetch the value, the supplied default is returned.
A canonicalized (unpadded) form is returned, not the original string.
list
- the list of attributes in which to look for the attributetag
- the tag of the attribute to finddflt
- what to return if there is no (valid) string valueformat
- the format to use for each numerical or decimal valueString
valuepublic static java.lang.String getSingleStringValueOrDefault(Attribute a, java.lang.String dflt)
Get a single string value for a supplied attribute that may be null.
If there is no such attribute, the supplied default is returned.
If there is more than one string value, only the first is returned.
If there is no string value, the supplied default is returned.
If there is an exception trying to fetch the value, the supplied default is returned.
A canonicalized (unpadded) form is returned, not the original string.
a
- the attribute, which may be nulldflt
- what to return if there is no (valid) string valueString
valuepublic static java.lang.String getSingleStringValueOrDefault(Attribute a, java.lang.String dflt, java.text.NumberFormat format)
Get a single string value for a supplied attribute that may be null.
If there is no such attribute, the supplied default is returned.
If there is more than one string value, only the first is returned.
If there is no string value, the supplied default is returned.
If there is an exception trying to fetch the value, the supplied default is returned.
A canonicalized (unpadded) form is returned, not the original string.
a
- the attribute, which may be nulldflt
- what to return if there is no (valid) string valueformat
- the format to use for each numerical or decimal valueString
valuepublic java.lang.String getSingleStringValueOrDefault(java.lang.String dflt)
Get a single string value for the attribute.
If there is more than one string value, only the first is returned.
If there is no string value, the supplied default is returned.
If there is an exception trying to fetch the value, the supplied default is returned.
A canonicalized (unpadded) form is returned, not the original string.
dflt
- what to return if there is no (valid) string valueString
valuepublic java.lang.String getSingleStringValueOrDefault(java.lang.String dflt, java.text.NumberFormat format)
Get a single string value for the attribute.
If there is more than one string value, only the first is returned.
If there is no string value, the supplied default is returned.
If there is an exception trying to fetch the value, the supplied default is returned.
A canonicalized (unpadded) form is returned, not the original string.
dflt
- what to return if there is no (valid) string valueformat
- the format to use for each numerical or decimal value (null if none)String
valuepublic java.lang.String getSingleStringValueOrEmptyString()
Get a single string value for the attribute.
If there is more than one string value, only the first is returned.
If there is no string value, an empty string is returned.
If there is an exception trying to fetch the value, an empty string is returned.
A canonicalized (unpadded) form is returned, not the original string.
String
valuepublic static java.lang.String getSingleStringValueOrEmptyString(Attribute a)
Get a single string value for a supplied attribute that may be null.
If there is no such attribute, an empty string is returned.
If there is more than one string value, only the first is returned.
If there is no string value, an empty string is returned.
If there is an exception trying to fetch the value, an empty string is returned.
A canonicalized (unpadded) form is returned, not the original string.
a
- the attribute, which may be nullString
valuepublic static java.lang.String getSingleStringValueOrEmptyString(AttributeList list, AttributeTag tag)
Get a single string value for a named attribute in an attribute list.
If there is no such attribute, an empty string is returned.
If there is more than one string value, only the first is returned.
If there is no string value, an empty string is returned.
If there is an exception trying to fetch the value, an empty string is returned.
A canonicalized (unpadded) form is returned, not the original string.
list
- the list of attributes in which to look for the attributetag
- the tag of the attribute to findString
valuepublic static java.lang.String getSingleStringValueOrEmptyString(AttributeList list, AttributeTag tag, java.text.NumberFormat format)
Get a single string value for a named attribute in an attribute list.
If there is no such attribute, an empty string is returned.
If there is more than one string value, only the first is returned.
If there is no string value, an empty string is returned.
If there is an exception trying to fetch the value, an empty string is returned.
A canonicalized (unpadded) form is returned, not the original string.
list
- the list of attributes in which to look for the attributetag
- the tag of the attribute to findformat
- the format to use for each numerical or decimal valueString
valuepublic static java.lang.String getSingleStringValueOrEmptyString(Attribute a, java.text.NumberFormat format)
Get a single string value for a supplied attribute that may be null.
If there is no such attribute, an empty string is returned.
If there is more than one string value, only the first is returned.
If there is no string value, an empty string is returned.
If there is an exception trying to fetch the value, an empty string is returned.
A canonicalized (unpadded) form is returned, not the original string.
a
- the attribute, which may be nullformat
- the format to use for each numerical or decimal valueString
valuepublic java.lang.String getSingleStringValueOrEmptyString(java.text.NumberFormat format)
Get a single string value for the attribute.
If there is more than one string value, only the first is returned.
If there is no string value, an empty string is returned.
If there is an exception trying to fetch the value, an empty string is returned.
A canonicalized (unpadded) form is returned, not the original string.
format
- the format to use for each numerical or decimal valueString
valuepublic java.lang.String getSingleStringValueOrNull()
Get a single string value for the attribute.
If there is more than one string value, only the first is returned.
If there is no string value, null
is returned.
If there is an exception trying to fetch the value, null
is returned.
A canonicalized (unpadded) form is returned, not the original string.
String
valuepublic static java.lang.String getSingleStringValueOrNull(Attribute a)
Get a single string value for a supplied attribute that may be null.
If there is no such attribute, null
is returned.
If there is more than one string value, only the first is returned.
If there is no string value, null
is returned.
If there is an exception trying to fetch the value, null
is returned.
A canonicalized (unpadded) form is returned, not the original string.
a
- the attribute, which may be nullString
valuepublic static java.lang.String getSingleStringValueOrNull(AttributeList list, AttributeTag tag)
Get a single string value for a named attribute in an attribute list.
If there is no such attribute, null
is returned.
If there is more than one string value, only the first is returned.
If there is no string value, null
is returned.
If there is an exception trying to fetch the value, null
is returned.
A canonicalized (unpadded) form is returned, not the original string.
list
- the list of attributes in which to look for the attributetag
- the tag of the attribute to findString
valuepublic static java.lang.String getSingleStringValueOrNull(AttributeList list, AttributeTag tag, java.text.NumberFormat format)
Get a single string value for a named attribute in an attribute list.
If there is no such attribute, null
is returned.
If there is more than one string value, only the first is returned.
If there is no string value, null
is returned.
If there is an exception trying to fetch the value, null
is returned.
A canonicalized (unpadded) form is returned, not the original string.
list
- the list of attributes in which to look for the attributetag
- the tag of the attribute to findformat
- the format to use for each numerical or decimal valueString
valuepublic static java.lang.String getSingleStringValueOrNull(Attribute a, java.text.NumberFormat format)
Get a single string value for a supplied attribute that may be null.
If there is no such attribute, null
is returned.
If there is more than one string value, only the first is returned.
If there is no string value, null
is returned.
If there is an exception trying to fetch the value, null
is returned.
A canonicalized (unpadded) form is returned, not the original string.
a
- the attribute, which may be nullformat
- the format to use for each numerical or decimal valueString
valuepublic java.lang.String getSingleStringValueOrNull(java.text.NumberFormat format)
Get a single string value for the attribute.
If there is more than one string value, only the first is returned.
If there is no string value, null
is returned.
If there is an exception trying to fetch the value, null
is returned.
A canonicalized (unpadded) form is returned, not the original string.
format
- the format to use for each numerical or decimal valueString
valuepublic java.lang.String[] getStringValues() throws DicomException
Get the values of this attribute as strings.
The strings may have been cleaned up into a canonical form, such as to remove padding.
String
DicomException
- thrown if values are not available (such as not supported for this concrete attribute class)public static java.lang.String[] getStringValues(Attribute a)
Get the values of a supplied attribute that may be null, as an array of strings.
If there is no such attribute, null
is returned.
If there is an exception trying to fetch the values, null
is returned.
The strings may have been cleaned up into a canonical form, such as to remove padding.
a
- the attribute, which may be nullString
public static java.lang.String[] getStringValues(AttributeList list, AttributeTag tag)
Get the values of a named attribute in an attribute list, as an array of strings.
If there is no such attribute, null
is returned.
If there is an exception trying to fetch the values, null
is returned.
The strings may have been cleaned up into a canonical form, such as to remove padding.
list
- the list of attributes in which to look for the attributetag
- the tag of the attribute to findString
public static java.lang.String[] getStringValues(AttributeList list, AttributeTag tag, java.text.NumberFormat format)
Get the values of a named attribute in an attribute list, as an array of strings.
If there is no such attribute, null
is returned.
If there is an exception trying to fetch the values, null
is returned.
The strings may have been cleaned up into a canonical form, such as to remove padding.
list
- the list of attributes in which to look for the attributetag
- the tag of the attribute to findformat
- the format to use for each numerical or decimal valueString
public static java.lang.String[] getStringValues(Attribute a, java.text.NumberFormat format)
Get the values of a supplied attribute that may be null, as an array of strings.
If there is no such attribute, null
is returned.
If there is an exception trying to fetch the values, null
is returned.
The strings may have been cleaned up into a canonical form, such as to remove padding.
a
- the attribute, which may be nullformat
- the format to use for each numerical or decimal valueString
public java.lang.String[] getStringValues(java.text.NumberFormat format) throws DicomException
Get the values of this attribute as strings.
The strings may have been cleaned up into a canonical form, such as to remove padding as well as numbers formatted.
format
- the format to use for each numerical or decimal valueString
DicomException
- thrown if values are not available (such as not supported for this concrete attribute class)public AttributeTag getTag()
Get the tag of this attribute.
public long getVL()
Get the value length of this attribute.
public int getVM()
Get the value multiplicity of this attribute.
public byte[] getVR()
Get the value representation of this attribute.
public java.lang.String getVRAsString()
Get the value representation of this attribute.
String
public boolean isValid() throws DicomException
DicomException
- if error in DICOM value extractionpublic abstract void removeValues() throws DicomException
Remove any existing values, making the attribute empty (zero length).
DicomException
- thrown if not supported for concrete attribute classpublic boolean repairValues() throws DicomException
DicomException
- if error in DICOM value extractionpublic void setValue(byte v) throws DicomException
v
- value to setDicomException
- thrown if value of this type is not valid for this concrete attribute classpublic void setValue(double v) throws DicomException
v
- value to setDicomException
- thrown if value of this type is not valid for this concrete attribute classpublic void setValue(float v) throws DicomException
v
- value to setDicomException
- thrown if value of this type is not valid for this concrete attribute classpublic void setValue(int v) throws DicomException
v
- value to setDicomException
- thrown if value of this type is not valid for this concrete attribute classpublic void setValue(long v) throws DicomException
v
- value to setDicomException
- thrown if value of this type is not valid for this concrete attribute classpublic void setValue(short v) throws DicomException
v
- value to setDicomException
- thrown if value of this type is not valid for this concrete attribute classpublic void setValue(java.lang.String v) throws DicomException
String
value after any existing values of this attribute.v
- value to setDicomException
- thrown if value of this type is not valid for this concrete attribute classpublic void setValues(byte[] v) throws DicomException
v
- the array of new valuesDicomException
- thrown if values of this type are not valid for this concrete attribute classpublic void setValues(byte[] v, boolean big) throws DicomException
v
- the array of new valuesbig
- whether or not to intepret the values larger than bytes as big endian or notDicomException
- thrown if values of this type are not valid for this concrete attribute classpublic void setValues(double[] v) throws DicomException
v
- the array of new valuesDicomException
- thrown if values of this type are not valid for this concrete attribute classpublic void setValues(float[] v) throws DicomException
v
- the array of new valuesDicomException
- thrown if values of this type are not valid for this concrete attribute classpublic void setValues(int[] v) throws DicomException
v
- the array of new valuesDicomException
- thrown if values of this type are not valid for this concrete attribute classpublic void setValues(long[] v) throws DicomException
v
- the array of new valuesDicomException
- thrown if values of this type are not valid for this concrete attribute classpublic void setValues(short[] v) throws DicomException
v
- the array of new valuesDicomException
- thrown if values of this type are not valid for this concrete attribute classpublic java.lang.String toString()
Dump the contents of the attribute as a human-readable string.
No new line is appended.
The result is of the form:
(0xgggg,0xeeee) VR=<XX> VL=<0xnnnn> <...>
For example:
(0x0018,0x0020) VR=<CS> VL=<0x2> <GR>
toString
in class java.lang.Object
String
valuepublic java.lang.String toString(DicomDictionary dictionary)
Dump the contents of the attribute as a human-readable string.
No new line is appended.
The result is of the form:
(0xgggg,0xeeee) Name VR=<XX> VL=<0xnnnn> <...>
For example:
(0x0018,0x0020) ScanningSequence VR=<CS> VL=<0x2> <GR>
dictionary
- the dictionary to use to look up the nameString
valuepublic abstract void write(DicomOutputStream o) throws DicomException, java.io.IOException
Write the entire attribute (including values) to the output stream.
o
- the output streamjava.io.IOException
- if an I/O error occursDicomException
- if error in DICOM encodingprotected void writeBase(DicomOutputStream o) throws DicomException, java.io.IOException
Write the common preamble of an attribute to the output stream.
Writes the tag, VR (if explicit in the output stream) and the value length in the appropriate form.
Implements the CP 1066 proposal to handle values too long to fit in Explicit VR by writing a UN rather than the actual VR.
Called by a concrete base class prior to writing the values themselves.
o
- the output streamDicomException
- if the VL is too long to be written in the Transfer Syntax of the DicomOutputStream (Explicit VR)java.io.IOException
- if an I/O error occurs