public class MCtag
extends java.lang.Object
Class methods that require an attribute identifier require either the use of
an MCtag
object or an integer for that identification. It is recommended that
applications use MCtag objects to identify private attributes and integers to
for non-private attributes.
A DICOM tag is usually written as an ordered pair of two byte numbers. The first two bytes are sometimes called a group number, with the last two bytes being called an element number (e.g., (0010, 0010), (0038, 001C), ...).
This class addresses the fact that DICOM allows both private and non-private attributes. The group number for private attributes must always be odd, while the group number for non-private attributes must always be even. Private attributes belong to a private group, identified by a private code string. Each private group may have up to 254 elements, numbered 1 through 255.
Tags for private attributes are constructed by providing a private group code string in addition to the two byte private group number and the one byte element number.
The definition of private data elements may be added to the toolkit's DICOM data dictionary to ensure proper value parsing and value representation when dealing with implicitly encoded data (Implicit Little Endian transfer syntax). See the Merge DICOM database manual (Database.pdf) for information on how to add private data element definitions to the dictionary.
Instances of this class can be used by multiple threads concurrently.
Constructor and Description |
---|
MCtag(int tagNumber)
Initializes a tag object identifying a non-private data element.
|
MCtag(int tagNumber,
java.lang.String privateCode)
Initializes a tag object identifying a private data element.
|
MCtag(java.lang.String privateCode,
int privateGroupNumber,
int privateElementNumber)
Initializes a tag object identifying a private data element.
|
Modifier and Type | Method and Description |
---|---|
int |
elementNumber()
Gets the element portion of the tag number.
|
boolean |
equals(java.lang.Object o)
Determines whether this object is equal to another object.
|
short |
groupNumber()
Returns the group portion of the tag number.
|
int |
hashCode()
Gets a hash code based on the tag number.
|
boolean |
isPrivateCreatorTag()
Tells if this tag identifies the private group creator element.
|
static boolean |
isPrivateCreatorTag(int tagNumber)
Tells if a tag identifies the private group creator element.
|
boolean |
isPrivateTag()
Tells if this tag is identifying a private data element.
|
static boolean |
isPrivateTag(int tagNumber)
Tells if a tag number is identifying a private data element.
|
java.lang.String |
privateCode()
Returns the private creator code associated with this tag's private group.
|
int |
tagNumber()
Gets the tag number of this tag.
|
static java.lang.String |
tagToString(int tagNumber)
Converts a tag number to its string representation in the form "(gggg,eeee)".
|
java.lang.String |
toString()
Returns a String that represents the value of this tag.
|
public MCtag(int tagNumber)
Tag numbers larger than Integer.MAX_VALUE
are represented as negative integer.
tagNumber
- The tag number of the element.MCexception
- if the tag number represents a private tag.public MCtag(java.lang.String privateCode, int privateGroupNumber, int privateElementNumber)
privateCode
- The private group creator code identifying the element.privateGroupNumber
- The private tag's group number (an odd number)privateElementNumber
- The private tag's element number (0-255).MCexception
- If one of the arguments is invalid.public MCtag(int tagNumber, java.lang.String privateCode)
tagNumber
- The tag number of the data element.privateCode
- The private group creator code identifying the element.MCexception
- If one of the arguments is invalid.public int elementNumber()
The element portion is the least significant 16 bits of the 32-bit tag number.
public boolean equals(java.lang.Object o)
MCtag
,
the tag numbers are equal and (if this is a private tag) the private codes are the same.equals
in class java.lang.Object
o
- The object to compare to this objectpublic short groupNumber()
public int hashCode()
hashCode
in class java.lang.Object
public boolean isPrivateTag()
A tag is considered private if its group number is odd and its element number is not in the range [0x0010,0x00FF]. Odd numbered groups 1, 3, 5, 7 and 0xFFFF, and element numbers in the range [0x0001,0x000F] or [0x0100,0x0FFF] are DICOM non-compliant (will generate warning message). Note: element 0 (group length - retired) isn't treated as private data element and will return false.
true
if this is a private tag.public boolean isPrivateCreatorTag()
Private group creator elements are used to reserve a range of tag values in a certain private group and they have odd group numbers and element numbers between 0x0010 and 0x00FF inclusively. Odd numbered groups 1, 3, 5, 7 and 0xFFFF will generate a warning message since these are DICOM non-compliant.
true
if this tag identifies the private group creator element.public static boolean isPrivateTag(int tagNumber)
A tag is considered private if its group number is odd and its element number is not in the range [0x0010,0x00FF]. Odd numbered groups 1, 3, 5, 7 and 0xFFFF, and element numbers in the range [0x0001,0x000F] or [0x0100,0x0FFF] are DICOM non-compliant (will generate warning message). Note: element 0 (group length - retired) isn't treated as private data element and will return false.
tagNumber
- The tag number to check.true
if the specified tag is a private tag.public static boolean isPrivateCreatorTag(int tagNumber)
Private group creator elements are used to reserve a range of tag values in a certain private group and they have odd group numbers and element numbers between 0x0010 and 0x00FF inclusively. Odd numbered groups 1, 3, 5, 7 and 0xFFFF will generate a warning message since these are DICOM non-compliant.
tagNumber
- The tag number to check.true
if the specified tag identifies the private group creator element.public java.lang.String privateCode()
null
if this is not a private tag.public int tagNumber()
public java.lang.String toString()
The string represents the number as a hexadecimal number. If the tag is private, its private code is included in the string.
toString
in class java.lang.Object
public static java.lang.String tagToString(int tagNumber)
tagNumber
- The tag number.