public class MCdicomDir extends MCattributeSet
For a description about how DICOMDIR's reference instances in a DICOM File-set see Annex F in Part 3 of the DICOM standard.
An instance of this class is an in-memory representation of a DICOMDIR file. The File-set
identification and the Directory Information attributes can be accessed or modified directly
using the corresponding methods of the base class. Although the Directory Record Sequence
attribute can be accessed directly using the same methods, the toolkit provides a much
easier way to navigate the records of the DICOMDIR through the MCdirRecord
class.
The constructor of this class creates an empty DICOMDIR object which can be populated with
records by reading the content of an existing DICOMDIR file or by building a new record
hierarchy using the addChildRecord()
method of
the root record.
The root record of the DICOMDIR represents the Directory Record Sequence itself and it does
not contain any attributes directly, instead it is the parent record for all top level (PATIENT)
records. The root record can not be deleted and its getRecordItem()
method always returns null
.
The following code shows how to read a DICOMDIR file and navigate its records:
MCdicomDir dir = new MCdicomDir(); dir.readDicomDir( "DICOMDIR" ); MCdirRecord root = dir.getRoot(); MCdirRecord rec = root.getFirstChild(); while( rec != null ) { MCitem content = rec.getRecordItem(); String patientName = content.getStringValue( MCdicom.PATIENTS_NAME, 0, "" ); System.out.println( rec.getRecordName() + " record: " + patientName ); System.out.println( " has " + rec.getChildCount() + " studies " ); rec = root.getNextChild(); }
An instance of this class can not be used by multiple threads concurrently.
Modifier and Type | Class and Description |
---|---|
class |
MCdicomDir.MCdirRecord
Represents a DICOMDIR record containing information about one DICOM instance in a file set.
|
Constructor and Description |
---|
MCdicomDir()
Initializes a new instance of this class.
|
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Disposes this attribute set and ensures unmanaged resource associated with the attributes set are released.
|
int |
getFileSetConsistencyFlag()
Gets the value of the File-set Consistency Flag attribute of this DICOMDIR.
|
java.lang.String |
getFileSetID()
Gets the value of the File-set ID attribute of this DICOMDIR.
|
java.lang.String |
getMediaStorageSOPInstanceUID()
Gets the value of the Media Storage SOP Instance UID attribute in this DICOMDIR's meta information.
|
MCdicomDir.MCdirRecord |
getRoot()
Gets the root record of this DICOMDIR.
|
void |
list(java.io.PrintStream dest)
Lists the content of this attribute set in a human readable form.
|
void |
readDicomDir(java.nio.channels.ReadableByteChannel source)
Reads a DICOMDIR file from the specified byte channel.
|
void |
readDicomDir(java.lang.String filePath)
Reads a DICOMDIR file from specified location.
|
void |
writeDicomDir(java.lang.String filePath)
Write a DICOMDIR file object to the specified file.
|
void |
writeDicomDir(java.nio.channels.WritableByteChannel destination)
Write a DICOMDIR file object to a specified byte channel.
|
addAttribute, addAttribute, addEncapsulatedFrame, addValue, addValue, clear, clear, contains, contains, copyTo, createSignature, createSignature, deleteSignature, duplicate, getBigInteger, getBigInteger, getBulkValue, getBulkValue, getCommand, getDoubleValue, getDoubleValue, getEncapsulatedFrame, getFloatValue, getFloatValue, getFrame, getIntValue, getIntValue, getItem, getItem, getKeyword, getKeyword, getLongValue, getLongValue, getModality, getNextValidationError, getOffsetTable, getService, getShortValue, getShortValue, getSOPClassUID, getSOPInstanceUID, getStringValue, getStringValue, getStringValue, getStringValue, getTransferSyntax, getValue, getValue, getValue, getValue, getValueCount, getValueCount, getValueLength, getValueLength, getValueRepresentation, getValueRepresentation, getValues, getValues, iterator, list, readAttributeSetsFromJSON, readAttributeSetsFromJSON, readFromJSON, readFromJSON, readFromStream, readFromStream, readFromXML, readFromXML, readFromXMLNative, readFromXMLNative, removeAttribute, removeAttribute, resetTransferSyntax, setDefaultCompression, setServiceCommand, setTransferSyntax, setValue, setValue, setValueRepresentation, setValueRepresentation, size, validate, validateAttribute, verifySignature, writeAttributeSetsToJSON, writeToJSON, writeToStream, writeToStream, writeToXML, writeToXML, writeToXMLNative
public MCdicomDir()
The newly created instance will be empty meaning that it contains a root record with no child records.
MCexception
- If the toolkit is not initialized.public void readDicomDir(java.lang.String filePath)
filePath
- The DICOMDIR file location. The file name is always "DICOMDIR".MCexception
- null
or the file name is not "DICOMDIR".
public void readDicomDir(java.nio.channels.ReadableByteChannel source)
source
- The byte channel providing the encoded DICOM content.MCexception
- null
public void writeDicomDir(java.lang.String filePath)
Changes made to the content of this dicomdir after this call will not be reflected in the written DICOMDIR file unless this method is called again after the changes are made.
If a file with the same name already exists, the file is overwritten.
filePath
- The destination to write this DICOMDIR instance. The file name
should always be "DICOMDIR"MCexception
- null
or the file name is not "DICOMDIR".
public void writeDicomDir(java.nio.channels.WritableByteChannel destination)
Changes made to the content of this dicomdir after this call will not be reflected in the written DICOMDIR file unless this method is called again after the changes are made.
If a file with the same name already exists, the file is overwritten.
destination
- The byte channel to write this DICOMDIR instance.MCexception
- null
.
public MCdicomDir.MCdirRecord getRoot()
The root record of the DICOMDIR represents the Directory Record Sequence itself and it does not contain any attributes directly, instead it can be used to manage top (PATIENT) level records.
The root record can not be deleted and its getRecordItem()
method always returns null
.
MCdirRecord
object that can be used to get all top level records in the DICOMDIR.
null
if no lower level records in this DICOMDIR.MCexception
- the toolkit found a corrupted record ID in a directory record offset attribute
while trying to traverse the DICOMDIR.public void dispose()
MCattributeSet
If this method is not called the unmanaged resources are released when this object is garbage collected.
An application must not call any method of the attribute set after disposing it.
dispose
in class MCattributeSet
public java.lang.String getMediaStorageSOPInstanceUID()
This method provides easy access to the value of the Media Storage SOP Instance UID
attribute of this DICOMDIR. This method is equivalent with the following call:
getStringValue(MCdicom.MEDIA_STORAGE_SOP_INSTANCE_UID, 0, null)
.
null
if
the attribute is missing or it has no values.public java.lang.String getFileSetID()
This method provides easy access to the value of the File-set ID attribute
of this DICOMDIR. This method is equivalent with the following call:
getStringValue(MCdicom.FILE_SET_ID, 0, null)
.
public int getFileSetConsistencyFlag()
This method provides easy access to the value of the File-set Consistency Flag
attribute of this DICOMDIR. This method is equivalent with the following call:
getIntValue(MCdicom.FILE_SET_CONSISTENCY_FLAG, 0, null)
.
A return value of 0 (zero) means no known inconsistencies while 0xFFFF means that inconsistencies may be present.
MCexception
- If this attribute set does not contain the requested attribute, if the value number is out of
range or if the value can not be represented as an integer.public void list(java.io.PrintStream dest)
This method produces a report describing the contents of this attribute set. The report will
be written to the provided print stream, or to the "standard" output stream if the argument is
null
.
Note that if the object contains an attribute with a Value Representation of SQ (sequence of items), each item in the sequence will be listed. Each sequence of items is indented in the listing four spaces to the right of its owning message or items. This behavior is configurable through the LIST_SQ_DEPTH_LIMIT setting.
The maximum size of values listed can be controlled using the LIST_VALUE_LIMIT setting. The listing of attributes with UNKNOWN value representation is controlled by the LIST_UN_ATTRIBUTES setting.}
list
in class MCattributeSet
dest
- The output for the listing.}