SoftNet-Consult Java Utility Library

com.softnetConsult.utils.reflect
Class ClassFileVersionTool

java.lang.Object
  extended by com.softnetConsult.utils.reflect.ClassFileVersionTool

public class ClassFileVersionTool
extends java.lang.Object

This class implements a small executable tool that can analyse a Java class file, a directory, or a Java archive (JAR or ZIP) and print version information for Java class binaries found. This tool uses the library methods SystemTools.getClassVersionInfo(File) and ClassTools.getClassVersionInfo(InputStream) for the actual parsing of Java class binaries.
For usage and command line arguments, see printUsage() and main(String[]).

This product includes software developed by the SoftNet-Consult Java Utility Library project and its contributors.
(http://java-tools.sourceforge.net)
Copyright (c) 2007-2008 SoftNet-Consult.
Copyright (c) 2007-2008 G. Paperin.
All rights reserved.

File: ClassFileVersionTool.java
Library API version: "2.02"
Java compliance version: "1.5"

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following terms and conditions are met:

1. Redistributions of source code must retain the above acknowledgement of the SoftNet-Consult Java Utility Library project, the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above acknowledgement of the SoftNet-Consult Java Utility Library project, the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software or any derived software must display the following acknowledgement:
This product includes software developed by the SoftNet-Consult Java Utility Library project and its contributors.

THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Version:
"2.02"
Author:
Greg Paperin (http://www.paperin.org)

Constructor Summary
ClassFileVersionTool()
           
 
Method Summary
static void exec(java.lang.String path, boolean recursive)
          The actual main program.
static void main(java.lang.String[] args)
          This executable program prints version information about all Java class files within a specified subdirectory.
private static void printInfo(java.lang.String name, ClassVersionInfo info, ScreenFileLogger out)
          Prints version info for a class binary in a nice looing way.
private static void printUsage()
          Used internally to print detailed information about the command line parameters.
private static void procClass(java.io.File classfile, ScreenFileLogger out)
          Analyses the specified Java binary and prints its version info.
private static void procDir(java.io.File dir, boolean recursive, ScreenFileLogger out)
          Analyses the specified directory and prints the version info for all Java class files contained therein.
private static void procZip(java.io.File archive, ScreenFileLogger out)
          Analyses the specified archive and prints the version info for all Java class files contained therein.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassFileVersionTool

public ClassFileVersionTool()
Method Detail

printInfo

private static void printInfo(java.lang.String name,
                              ClassVersionInfo info,
                              ScreenFileLogger out)
Prints version info for a class binary in a nice looing way.

Parameters:
name - File name of class file.
info - Version info.
out - The indenting screen logger to use for all output.

procClass

private static void procClass(java.io.File classfile,
                              ScreenFileLogger out)
Analyses the specified Java binary and prints its version info.

Parameters:
classfile - The class binary to analyse.
out - The indenting screen logger to use for all output.

procZip

private static void procZip(java.io.File archive,
                            ScreenFileLogger out)
Analyses the specified archive and prints the version info for all Java class files contained therein.

Parameters:
archive - The archive to analyse.
out - The indenting screen logger to use for all output.

procDir

private static void procDir(java.io.File dir,
                            boolean recursive,
                            ScreenFileLogger out)
Analyses the specified directory and prints the version info for all Java class files contained therein.

Parameters:
dir - The directory to analyse.
recursive - Whther to recursively analyse subdirectories and archived contained therein. Anchives within archives are not analysed.
out - The indenting screen logger to use for all output.

exec

public static void exec(java.lang.String path,
                        boolean recursive)
The actual main program. Analyses the specified path and prints the version info for all Java class files contained therein.

Parameters:
path - A path of a class binary, a directory or a Java archive (ZIP or JAR).
recursive - Whther to recursively analyse subdirectories and archived contained therein. Anchives within archives are not analysed.

printUsage

private static void printUsage()
Used internally to print detailed information about the command line parameters.


main

public static void main(java.lang.String[] args)
This executable program prints version information about all Java class files within a specified subdirectory.

Parameters:
args - Command line parameters:
1. (optional) -R to request recursive analysis of all subdirectories.
2. Path of a Java class binary, directory or archive to analyse.
For futher info on the command line parameters, see printUsage().

SoftNet-Consult Java Utility Library is a member of SourceForge.net