Class IbmUimaToApacheUima

java.lang.Object
org.apache.uima.tools.migration.IbmUimaToApacheUima

public class IbmUimaToApacheUima extends Object
Migration utility for converting from IBM UIMA to Apache UIMA. Updates package names and does various other string replacements. Should be run on java code, descriptors, and other files that may have UIMA package names in them (e.g., launch configurations, scripts).
  • Field Details

    • replacements

      private static List replacements
    • MAX_FILE_SIZE

      private static int MAX_FILE_SIZE
    • extensions

      private static Set extensions
    • filesScanned

      private static int filesScanned
    • filesModified

      private static int filesModified
    • filesNeedingManualAttention

      private static List filesNeedingManualAttention
    • ibmPackageNames

      private static Set ibmPackageNames
    • IMPORT_PATTERN

      private static final Pattern IMPORT_PATTERN
    • CLASS_NAME_PATTERN

      private static final Pattern CLASS_NAME_PATTERN
    • GET_NEXT_INDEX_PATTERN

      private static final Pattern GET_NEXT_INDEX_PATTERN
    • THROW_FEAT_MISSING_PATTERN

      private static final Pattern THROW_FEAT_MISSING_PATTERN
    • PACKAGE_PATTERN

      private static final Pattern PACKAGE_PATTERN
    • GETDOCANNOT_PATTERN

      private static final Pattern GETDOCANNOT_PATTERN
  • Constructor Details

    • IbmUimaToApacheUima

      public IbmUimaToApacheUima()
  • Method Details

    • main

      public static void main(String[] args) throws IOException
      Main program. Expects one argument, the name of a directory containing files to update. Subdirectories are processed recursively.
      Parameters:
      args - Command line arguments
      Throws:
      IOException - if an I/O error occurs
    • parseCommaSeparatedList

      private static void parseCommaSeparatedList(String string, Collection results)
      Parses a comma separated list, entering each value into the results Collection. Trailing empty strings are included in the results Collection.
      Parameters:
      string - string to parse
      results - Collection to which each value will be added
    • printUsageAndExit

      private static void printUsageAndExit()
    • replaceInAllFiles

      private static void replaceInAllFiles(File dir) throws IOException
      Applies the necessary replacements to all files in the given directory. Subdirectories are processed recursively.
      Parameters:
      dir - diretory containing files to replace
      Throws:
      IOException - if an I/O error occurs
    • replaceInFile

      private static void replaceInFile(File file) throws IOException
      Applies replacements to a single file.
      Parameters:
      file - the file to process
      Throws:
      IOException
    • applyJCasRefactoring

      private static String applyJCasRefactoring(String contents)
    • removeDuplicateImports

      private static String removeDuplicateImports(String contents)
      Remove duplicate imports from a Java source file.
    • checkForManualAttentionNeeded

      private static void checkForManualAttentionNeeded(File file, String contents)
      Scans for certain patterns in the string that indicate situations that the migration tool doesn't resolve and may require user attention. Updated the filesNeedingManualAttention field with a String which is the file path plus the reason the file was flagged.
      Parameters:
      contents - string to scan
    • readMapping

      private static void readMapping(String fileName, List mappings, boolean treatAsPackageNames) throws IOException
      Reads a mapping from a resource file, and populates a List of Replacement objects. We don't use a Map because the order in which the replacements are applied can be important.
      Parameters:
      fileName - name of file to read from (looked up looking using Class.getResource())
      mappings - List to which Replacement objects will be added. Each object contains the regex to search for and the replacement string.
      treatAsPackageNames - if true, the keys in the resource file will be considered package names, and this routine will produce regexes that replace any fully-qualified class name belonging to that package. Also in this case updates the static ibmPackageNames HashSet.
      Throws:
      IOException