Package org.apache.uima.tools.migration
Class IbmUimaToApacheUima
java.lang.Object
org.apache.uima.tools.migration.IbmUimaToApacheUima
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).
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Pattern
private static Set
private static int
private static List
private static int
private static final Pattern
private static final Pattern
private static Set
private static final Pattern
private static int
private static final Pattern
private static List
private static final Pattern
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static String
applyJCasRefactoring
(String contents) 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.static void
Main program.private static void
parseCommaSeparatedList
(String string, Collection results) Parses a comma separated list, entering each value into the results Collection.private static void
private static void
readMapping
(String fileName, List mappings, boolean treatAsPackageNames) Reads a mapping from a resource file, and populates a List of Replacement objects.private static String
removeDuplicateImports
(String contents) Remove duplicate imports from a Java source file.private static void
replaceInAllFiles
(File dir) Applies the necessary replacements to all files in the given directory.private static void
replaceInFile
(File file) Applies replacements to a single file.
-
Field Details
-
replacements
-
MAX_FILE_SIZE
private static int MAX_FILE_SIZE -
extensions
-
filesScanned
private static int filesScanned -
filesModified
private static int filesModified -
filesNeedingManualAttention
-
ibmPackageNames
-
IMPORT_PATTERN
-
CLASS_NAME_PATTERN
-
GET_NEXT_INDEX_PATTERN
-
THROW_FEAT_MISSING_PATTERN
-
PACKAGE_PATTERN
-
GETDOCANNOT_PATTERN
-
-
Constructor Details
-
IbmUimaToApacheUima
public IbmUimaToApacheUima()
-
-
Method Details
-
main
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
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 parseresults
- Collection to which each value will be added
-
printUsageAndExit
private static void printUsageAndExit() -
replaceInAllFiles
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
Applies replacements to a single file.- Parameters:
file
- the file to process- Throws:
IOException
-
applyJCasRefactoring
-
removeDuplicateImports
Remove duplicate imports from a Java source file. -
checkForManualAttentionNeeded
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
-