Class Attribute
- java.lang.Object
-
- com.pixelmed.dicom.Attribute
-
- Direct Known Subclasses:
AttributeTagAttribute
,FloatDoubleAttribute
,FloatSingleAttribute
,OtherAttributeOnDisk
,OtherByteAttribute
,OtherByteAttributeMultipleCompressedFilesOnDisk
,OtherByteAttributeMultipleCompressedFrames
,OtherByteAttributeMultipleFilesOnDisk
,OtherByteAttributeMultipleFrameArrays
,OtherDoubleAttribute
,OtherFloatAttribute
,OtherFloatAttributeMultipleFilesOnDisk
,OtherLongAttribute
,OtherVeryLongAttribute
,OtherWordAttribute
,OtherWordAttributeMultipleFilesOnDisk
,OtherWordAttributeMultipleFrameArrays
,SequenceAttribute
,SignedLongAttribute
,SignedShortAttribute
,SignedVeryLongAttribute
,StringAttribute
,TextAttribute
,UnknownAttribute
,UnsignedLongAttribute
,UnsignedShortAttribute
,UnsignedVeryLongAttribute
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
.- See Also:
AttributeFactory
,AttributeList
-
-
Field Summary
Fields Modifier and Type Field Description protected long
valueLength
protected int
valueMultiplicity
-
Constructor Summary
Constructors Modifier Constructor Description protected
Attribute(AttributeTag t)
Construct an (empty) attribute; called only by concrete sub-classes.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method 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
getLengthOfBaseOfEncodedAttribute(boolean explicit, boolean littleEndian)
Get the length of the base attribute when encoded, accounting for the characteristics of the Transfer Syntax and the need for even-length padding.long
getLengthOfEncodedValue()
Get the number of bytes encoded for the value of this attribute.long
getLengthOfEntireEncodedAttribute(boolean explicit, boolean littleEndian)
Get the length of the entire attribute when encoded, accounting for the characteristics of the Transfer Syntax and the need for even-length padding.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.double
getSingleDoubleValueOrDefault(double dflt)
Get a single double value for the attribute.static double
getSingleDoubleValueOrDefault(AttributeList list, AttributeTag tag, double dflt)
Get a single double value of a named attribute in an attribute list.static double
getSingleDoubleValueOrDefault(Attribute a, double dflt)
Get a single double value of a supplied attribute that may be null.float
getSingleFloatValueOrDefault(float dflt)
Get a single float value for the attribute.static float
getSingleFloatValueOrDefault(AttributeList list, AttributeTag tag, float dflt)
Get a single float value of a named attribute in an attribute list.static float
getSingleFloatValueOrDefault(Attribute a, float dflt)
Get a single float value of a supplied attribute that may be null.int
getSingleIntegerValueOrDefault(int dflt)
Get a single int value for the attribute.static int
getSingleIntegerValueOrDefault(AttributeList list, AttributeTag tag, int dflt)
Get a single int value of a named attribute in an attribute list.static int
getSingleIntegerValueOrDefault(Attribute a, int dflt)
Get a single int value of a supplied attribute that may be null.long
getSingleLongValueOrDefault(long dflt)
Get a single long 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.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 singleString
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.
-
-
-
Constructor Detail
-
Attribute
protected Attribute(AttributeTag t)
Construct an (empty) attribute; called only by concrete sub-classes.
- Parameters:
t
- the tag of the attribute
-
-
Method Detail
-
getTag
public AttributeTag getTag()
Get the tag of this attribute.
- Returns:
- the tag
-
getGroup
public int getGroup()
Get the group of the tag of this attribute.
- Returns:
- the group of the tag
-
getElement
public int getElement()
Get the element of the tag of this attribute.
- Returns:
- the element of the tag
-
getVL
public long getVL()
Get the value length of this attribute.
- Returns:
- the value length (does not include need for even-length padding, hence may be odd length)
-
getVM
public int getVM()
Get the value multiplicity of this attribute.
- Returns:
- the value multiplicity
-
getVR
public byte[] getVR()
Get the value representation of this attribute.
- Returns:
- the value representation as a two byte array
-
getVRAsString
public java.lang.String getVRAsString()
Get the value representation of this attribute.
- Returns:
- the value representation as a
String
-
getPaddedVL
public long getPaddedVL()
Get the value length of this attribute, accounting for the need for even-length padding.
- Returns:
- the value length (padded to an even length)
-
getLengthOfEncodedValue
public long getLengthOfEncodedValue()
Get the number of bytes encoded for the value of this attribute.
Accounts for delimited Sequence and Encapsulated Pixel Data OB attributes.
- Returns:
- number of bytes encoded
-
getLengthOfEntireEncodedAttribute
public long getLengthOfEntireEncodedAttribute(boolean explicit, boolean littleEndian) throws DicomException
Get the length of the entire attribute when encoded, accounting for the characteristics of the Transfer Syntax and the need for even-length padding.
- Parameters:
explicit
- true if the Transfer Syntax to be used for encoding is explicit VRlittleEndian
- true if the Transfer Syntax to be used for encoding is little endian- Returns:
- the length in bytes
- Throws:
DicomException
- if the VL is too long to be written in Explicit VR Transfer Syntax
-
getLengthOfBaseOfEncodedAttribute
public long getLengthOfBaseOfEncodedAttribute(boolean explicit, boolean littleEndian) throws DicomException
Get the length of the base attribute when encoded, accounting for the characteristics of the Transfer Syntax and the need for even-length padding.
- Parameters:
explicit
- true if the Transfer Syntax to be used for encoding is explicit VRlittleEndian
- true if the Transfer Syntax to be used for encoding is little endian- Returns:
- the length in bytes
- Throws:
DicomException
- if the VL is too long to be written in Explicit VR Transfer Syntax
-
getOriginalStringValues
public java.lang.String[] getOriginalStringValues() throws DicomException
Get the values of this attribute as strings, the way they were originally inserted or read.
- Returns:
- the values as an array of
String
- Throws:
DicomException
- thrown if values are not available (such as not supported for this concrete attribute class)
-
getStringValues
public 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.
- Returns:
- the values as an array of
String
- Throws:
DicomException
- thrown if values are not available (such as not supported for this concrete attribute class)
-
getStringValues
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.
- Parameters:
format
- the format to use for each numerical or decimal value- Returns:
- the values as an array of
String
- Throws:
DicomException
- thrown if values are not available (such as not supported for this concrete attribute class)
-
getByteValues
public byte[] getByteValues() throws DicomException
Get the values of this attribute as a byte array, if the values are byte order insensitive.
- Returns:
- the values as an array of bytes
- Throws:
DicomException
- thrown if values are not available (such as not supported for this concrete attribute class)
-
getByteValues
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.
- Parameters:
big
- whether or not to intepret the values larger than bytes as big endian or not- Returns:
- the values as an array of bytes
- Throws:
DicomException
- thrown if values are not available (such as not supported for this concrete attribute class)
-
getShortValues
public short[] getShortValues() throws DicomException
Get the values of this attribute as a short array.
- Returns:
- the values as an array of short
- Throws:
DicomException
- thrown if values are not available (such as not supported for this concrete attribute class)
-
getIntegerValues
public int[] getIntegerValues() throws DicomException
Get the values of this attribute as an int array.
- Returns:
- the values as an array of int
- Throws:
DicomException
- thrown if values are not available (such as not supported for this concrete attribute class)
-
getLongValues
public long[] getLongValues() throws DicomException
Get the values of this attribute as a long array.
- Returns:
- the values as an array of long
- Throws:
DicomException
- thrown if values are not available (such as not supported for this concrete attribute class)
-
getFloatValues
public float[] getFloatValues() throws DicomException
Get the values of this attribute as a float array.
- Returns:
- the values as an array of float
- Throws:
DicomException
- thrown if values are not available (such as not supported for this concrete attribute class)
-
getDoubleValues
public double[] getDoubleValues() throws DicomException
Get the values of this attribute as a double array.
- Returns:
- the values as an array of double
- Throws:
DicomException
- thrown if values are not available (such as not supported for this concrete attribute class)
-
addValue
public void addValue(java.lang.String v) throws DicomException
Add a(nother)String
value after any existing values of this attribute.- Parameters:
v
- value to add- Throws:
DicomException
- thrown if value of this type is not valid for this concrete attribute class
-
setValue
public void setValue(java.lang.String v) throws DicomException
Set a singleString
value after any existing values of this attribute.- Parameters:
v
- value to set- Throws:
DicomException
- thrown if value of this type is not valid for this concrete attribute class
-
addValue
public void addValue(byte v) throws DicomException
Add a(nother) byte value after any existing values of this attribute.- Parameters:
v
- value to add- Throws:
DicomException
- thrown if value of this type is not valid for this concrete attribute class
-
setValue
public void setValue(byte v) throws DicomException
Set a single byte value after any existing values of this attribute.- Parameters:
v
- value to set- Throws:
DicomException
- thrown if value of this type is not valid for this concrete attribute class
-
addValue
public void addValue(short v) throws DicomException
Add a(nother) short value after any existing values of this attribute.- Parameters:
v
- value to add- Throws:
DicomException
- thrown if value of this type is not valid for this concrete attribute class
-
setValue
public void setValue(short v) throws DicomException
Set a single short value after any existing values of this attribute.- Parameters:
v
- value to set- Throws:
DicomException
- thrown if value of this type is not valid for this concrete attribute class
-
addValue
public void addValue(int v) throws DicomException
Add a(nother) int value after any existing values of this attribute.- Parameters:
v
- value to add- Throws:
DicomException
- thrown if value of this type is not valid for this concrete attribute class
-
setValue
public void setValue(int v) throws DicomException
Set a single int value after any existing values of this attribute.- Parameters:
v
- value to set- Throws:
DicomException
- thrown if value of this type is not valid for this concrete attribute class
-
addValue
public void addValue(long v) throws DicomException
Add a(nother) long value after any existing values of this attribute.- Parameters:
v
- value to add- Throws:
DicomException
- thrown if value of this type is not valid for this concrete attribute class
-
setValue
public void setValue(long v) throws DicomException
Set a single long value after any existing values of this attribute.- Parameters:
v
- value to set- Throws:
DicomException
- thrown if value of this type is not valid for this concrete attribute class
-
addValue
public void addValue(float v) throws DicomException
Add a(nother) float value after any existing values of this attribute.- Parameters:
v
- value to add- Throws:
DicomException
- thrown if value of this type is not valid for this concrete attribute class
-
setValue
public void setValue(float v) throws DicomException
Set a single float value after any existing values of this attribute.- Parameters:
v
- value to set- Throws:
DicomException
- thrown if value of this type is not valid for this concrete attribute class
-
addValue
public void addValue(double v) throws DicomException
Add a(nother) double value after any existing values of this attribute.- Parameters:
v
- value to add- Throws:
DicomException
- thrown if value of this type is not valid for this concrete attribute class
-
setValue
public void setValue(double v) throws DicomException
Set a single double value after any existing values of this attribute.- Parameters:
v
- value to set- Throws:
DicomException
- thrown if value of this type is not valid for this concrete attribute class
-
setValues
public void setValues(byte[] v) throws DicomException
Replace any existing values with the supplied array of byte.- Parameters:
v
- the array of new values- Throws:
DicomException
- thrown if values of this type are not valid for this concrete attribute class
-
setValues
public void setValues(byte[] v, boolean big) throws DicomException
Replace any existing values with the supplied array of byte, accounting for byte ordering of values that are larger than one byte.- Parameters:
v
- the array of new valuesbig
- whether or not to intepret the values larger than bytes as big endian or not- Throws:
DicomException
- thrown if values of this type are not valid for this concrete attribute class
-
setValues
public void setValues(short[] v) throws DicomException
Replace any existing values with the supplied array of short.- Parameters:
v
- the array of new values- Throws:
DicomException
- thrown if values of this type are not valid for this concrete attribute class
-
setValues
public void setValues(int[] v) throws DicomException
Replace any existing values with the supplied array of int.- Parameters:
v
- the array of new values- Throws:
DicomException
- thrown if values of this type are not valid for this concrete attribute class
-
setValues
public void setValues(long[] v) throws DicomException
Replace any existing values with the supplied array of long.- Parameters:
v
- the array of new values- Throws:
DicomException
- thrown if values of this type are not valid for this concrete attribute class
-
setValues
public void setValues(float[] v) throws DicomException
Replace any existing values with the supplied array of float.- Parameters:
v
- the array of new values- Throws:
DicomException
- thrown if values of this type are not valid for this concrete attribute class
-
setValues
public void setValues(double[] v) throws DicomException
Replace any existing values with the supplied array of double.- Parameters:
v
- the array of new values- Throws:
DicomException
- thrown if values of this type are not valid for this concrete attribute class
-
removeValues
public abstract void removeValues() throws DicomException
Remove any existing values, making the attribute empty (zero length).
- Throws:
DicomException
- thrown if not supported for concrete attribute class
-
writeBase
protected 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.
- Parameters:
o
- the output stream- Throws:
DicomException
- 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
-
write
public abstract void write(DicomOutputStream o) throws DicomException, java.io.IOException
Write the entire attribute (including values) to the output stream.
- Parameters:
o
- the output stream- Throws:
java.io.IOException
- if an I/O error occursDicomException
- if error in DICOM encoding
-
isValid
public boolean isValid() throws DicomException
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?- Returns:
- true if valid, false if invalid or validation not supported for the attribute type
- Throws:
DicomException
- if error in DICOM value extraction
-
repairValues
public boolean repairValues() throws DicomException
Repair any existing values of this attribute to make them comply with standard VR requirements. E.g., truncate them if they are too long. N.B., Not all types of attribute support repair.- Returns:
- true if successfully repaired or was already valid
- Throws:
DicomException
- if error in DICOM value extraction
-
toString
public 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>
- Parameters:
dictionary
- the dictionary to use to look up the name- Returns:
- a single
String
value
-
toString
public 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>
- Overrides:
toString
in classjava.lang.Object
- Returns:
- a single
String
value
-
getSingleStringValueOrDefault
public 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.
- Parameters:
dflt
- what to return if there is no (valid) string value- Returns:
- a single
String
value
-
getSingleStringValueOrDefault
public 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.
- Parameters:
dflt
- what to return if there is no (valid) string valueformat
- the format to use for each numerical or decimal value (null if none)- Returns:
- a single
String
value
-
getSingleStringValueOrEmptyString
public 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.
- Returns:
- a single
String
value
-
getSingleStringValueOrEmptyString
public 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.
- Parameters:
format
- the format to use for each numerical or decimal value- Returns:
- a single
String
value
-
getSingleStringValueOrNull
public 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.
- Returns:
- a single
String
value
-
getSingleStringValueOrNull
public 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.
- Parameters:
format
- the format to use for each numerical or decimal value- Returns:
- a single
String
value
-
getDelimitedStringValuesOrDefault
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.
- Parameters:
dflt
- what to return if there are no (valid) string values- Returns:
- the values as a delimited
String
-
getDelimitedStringValuesOrDefault
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.
- Parameters:
dflt
- what to return if there are no (valid) string valuesformat
- the format to use for each numerical or decimal value (null if none)- Returns:
- the values as a delimited
String
-
getDelimitedStringValuesOrEmptyString
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.
- Returns:
- the values as a delimited
String
-
getDelimitedStringValuesOrEmptyString
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.
- Parameters:
format
- the format to use for each numerical or decimal value- Returns:
- the values as a delimited
String
-
getDelimitedStringValuesOrNull
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.
- Returns:
- the values as a delimited
String
-
getDelimitedStringValuesOrNull
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.
- Parameters:
format
- the format to use for each numerical or decimal value- Returns:
- the values as a delimited
String
-
getSingleIntegerValueOrDefault
public 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.
- Parameters:
dflt
- what to return if there is no (valid) value- Returns:
- a single int value
-
getSingleDoubleValueOrDefault
public 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.
- Parameters:
dflt
- what to return if there is no (valid) value- Returns:
- a single double value
-
getSingleFloatValueOrDefault
public 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.
- Parameters:
dflt
- what to return if there is no (valid) value- Returns:
- a single float value
-
getSingleLongValueOrDefault
public 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.
- Parameters:
dflt
- what to return if there is no (valid) value- Returns:
- a single long value
-
getSingleStringValueOrDefault
public 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.
- Parameters:
a
- the attribute, which may be nulldflt
- what to return if there is no (valid) string value- Returns:
- a single
String
value
-
getSingleStringValueOrDefault
public 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.
- Parameters:
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 value- Returns:
- a single
String
value
-
getSingleStringValueOrEmptyString
public 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.
- Parameters:
a
- the attribute, which may be null- Returns:
- a single
String
value
-
getSingleStringValueOrEmptyString
public 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.
- Parameters:
a
- the attribute, which may be nullformat
- the format to use for each numerical or decimal value- Returns:
- a single
String
value
-
getSingleStringValueOrNull
public 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.
- Parameters:
a
- the attribute, which may be null- Returns:
- a single
String
value
-
getSingleStringValueOrNull
public 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.
- Parameters:
a
- the attribute, which may be nullformat
- the format to use for each numerical or decimal value- Returns:
- a single
String
value
-
getDelimitedStringValuesOrDefault
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.
- Parameters:
a
- the attribute, which may be nulldflt
- what to return if there are no (valid) string values- Returns:
- the values as a delimited
String
-
getDelimitedStringValuesOrDefault
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.
- Parameters:
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 value- Returns:
- the values as a delimited
String
-
getDelimitedStringValuesOrEmptyString
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.
- Parameters:
a
- the attribute, which may be null- Returns:
- the values as a delimited
String
-
getDelimitedStringValuesOrEmptyString
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.
- Parameters:
a
- the attribute, which may be nullformat
- the format to use for each numerical or decimal value- Returns:
- the values as a delimited
String
-
getDelimitedStringValuesOrNull
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.
- Parameters:
a
- the attribute, which may be null- Returns:
- the values as a delimited
String
-
getDelimitedStringValuesOrNull
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.
- Parameters:
a
- the attribute, which may be nullformat
- the format to use for each numerical or decimal value- Returns:
- the values as a delimited
String
-
getStringValues
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.
- Parameters:
a
- the attribute, which may be null- Returns:
- the values as an array of
String
-
getStringValues
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.
- Parameters:
a
- the attribute, which may be nullformat
- the format to use for each numerical or decimal value- Returns:
- the values as an array of
String
-
getSingleIntegerValueOrDefault
public 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.
- Parameters:
a
- the attribute, which may be nulldflt
- what to return if there is no (valid) value- Returns:
- a single int value
-
getIntegerValues
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.- Parameters:
a
- the attribute, which may be null- Returns:
- the values as an array of int
-
getSingleLongValueOrDefault
public 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.
- Parameters:
a
- the attribute, which may be nulldflt
- what to return if there is no (valid) value- Returns:
- a single long value
-
getLongValues
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.- Parameters:
a
- the attribute, which may be null- Returns:
- the values as an array of long
-
getSingleDoubleValueOrDefault
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.
- Parameters:
a
- the attribute, which may be nulldflt
- what to return if there is no (valid) value- Returns:
- a single double value
-
getSingleFloatValueOrDefault
public 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.
- Parameters:
a
- the attribute, which may be nulldflt
- what to return if there is no (valid) value- Returns:
- a single float value
-
getDoubleValues
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.- Parameters:
a
- the attribute, which may be null- Returns:
- the values as an array of double
-
getFloatValues
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.- Parameters:
a
- the attribute, which may be null- Returns:
- the values as an array of double
-
getSingleStringValueOrDefault
public 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.
- Parameters:
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 value- Returns:
- a single
String
value
-
getSingleStringValueOrDefault
public 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.
- Parameters:
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 value- Returns:
- a single
String
value
-
getSingleStringValueOrEmptyString
public 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.
- Parameters:
list
- the list of attributes in which to look for the attributetag
- the tag of the attribute to find- Returns:
- a single
String
value
-
getSingleStringValueOrEmptyString
public 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.
- Parameters:
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 value- Returns:
- a single
String
value
-
getSingleStringValueOrNull
public 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.
- Parameters:
list
- the list of attributes in which to look for the attributetag
- the tag of the attribute to find- Returns:
- a single
String
value
-
getSingleStringValueOrNull
public 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.
- Parameters:
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 value- Returns:
- a single
String
value
-
getDelimitedStringValuesOrDefault
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.
- Parameters:
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 values- Returns:
- the values as a delimited
String
-
getDelimitedStringValuesOrDefault
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.
- Parameters:
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 value- Returns:
- the values as a delimited
String
-
getDelimitedStringValuesOrEmptyString
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.
- Parameters:
list
- the list of attributes in which to look for the attributetag
- the tag of the attribute to find- Returns:
- the values as a delimited
String
-
getDelimitedStringValuesOrEmptyString
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.
- Parameters:
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 value- Returns:
- the values as a delimited
String
-
getDelimitedStringValuesOrNull
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.
- Parameters:
list
- the list of attributes in which to look for the attributetag
- the tag of the attribute to find- Returns:
- the values as a delimited
String
-
getDelimitedStringValuesOrNull
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.
- Parameters:
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 value- Returns:
- the values as a delimited
String
-
getStringValues
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.
- Parameters:
list
- the list of attributes in which to look for the attributetag
- the tag of the attribute to find- Returns:
- the values as an array of
String
-
getStringValues
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.
- Parameters:
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 value- Returns:
- the values as an array of
String
-
getSingleIntegerValueOrDefault
public 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.
- Parameters:
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) value- Returns:
- a single int value
-
getIntegerValues
public 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.- Parameters:
list
- the list of attributes in which to look for the attributetag
- the tag of the attribute to find- Returns:
- the values as an array of int
-
getSingleLongValueOrDefault
public 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.
- Parameters:
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) value- Returns:
- a single long value
-
getLongValues
public 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.- Parameters:
list
- the list of attributes in which to look for the attributetag
- the tag of the attribute to find- Returns:
- the values as an array of long
-
getSingleDoubleValueOrDefault
public 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.
- Parameters:
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) value- Returns:
- a single double value
-
getSingleFloatValueOrDefault
public 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.
- Parameters:
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) value- Returns:
- a single float value
-
getDoubleValues
public 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.- Parameters:
list
- the list of attributes in which to look for the attributetag
- the tag of the attribute to find- Returns:
- the values as an array of double
-
getFloatValues
public 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.- Parameters:
list
- the list of attributes in which to look for the attributetag
- the tag of the attribute to find- Returns:
- the values as an array of float
-
-