Class FilenameSorter

java.lang.Object
gov.nih.mipav.model.file.FilenameSorter
All Implemented Interfaces:
Comparator<String>

public class FilenameSorter extends Object implements Comparator<String>
DOCUMENT ME!
  • Constructor Details

    • FilenameSorter

      public FilenameSorter()
  • Method Details

    • commonSet

      public static boolean commonSet(String str1, String str2)
      This method determines whether two String objects have the same characters up to the beginning index of the last numerical sequence of numerals.
      Parameters:
      str1 - DOCUMENT ME!
      str2 - DOCUMENT ME!
      Returns:
      DOCUMENT ME!
    • compareToLastNumericalSequence

      public static int compareToLastNumericalSequence(String str1, String str2)
      The purpose of this method is to compare two filename strings on the basis of their last numerical sequence. For example, the filenames "dicom84.dcm" and "dicom83.dcm" will be compared to each other on the numbers 83 and 84.
      Parameters:
      str1 - String
      str2 - String
      Returns:
      int
    • extractSubSets

      public static Vector<Vector<String>> extractSubSets(String[] filenames)
      This method will take a String array parameter and break it into a Vector of Vectors. The encompassing Vector will hold references to Vectors of String, which should represent a set of related data. The related data is meant to have the same characters up until the beginning index of the last numerical sequence of numerals.
      Parameters:
      filenames - String[]
      Returns:
      Vector
    • lastNumericalSequenceBegin

      public static int lastNumericalSequenceBegin(String str)
      Alternative to lastNumericalSequenceBegin(String, int), this method should be called if you don't already have the index of the end of the last numerical sequence in the String parameter.
      Parameters:
      str - String
      Returns:
      int
    • lastNumericalSequenceBegin

      public static int lastNumericalSequenceBegin(String str, int lastNumSequenceEnd)
      The purpose of this method is to find the index location of a String that is the beginning of the last numerical sequence. For example, when passed the string "dicom84.dcm" the method will return 5.
      Parameters:
      str - String
      lastNumSequenceEnd - int
      Returns:
      int
    • lastNumericalSequenceEnd

      public static int lastNumericalSequenceEnd(String str)
      The purpose of this method is to find the index location of a String that is the end of the last numerical sequence. For example, when passed the string "dicom84.dcm" this method will return 6.
      Parameters:
      str - String
      Returns:
      int
    • secondarySort

      public static Vector<Vector<String>> secondarySort(Vector<Vector<String>> vector)
      This method takes a sorted Vector of Vectors as a parameter. The encompassing Vector holds references to Vectors of a particular set of Strings. These sets are sorted based on their last numerical sequence of numerals. The rearranged Vector is then returned.
      Parameters:
      vector - Vector
      Returns:
      Vector
    • subSetsToArray

      public static String[] subSetsToArray(Vector<Vector<String>> vector)
      Method will convert a Vector of Vectors of String into a String array.
      Parameters:
      vector - Vector
      Returns:
      String[]
    • compare

      public int compare(String arg0, String arg1)
      Specified by:
      compare in interface Comparator<String>