com.pixelmed.dicom

## Class UIDGenerator

- java.lang.Object
- - com.pixelmed.dicom.UIDGenerator

-     public class UIDGenerator
      extends java.lang.Object

  A class for generating new UIDs, deterministically or not, including potentially reproducible Study, Series and SOP Instance UIDs.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `UIDGenerator()` Create a UID generator.
    `UIDGenerator(java.lang.String stamp)` Create a UID generator.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `getAnotherNewUID()` Get a different new UID for any purpose.
    `java.lang.String` | `getNewSeriesInstanceUID(java.lang.String studyID, java.lang.String seriesNumber)` Get a Series Instance UID.
    `java.lang.String` | `getNewSOPInstanceUID(java.lang.String studyID, java.lang.String seriesNumber, java.lang.String instanceNumber)` Get a SOP Instance UID.
    `java.lang.String` | `getNewStudyInstanceUID(java.lang.String studyID)` Get a Study Instance UID.
    `java.lang.String` | `getNewUID()` Get a new UID for any purpose.
    `static void` | `main(java.lang.String[] arg)` Test generating SOP Instance UIDs.
    `void` | `newStamp()` Reinitialize the UID generator with a new stamp using random and installation specific elements to create a unique root.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### UIDGenerator

          public UIDGenerator()

      Create a UID generator.

      This will use random and installation specific elements to create a unique root.

    - #### UIDGenerator

          public UIDGenerator(java.lang.String stamp)

      Create a UID generator.

      This will use the supplied stamp rather than generating a unique root, to create repeatable UIDs.

      Parameters:
        `stamp` - a String of dotted numeric values in UID form

  - ### Method Detail

    - #### newStamp

          public void newStamp()

      Reinitialize the UID generator with a new stamp using random and installation specific elements to create a unique root.

      For example, use between invocations of getNewUID().

    - #### getNewUID

          public java.lang.String getNewUID()
                                     throws DicomException

      Get a new UID for any purpose.

      This will always be the same for this instance of the UIDGenerator, unless newStamp() has been called since the last time.

      Returns:
        the UID
      Throws:
        `DicomException` - if result is too long or otherwise not a valid UID

    - #### getAnotherNewUID

          public java.lang.String getAnotherNewUID()
                                            throws DicomException

      Get a different new UID for any purpose.

      This will never be the same twice, since newStamp() is called.

      Returns:
        the UID
      Throws:
        `DicomException` - if result is too long or otherwise not a valid UID

    - #### getNewStudyInstanceUID

          public java.lang.String getNewStudyInstanceUID(java.lang.String studyID)
                                                  throws DicomException

      Get a Study Instance UID.

      This will be the same for this instance of the UIDGenerator and the same parameter values.

      Only use this if you really need reproducible UIDs; otherwise use getNewUID().

      Parameters:
        `studyID` - least significant 4 digits of leading numeric part is used
      Returns:
        the UID
      Throws:
        `DicomException` - if result is too long or otherwise not a valid UID

    - #### getNewSeriesInstanceUID

          public java.lang.String getNewSeriesInstanceUID(java.lang.String studyID,
                                                          java.lang.String seriesNumber)
                                                   throws DicomException

      Get a Series Instance UID.

      This will be the same for this instance of the UIDGenerator and the same parameter values.

      Only use this if you really need reproducible UIDs; otherwise use getNewUID().

      Parameters:
        `studyID` - least significant 4 digits of leading numeric part is used
        `seriesNumber` - least significant 4 digits of leading numeric part is used
      Returns:
        the UID
      Throws:
        `DicomException` - if result is too long or otherwise not a valid UID

    - #### getNewSOPInstanceUID

          public java.lang.String getNewSOPInstanceUID(java.lang.String studyID,
                                                       java.lang.String seriesNumber,
                                                       java.lang.String instanceNumber)
                                                throws DicomException

      Get a SOP Instance UID.

      This will be the same for this instance of the UIDGenerator and the same parameter values.

      Only use this if you really need reproducible UIDs; otherwise use getNewUID().

      Parameters:
        `studyID` - least significant 4 digits of leading numeric part is used
        `seriesNumber` - least significant 4 digits of leading numeric part is used
        `instanceNumber` - least significant 4 digits of leading numeric part is used
      Returns:
        the UID
      Throws:
        `DicomException` - if result is too long or otherwise not a valid UID

    - #### main

          public static final void main(java.lang.String[] arg)

      Test generating SOP Instance UIDs.

      Parameters:
        `arg` - a single numeric argument that is the number of UIDs to generate