import java.io.File;
import java.io.FileOutputStream;
-import java.io.FilenameFilter;
import java.io.FileInputStream;
import java.util.zip.ZipEntry;
import java.util.jar.JarOutputStream;
/**
* This class manages the build of the Java Help
*/
-public class BuildJavaHelp {
+public final class BuildJavaHelp {
+
+ private static final String JAVAHELPSEARCH_DIR = "/JavaHelpSearch/";
+ private static final String COULD_NOT_FIND = "buildDoc: Could not find/access to ";
+ private static final String LEFT_PAR = " ( ";
+ private static final String RIGHT_PAR = " )";
+
+ /**
+ * Default constructor (must no be used)
+ */
+ private BuildJavaHelp() {
+ throw new UnsupportedOperationException();
+ }
+ /**
+ * Get the list of the files in a directory
+ * @param directory the directory where files have to be searched
+ * @return teh list of the files found
+ */
private static ArrayList<File> buildFileList(File directory) {
ArrayList<File> listFile = new ArrayList<File>();
if (files[i].isDirectory()) {
listFile.addAll(buildFileList(files[i]));
- }else{
+ } else {
listFile.add(files[i]);
}
}
jarFile = new JarOutputStream(fileOutputStream);
} catch (java.io.FileNotFoundException e) {
- System.err.println("buildDoc: Could not find/access to " + fileName + " ( " + e.getLocalizedMessage() + " )");
+ System.err.println(COULD_NOT_FIND + fileName + LEFT_PAR + e.getLocalizedMessage() + RIGHT_PAR);
} catch (java.io.IOException e) {
- System.err.println("buildDoc: Could not find/access to " + fileName + " ( " + e.getLocalizedMessage() + " )");
+ System.err.println(COULD_NOT_FIND + fileName + LEFT_PAR + e.getLocalizedMessage() + RIGHT_PAR);
}
jarFile.setLevel(compressionLevel);
- ArrayList<File> fileList=BuildJavaHelp.buildFileList(new File(outputDirectory));
+ ArrayList<File> fileList = BuildJavaHelp.buildFileList(new File(outputDirectory));
File []allFiles = fileList.toArray(new File [fileList.size()]);
for (int i = 0; i < allFiles.length; i++) {
try {
try {
fileInputStream.read(buffer, 0, length);
} catch (java.io.IOException e) {
- System.err.println("buildDoc: Could not find/access to " + workingFile + " ( " + e.getLocalizedMessage() + " )");
+ System.err.println(COULD_NOT_FIND + workingFile + LEFT_PAR + e.getLocalizedMessage() + RIGHT_PAR);
}
- String relativeFileName=null;
+ String relativeFileName = null;
if (workingFile.getPath().indexOf("JavaHelpSearch") == -1) {
relativeFileName = baseName + "/" + workingFile.getName();
} else {
- relativeFileName = baseName + "/JavaHelpSearch/" + workingFile.getName();
+ relativeFileName = baseName + JAVAHELPSEARCH_DIR + workingFile.getName();
}
ZipEntry zipEntry = new ZipEntry(relativeFileName);
jarFile.putNextEntry(zipEntry);
fileInputStream.close();
} catch (java.io.IOException e) {
- System.err.println("buildDoc: An error occurs while building the JavaHelp ( " + e.getLocalizedMessage() + " )");
+ System.err.println("buildDoc: An error occurs while building the JavaHelp ( " + e.getLocalizedMessage() + RIGHT_PAR);
}
}
try {
jarFile.close();
} catch (java.io.IOException e) {
- System.err.println("buildDoc: An error occurs while closing the JavaHelp ( " + e.getLocalizedMessage() + " )");
+ System.err.println("buildDoc: An error occurs while closing the JavaHelp ( " + e.getLocalizedMessage() + RIGHT_PAR);
}
return true;
}
try {
String[] args = new String[] {
"-db",
- outputDirectory + "/JavaHelpSearch/", /* Where the Java Help Index should be created */
+ outputDirectory + JAVAHELPSEARCH_DIR, /* Where the Java Help Index should be created */
outputDirectory
};
indexer.compile(args);