1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134 | package Torello.Java.Build;
import Torello.JavaDoc.LinkJavaSource;
import Torello.Java.StrCmpr;
import java.io.IOException;
/**
* A very basic utility for ensuring that the Java Doc Comment portion of a source-file does not
* exceed a maximum line-length.
*
* <BR /><BR />
* <EMBED CLASS='external-html' DATA-FILE-ID=LINT>
* <EMBED CLASS='external-html' DATA-FILE-ID=RELATED_UTIL_NOTE>
*/
public class Lint
{
private Lint() { }
// ********************************************************************************************
// ********************************************************************************************
// MAIN COMMAND-LINE METHOD
// ********************************************************************************************
// ********************************************************************************************
private static final String man_page = '\n' +
"\tjava Torello.Java.Lint 1 <Java-Source-File>\n" +
"\tjava Torello.Java.Lint 1 INNERCLASS <Java-Source-File>\n" +
"\tjava Torello.Java.Lint 2 <external-html-directory> (replaces ' * ' and {@code })\n" +
"\tjava Torello.Java.Lint 3 <external-html-directory> (line-length checker)\n";
/**
* This class' operations are all performed via the command line. It asks questions of the
* user from the command line, and lints the Java Doc Comments parts of {@code '.java'} files
* to ensure that no line comment line is longer than 100 characters. This class is probably
* not too useful - <I>outside of the Java HTML Library!</I> It did help me make all of my
* source-code files look nice when you click on the "Hi-Lited Source Code" links.
*/
public static void main(String[] argv) throws IOException
{
if ( ((argv.length < 2) || (argv.length > 3))
|| StrCmpr.equalsNAND(argv[0], "1", "2", "3")
)
System.out.println(man_page);
else if (argv[0].equals("1")) // Java Doc Linter
{
if (argv.length == 2) lint(argv[1]);
else
{
if (! argv[1].equals("INNERCLASS"))
{
System.out.println(man_page);
System.exit(0);
}
JavaDocLineLengths.prepareForInnerClass();
lint(argv[2]);
}
}
else if (argv[0].equals("2")) // External-HTML File Linter
externalHTML(argv[1]);
else if (argv[0].equals("3")) // External-HTML File Linter
lineLengthChecker(argv[1]);
else System.out.println(man_page);
}
// ********************************************************************************************
// ********************************************************************************************
// Java Doc Comments Linter
// ********************************************************************************************
// ********************************************************************************************
/**
* Performs a 'LINT' on the input Java Source Code File.
*
* @param inFileOrDir This is any file or directory. If this is a directory, the entire
* directory will be scanned for {@code '.java'} source-files. If this is a file, then it
* will be the only file that is linted.
*
* @throws FileNotFoundException If this file or directory is not found.
*/
@LinkJavaSource(handle="JavaDocLineLengths")
public static void lint(String inFileOrDir) throws IOException
{ JavaDocLineLengths.lint(inFileOrDir); }
// ********************************************************************************************
// ********************************************************************************************
// External HTML File Converter
// ********************************************************************************************
// ********************************************************************************************
/**
* This can be a really great tool for transitioning a Source-File to use External-HTML Files.
* This method merely scans an HTML-File for items that need to be escaped or converted to
* constructs that are usable in {@code '.html'} rather than {@code '.java'} files.
*
* @param directoryName The name of a directory containing {@code '.html'} files.
*/
@LinkJavaSource(handle="ExternalHTML")
public static void externalHTML(String directoryName) throws IOException
{ ExternalHTML.cleanIt(directoryName); }
// ********************************************************************************************
// ********************************************************************************************
// CHECKS FOR '.java' FILES WITH LONG LINE LENGTHS
// ********************************************************************************************
// ********************************************************************************************
/**
* This method will scan an entire directory for {@code '.java'} files, and then report if
* there are any lines in each of those files whose length is greater than 100.
*
* <BR /><BR />While not exactly a great tool for all developers, during the development of
* Java HTML, this has been (on occasion) extremely useful.
*
* @param directoryName The name of the directory to be scanned for {@code '.java'} files.
*/
@LinkJavaSource(handle="LineLengths")
public static void lineLengthChecker(String directoryName) throws IOException
{ LineLengths.check(directoryName); }
}
|