001package Torello.Java.Build; 002 003import Torello.JavaDoc.LinkJavaSource; 004import Torello.Java.StrCmpr; 005import java.io.IOException; 006 007/** 008 * A very basic utility for ensuring that the Java Doc Comment portion of a source-file does not 009 * exceed a maximum line-length. 010 * 011 * <BR /><BR /> 012 * <EMBED CLASS='external-html' DATA-FILE-ID=LINT> 013 * <EMBED CLASS='external-html' DATA-FILE-ID=RELATED_UTIL_NOTE> 014 */ 015public class Lint 016{ 017 private Lint() { } 018 019 020 // ******************************************************************************************** 021 // ******************************************************************************************** 022 // MAIN COMMAND-LINE METHOD 023 // ******************************************************************************************** 024 // ******************************************************************************************** 025 026 027 private static final String man_page = '\n' + 028 "\tjava Torello.Java.Lint 1 <Java-Source-File>\n" + 029 "\tjava Torello.Java.Lint 1 INNERCLASS <Java-Source-File>\n" + 030 "\tjava Torello.Java.Lint 2 <external-html-directory> (replaces ' * ' and {@code })\n" + 031 "\tjava Torello.Java.Lint 3 <external-html-directory> (line-length checker)\n"; 032 033 /** 034 * This class' operations are all performed via the command line. It asks questions of the 035 * user from the command line, and lints the Java Doc Comments parts of {@code '.java'} files 036 * to ensure that no line comment line is longer than 100 characters. This class is probably 037 * not too useful - <I>outside of the Java HTML Library!</I> It did help me make all of my 038 * source-code files look nice when you click on the "Hi-Lited Source Code" links. 039 */ 040 public static void main(String[] argv) throws IOException 041 { 042 if ( ((argv.length < 2) || (argv.length > 3)) 043 || StrCmpr.equalsNAND(argv[0], "1", "2", "3") 044 ) 045 System.out.println(man_page); 046 047 else if (argv[0].equals("1")) // Java Doc Linter 048 { 049 if (argv.length == 2) lint(argv[1]); 050 else 051 { 052 if (! argv[1].equals("INNERCLASS")) 053 { 054 System.out.println(man_page); 055 System.exit(0); 056 } 057 058 JavaDocLineLengths.prepareForInnerClass(); 059 060 lint(argv[2]); 061 } 062 } 063 064 else if (argv[0].equals("2")) // External-HTML File Linter 065 externalHTML(argv[1]); 066 067 else if (argv[0].equals("3")) // External-HTML File Linter 068 lineLengthChecker(argv[1]); 069 070 else System.out.println(man_page); 071 } 072 073 074 // ******************************************************************************************** 075 // ******************************************************************************************** 076 // Java Doc Comments Linter 077 // ******************************************************************************************** 078 // ******************************************************************************************** 079 080 081 /** 082 * Performs a 'LINT' on the input Java Source Code File. 083 * 084 * @param inFileOrDir This is any file or directory. If this is a directory, the entire 085 * directory will be scanned for {@code '.java'} source-files. If this is a file, then it 086 * will be the only file that is linted. 087 * 088 * @throws FileNotFoundException If this file or directory is not found. 089 */ 090 @LinkJavaSource(handle="JavaDocLineLengths") 091 public static void lint(String inFileOrDir) throws IOException 092 { JavaDocLineLengths.lint(inFileOrDir); } 093 094 095 // ******************************************************************************************** 096 // ******************************************************************************************** 097 // External HTML File Converter 098 // ******************************************************************************************** 099 // ******************************************************************************************** 100 101 102 /** 103 * This can be a really great tool for transitioning a Source-File to use External-HTML Files. 104 * This method merely scans an HTML-File for items that need to be escaped or converted to 105 * constructs that are usable in {@code '.html'} rather than {@code '.java'} files. 106 * 107 * @param directoryName The name of a directory containing {@code '.html'} files. 108 */ 109 @LinkJavaSource(handle="ExternalHTML") 110 public static void externalHTML(String directoryName) throws IOException 111 { ExternalHTML.cleanIt(directoryName); } 112 113 114 // ******************************************************************************************** 115 // ******************************************************************************************** 116 // CHECKS FOR '.java' FILES WITH LONG LINE LENGTHS 117 // ******************************************************************************************** 118 // ******************************************************************************************** 119 120 121 /** 122 * This method will scan an entire directory for {@code '.java'} files, and then report if 123 * there are any lines in each of those files whose length is greater than 100. 124 * 125 * <BR /><BR />While not exactly a great tool for all developers, during the development of 126 * Java HTML, this has been (on occasion) extremely useful. 127 * 128 * @param directoryName The name of the directory to be scanned for {@code '.java'} files. 129 */ 130 @LinkJavaSource(handle="LineLengths") 131 public static void lineLengthChecker(String directoryName) throws IOException 132 { LineLengths.check(directoryName); } 133 134}