Class PackageRenamer


  • public class PackageRenamer
    extends java.lang.Object
    This class performs package renaming. It demonstrates the following: a) Reading the properties file to be a reference for changing the package name from your source code. b) Traverse source root directory for creating a corresponding output directory and finding the java source file(s) to be changing the package name. c) Search and replace the old TopLink package name(s) with new one(s) according to the reference. You will be able to see the logging message at the command line window where the PackageRenamer is running.
    • Constructor Summary

      Constructors 
      Constructor Description
      PackageRenamer​(java.lang.String sourceFolder, java.lang.String targetFolder, java.util.Properties properties)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void binaryCopy​(java.io.File inFile, java.io.File outFile)
      Do a binary copy of the file byte buffer by byte buffer.
      java.io.File buildAndCheckDestinationFile​(java.lang.String aDirString)  
      java.io.File buildAndCheckExistingDirFile​(java.lang.String aDirString)  
      static boolean directoryIsSubdirectory​(java.io.File directory1, java.io.File directory2)
      Return true if directory2 is contained within directory1.
      java.util.List<java.io.File> getIgnoreFiles()  
      java.util.List<RenameValue> getRenameValues()  
      boolean isExtensionSupported​(java.lang.String extension)
      Return true if the PackageRenamer should work on the given file extension.
      protected static java.lang.String parseFileExtension​(java.lang.String fileName)
      Returns the extension of the given file.
      java.lang.String renameFile​(java.lang.String source)  
      void run()
      This run() method performs, reading the properties file into properties variable to be a reference for changing package name. creating an destination-root-direetory. and, calling traverseSourceDirectory() method.
      void runSearchAndReplacePackageName​(java.io.File sourceFile)
      This runSearchAndReplacePackageName() reads an pre-rename source file all into string variable and replacing the old package names with the new ones according to the properties file.
      void traverseSourceDirectory​(java.io.File directory)
      This traverseSourceDirectory() traverse source-root-directory, creating an corresponding output directory, and calling another method for replacing old TopLink package name.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PackageRenamer

        public PackageRenamer​(java.lang.String sourceFolder,
                              java.lang.String targetFolder,
                              java.util.Properties properties)
    • Method Detail

      • getIgnoreFiles

        public java.util.List<java.io.File> getIgnoreFiles()
      • getRenameValues

        public java.util.List<RenameValue> getRenameValues()
      • binaryCopy

        public void binaryCopy​(java.io.File inFile,
                               java.io.File outFile)
                        throws java.io.FileNotFoundException,
                               java.io.IOException
        Do a binary copy of the file byte buffer by byte buffer.
        Throws:
        java.io.FileNotFoundException
        java.io.IOException
      • buildAndCheckDestinationFile

        public java.io.File buildAndCheckDestinationFile​(java.lang.String aDirString)
      • buildAndCheckExistingDirFile

        public java.io.File buildAndCheckExistingDirFile​(java.lang.String aDirString)
      • parseFileExtension

        protected static java.lang.String parseFileExtension​(java.lang.String fileName)
        Returns the extension of the given file. Returns and empty string if none was found.
      • directoryIsSubdirectory

        public static boolean directoryIsSubdirectory​(java.io.File directory1,
                                                      java.io.File directory2)
        Return true if directory2 is contained within directory1. Both directories must be absolute.
      • isExtensionSupported

        public boolean isExtensionSupported​(java.lang.String extension)
        Return true if the PackageRenamer should work on the given file extension.
      • run

        public void run()
        This run() method performs, reading the properties file into properties variable to be a reference for changing package name. creating an destination-root-direetory. and, calling traverseSourceDirectory() method.
      • runSearchAndReplacePackageName

        public void runSearchAndReplacePackageName​(java.io.File sourceFile)
        This runSearchAndReplacePackageName() reads an pre-rename source file all into string variable and replacing the old package names with the new ones according to the properties file.
      • renameFile

        public java.lang.String renameFile​(java.lang.String source)
      • traverseSourceDirectory

        public void traverseSourceDirectory​(java.io.File directory)
        This traverseSourceDirectory() traverse source-root-directory, creating an corresponding output directory, and calling another method for replacing old TopLink package name.