Class JarIndexer


  • public class JarIndexer
    extends java.lang.Object
    Class which contains utility methods to create an index for a jar file
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private JarIndexer()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static void copy​(java.io.File dest, java.io.File source)  
      private static void copy​(java.io.InputStream in, java.io.OutputStream out)  
      static Result createJarIndex​(java.io.File jarFile, Indexer indexer, boolean modify, boolean newJar, boolean verbose)
      Indexes a jar file and saves the result.
      static Result createJarIndex​(java.io.File jarFile, Indexer indexer, boolean modify, boolean newJar, boolean verbose, java.io.PrintStream infoStream, java.io.PrintStream errStream)
      Indexes a jar file and saves the result.
      static Result createJarIndex​(java.io.File jarFile, Indexer indexer, java.io.File outputFile, boolean modify, boolean newJar, boolean verbose)
      Indexes a jar file and saves the result.
      static Result createJarIndex​(java.io.File jarFile, Indexer indexer, java.io.File outputFile, boolean modify, boolean newJar, boolean verbose, java.io.PrintStream infoStream, java.io.PrintStream errStream)
      Indexes a jar file and saves the result.
      private static java.io.File getIndexFile​(java.io.File jarFile, boolean newJar)  
      private static void printIndexEntryInfo​(ClassInfo info, java.io.PrintStream infoStream)  
      private static void safeClose​(java.io.Closeable close)  
      private static void safeClose​(java.util.jar.JarFile close)  
      • Methods inherited from class java.lang.Object

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

      • JarIndexer

        private JarIndexer()
    • Method Detail

      • getIndexFile

        private static java.io.File getIndexFile​(java.io.File jarFile,
                                                 boolean newJar)
      • createJarIndex

        public static Result createJarIndex​(java.io.File jarFile,
                                            Indexer indexer,
                                            boolean modify,
                                            boolean newJar,
                                            boolean verbose)
                                     throws java.io.IOException
        Indexes a jar file and saves the result. If the modify flag is set, index is saved to META-INF/jandex.idx. Otherwise an external file is created with a similar name to the original file, concatenating .idx suffix.
        Parameters:
        jarFile - The file to index
        indexer - The indexer to use
        modify - If the original jar should be modified
        newJar - If the new jar should be created
        verbose - If we should print what we are doing to standard out
        Returns:
        indexing result
        Throws:
        java.io.IOException - for any I/o error
      • createJarIndex

        public static Result createJarIndex​(java.io.File jarFile,
                                            Indexer indexer,
                                            java.io.File outputFile,
                                            boolean modify,
                                            boolean newJar,
                                            boolean verbose)
                                     throws java.io.IOException
        Indexes a jar file and saves the result. If the modify flag is set, index is saved to META-INF/jandex.idx. Otherwise an external file is created with a similar name to the original file, concatenating .idx suffix.
        Parameters:
        jarFile - The file to index
        indexer - The indexer to use
        outputFile - The index file to write to
        modify - If the original jar should be modified
        newJar - If the new jar should be created
        verbose - If we should print what we are doing to standard out
        Returns:
        indexing result
        Throws:
        java.io.IOException - for any I/o error
      • createJarIndex

        public static Result createJarIndex​(java.io.File jarFile,
                                            Indexer indexer,
                                            boolean modify,
                                            boolean newJar,
                                            boolean verbose,
                                            java.io.PrintStream infoStream,
                                            java.io.PrintStream errStream)
                                     throws java.io.IOException
        Indexes a jar file and saves the result. If the modify flag is set, index is saved to META-INF/jandex.idx. Otherwise an external file is created with a similar name to the original file, concatenating .idx suffix.
        Parameters:
        jarFile - The file to index
        indexer - The indexer to use
        modify - If the original jar should be modified
        newJar - If the new jar should be created
        verbose - If we should print what we are doing to the specified info stream
        infoStream - A print stream which will record verbose info, may be null
        errStream - A print stream to print errors, must not be null
        Returns:
        indexing result
        Throws:
        java.io.IOException - for any I/o error
      • createJarIndex

        public static Result createJarIndex​(java.io.File jarFile,
                                            Indexer indexer,
                                            java.io.File outputFile,
                                            boolean modify,
                                            boolean newJar,
                                            boolean verbose,
                                            java.io.PrintStream infoStream,
                                            java.io.PrintStream errStream)
                                     throws java.io.IOException
        Indexes a jar file and saves the result. If the modify flag is set, index is saved to META-INF/jandex.idx. Otherwise an external file is created with a similar name to the original file, concatenating .idx suffix.
        Parameters:
        jarFile - The file to index
        indexer - The indexer to use
        outputFile - The index file to write to
        modify - If the original jar should be modified
        newJar - If the new jar should be created
        verbose - If we should print what we are doing to the specified info stream
        infoStream - A print stream which will record verbose info, may be null 1
        errStream - A print stream to print errors, must not be null
        Returns:
        indexing result
        Throws:
        java.io.IOException - for any I/o error
      • copy

        private static void copy​(java.io.File dest,
                                 java.io.File source)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • printIndexEntryInfo

        private static void printIndexEntryInfo​(ClassInfo info,
                                                java.io.PrintStream infoStream)
      • copy

        private static void copy​(java.io.InputStream in,
                                 java.io.OutputStream out)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • safeClose

        private static void safeClose​(java.util.jar.JarFile close)
      • safeClose

        private static void safeClose​(java.io.Closeable close)