public class PackageRenamer
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
PackageRenamer.PackageRenamerException |
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
SYSTEM_OUT |
Constructor and Description |
---|
PackageRenamer()
The constructor of a PackageRenamer class.
|
PackageRenamer(java.lang.String propertiesFileName) |
PackageRenamer(java.lang.String[] args) |
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
bannerText() |
void |
binaryCopy(java.io.File inFile,
java.io.File outFile)
Do a binary copy of the file byte buffer by byte buffer.
|
protected boolean |
bufferContainsNullChar(byte[] buffer,
int bufferLength) |
java.io.File |
buildAndCheckDestinationFile(java.lang.String aDirString)
INTERNAL Creates a destination directory File object under the path
passed, verifying correctness.
|
java.io.File |
buildAndCheckExistingDirFile(java.lang.String aDirString) |
java.io.PrintWriter |
buildAndCheckLogWriter(java.lang.String logFileString) |
protected void |
cleanup() |
void |
createDestinationDirectory(java.io.File aDirectory)
This method creates an output directory for post-rename file(s).
|
static boolean |
directoryIsSubdirectory(java.io.File directory1,
java.io.File directory2)
Return true if directory2 is contained within directory1.
|
java.io.File |
existingDirectoryFromPrompt() |
static java.lang.String |
getDefaultPropertiesFileName() |
java.io.BufferedReader |
getReader() |
boolean |
isExtensionSupported(java.lang.String extension)
Return true if the PackageRenamer should work on the given file
extension.
|
void |
logln(java.lang.String str) |
static void |
main(java.lang.String[] args)
Main method to run the PackageRenamer
|
java.lang.String |
parseFileExtension(java.io.File aFile)
Returns the extension of the given file.
|
protected java.io.File |
promptForDestinationDirectory()
INTERNAL Prompt from System.in for an empty or non-existent directory to
use as the destination directory.
|
java.util.Properties |
readChangesFile(java.lang.String filename)
This readChangesFile() method reads the given properties file to be a
reference for renaming TopLink package name.
|
static java.lang.String |
replace(java.lang.String str,
java.lang.String oldChars,
java.lang.String newChars)
Do a search and replace in a string.
|
java.lang.String |
returnNewFileNameIfRequired(java.lang.String aSourceFileNameWithoutRoot)
Renames a file based on the properties passed.
|
void |
run()
This run() method performs,
reading the properties file into properties variable to be a reference for changing package name.
|
void |
runSearchAndReplacePackageName(java.io.File sourceFile)
This runSearchAndReplacePackageName() reads a pre-rename source file all
into string variable and replacing the old package names with the new
ones according to the properties file.
|
protected java.io.PrintWriter |
streamForNonExistentFilePrompt() |
void |
traverseSourceDirectory(java.io.File aDirectoryString)
This traverseSourceDirectory() traverse source-root-directory, creating
an corresponding output directory, and calling another method for
replacing old TopLink package name.
|
static void |
usage() |
protected static final java.lang.String SYSTEM_OUT
public PackageRenamer()
public PackageRenamer(java.lang.String propertiesFileName)
public PackageRenamer(java.lang.String[] args)
protected java.lang.String bannerText()
public void binaryCopy(java.io.File inFile, java.io.File outFile) throws java.io.FileNotFoundException, java.io.IOException
inFile
- The file to copyoutFile
- The destination filejava.io.FileNotFoundException
- if either of the two files does not existjava.io.IOException
- if any other IO related error occursprotected boolean bufferContainsNullChar(byte[] buffer, int bufferLength)
public java.io.File buildAndCheckDestinationFile(java.lang.String aDirString)
aDirString
- The path to the directory File object to createpublic java.io.File buildAndCheckExistingDirFile(java.lang.String aDirString)
public java.io.PrintWriter buildAndCheckLogWriter(java.lang.String logFileString)
protected void cleanup()
public void createDestinationDirectory(java.io.File aDirectory)
aDirectory
- The output directory to createpublic static boolean directoryIsSubdirectory(java.io.File directory1, java.io.File directory2)
directory1
- The higher level directorydirectory2
- The lower level directorypublic java.io.File existingDirectoryFromPrompt()
public static java.lang.String getDefaultPropertiesFileName()
public java.io.BufferedReader getReader()
public boolean isExtensionSupported(java.lang.String extension)
extension
- The file extension to check for being supportedpublic void logln(java.lang.String str)
str
- The String to logpublic static void main(java.lang.String[] args)
args
- Command line argumentspublic java.lang.String parseFileExtension(java.io.File aFile)
aFile
- The file of which to retrieve the extensionprotected java.io.File promptForDestinationDirectory()
public java.util.Properties readChangesFile(java.lang.String filename)
filename
- The input file to use for the renamingpublic void run()
protected java.io.PrintWriter streamForNonExistentFilePrompt()
public void runSearchAndReplacePackageName(java.io.File sourceFile)
sourceFile
- The source file to processpublic static java.lang.String replace(java.lang.String str, java.lang.String oldChars, java.lang.String newChars)
str
- The original StringoldChars
- The character pattern to replacenewChars
- The character pattern to replace the existing withpublic java.lang.String returnNewFileNameIfRequired(java.lang.String aSourceFileNameWithoutRoot)
aSourceFileNameWithoutRoot
- The original filenamepublic void traverseSourceDirectory(java.io.File aDirectoryString)
aDirectoryString
- The source root directory to traversepublic static void usage()