com.pixelmed.dicom

## Class StoredFilePathStrategy

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

- Direct Known Subclasses:
    ReceivedFilePathStrategy, StoredFilePathStrategyComponentFolders, StoredFilePathStrategyHashSubFolders, StoredFilePathStrategySingleFolder

      public abstract class StoredFilePathStrategy
      extends java.lang.Object

  This is an abstract class to support creating path names for how to organize the folders and files for stored composite instances based on their SOP Instance UID.

  Concrete subclasses implement various different strategies, which may be instantiated themselves, or accessed by the enumerated fields in this class.

  The choices may be passed as arguments to constructors of `StorageSOPClassSCPDispatcher`.

  Methods are provided to generate pathnames based on the supplied UID, as well as to create any sub-folders required and generate altrernative path names if the existing path name is alreayd in use for some other purpose.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static StoredFilePathStrategy` | `BYSOPINSTANCEUIDCOMPONENTFOLDERS` Store all the stored files in a hierarchy of folders using successive numeric components of the SOP Instance UID as the folder name and the SOP Instance UID as the filename within the most deeply nested folder.
    `static StoredFilePathStrategy` | `BYSOPINSTANCEUIDHASHSUBFOLDERS` Store all the stored files in a hierarchy of folders using successive decimal digits of the hashcode of the SOP Instance UID as the folder name and the SOP Instance UID as the filename within the most deeply nested folder.
    `static StoredFilePathStrategy` | `BYSOPINSTANCEUIDINSINGLEFOLDER` Store all the stored files in a single folder, using the SOP Instance UID as the filename.
    `protected int` | `debugLevel`
    `protected static java.lang.String` | `defaultAlternativeSubfolder`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `StoredFilePathStrategy()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static StoredFilePathStrategy` | `getDefaultStrategy()` Get the default strategy.
    `java.io.File` | `makeAlternativeStoredFilePath(java.io.File savedInstancesFolder, java.lang.String alternativeSubfolder, java.lang.String sopInstanceUID)` Generate an alternative path to where to store a file based on its SOP Instance UID.
    `java.io.File` | `makeReliableStoredFilePathWithFoldersCreated(java.io.File savedInstancesFolder, java.lang.String sopInstanceUID)` Generate a path to where to store a file based on its SOP Instance UID and assure its reliability.
    `java.io.File` | `makeReliableStoredFilePathWithFoldersCreated(java.io.File savedInstancesFolder, java.lang.String alternativeSubfolder, java.lang.String sopInstanceUID)` Generate a path to where to store a file based on its SOP Instance UID and assure its reliability.
    `java.io.File` | `makeStoredFilePath(java.io.File savedInstancesFolder, java.lang.String sopInstanceUID)` Generate a path to where to store a file based on its SOP Instance UID.
    `java.lang.String` | `makeStoredFilePath(java.lang.String sopInstanceUID)` Generate a path to where to store a file based on its SOP Instance UID.
    `void` | `setDebugLevel(int debugLevel)`
    `protected void` | `test(java.lang.String[] arg)`

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

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

- - ### Field Detail

    - #### BYSOPINSTANCEUIDINSINGLEFOLDER

          public static final StoredFilePathStrategy BYSOPINSTANCEUIDINSINGLEFOLDER

      Store all the stored files in a single folder, using the SOP Instance UID as the filename.

      See Also:
        `StoredFilePathStrategySingleFolder`

    - #### BYSOPINSTANCEUIDCOMPONENTFOLDERS

          public static final StoredFilePathStrategy BYSOPINSTANCEUIDCOMPONENTFOLDERS

      Store all the stored files in a hierarchy of folders using successive numeric components of the SOP Instance UID as the folder name and the SOP Instance UID as the filename within the most deeply nested folder.

      See Also:
        `StoredFilePathStrategyComponentFolders`

    - #### BYSOPINSTANCEUIDHASHSUBFOLDERS

          public static final StoredFilePathStrategy BYSOPINSTANCEUIDHASHSUBFOLDERS

      Store all the stored files in a hierarchy of folders using successive decimal digits of the hashcode of the SOP Instance UID as the folder name and the SOP Instance UID as the filename within the most deeply nested folder.

      See Also:
        `StoredFilePathStrategyHashSubFolders`

    - #### defaultAlternativeSubfolder

          protected static java.lang.String defaultAlternativeSubfolder

    - #### debugLevel

          protected int debugLevel

  - ### Constructor Detail

    - #### StoredFilePathStrategy

          protected StoredFilePathStrategy()

  - ### Method Detail

    - #### getDefaultStrategy

          public static final StoredFilePathStrategy getDefaultStrategy()

      Get the default strategy.

      Returns:
        the default strategy (which is BYSOPINSTANCEUIDINSINGLEFOLDER)

    - #### makeStoredFilePath

          public java.lang.String makeStoredFilePath(java.lang.String sopInstanceUID)

      Generate a path to where to store a file based on its SOP Instance UID.

      Parameters:
        `sopInstanceUID` - the SOP Instance UID of the instance to be saved
      Returns:
        the path to the file, which may contain nested sub-folders

    - #### makeStoredFilePath

          public java.io.File makeStoredFilePath(java.io.File savedInstancesFolder,
                                                 java.lang.String sopInstanceUID)

      Generate a path to where to store a file based on its SOP Instance UID.

      Parameters:
        `savedInstancesFolder` - the folder in which to save the instance
        `sopInstanceUID` - the SOP Instance UID of the instance to be saved
      Returns:
        the path to the file in the specified folder, which may contain nested sub-folders

    - #### makeAlternativeStoredFilePath

          public java.io.File makeAlternativeStoredFilePath(java.io.File savedInstancesFolder,
                                                            java.lang.String alternativeSubfolder,
                                                            java.lang.String sopInstanceUID)

      Generate an alternative path to where to store a file based on its SOP Instance UID.

      Use when the normal path is already occupied by something other than a file (such as a folder).

      Parameters:
        `savedInstancesFolder` - the folder in which to save the instance
        `alternativeSubfolder` - the alternate sub-folder with the saved instance folder in which to save the instance
        `sopInstanceUID` - the SOP Instance UID of the instance to be saved
      Returns:
        the path to the file in the specified folder and alternate sub-folder

    - #### makeReliableStoredFilePathWithFoldersCreated

          public java.io.File makeReliableStoredFilePathWithFoldersCreated(java.io.File savedInstancesFolder,
                                                                           java.lang.String alternativeSubfolder,
                                                                           java.lang.String sopInstanceUID)

      Generate a path to where to store a file based on its SOP Instance UID and assure its reliability.

      Includes creating any necessary parent folders if they do not already exist, and using an alternate path or name if a desired file name already exists as something else (such as a folder).

      Parameters:
        `savedInstancesFolder` - the folder in which to save the instance
        `alternativeSubfolder` - the alternate sub-folder with the saved instance folder in which to save the instance
        `sopInstanceUID` - the SOP Instance UID of the instance to be saved
      Returns:
        the path to the file in the specified folder, which may contain nested sub-folders

    - #### makeReliableStoredFilePathWithFoldersCreated

          public java.io.File makeReliableStoredFilePathWithFoldersCreated(java.io.File savedInstancesFolder,
                                                                           java.lang.String sopInstanceUID)

      Generate a path to where to store a file based on its SOP Instance UID and assure its reliability.

      Includes creating any necessary parent folders if they do not already exist, and using an alternate path or name (in a default alternative sub-folder) if a desired file name already exists as something else (such as a folder).

      Parameters:
        `savedInstancesFolder` - the folder in which to save the instance
        `sopInstanceUID` - the SOP Instance UID of the instance to be saved
      Returns:
        the path to the file in the specified folder, which may contain nested sub-folders

    - #### setDebugLevel

          public void setDebugLevel(int debugLevel)

    - #### test

          protected void test(java.lang.String[] arg)