Scilab checkstyle compatibility
Vincent Couvert [Thu, 28 Aug 2008 09:42:40 +0000 (09:42 +0000)]
scilab/modules/helptools/src/java/org/scilab/modules/helptools/BuildJavaHelp.java

index cd8517a..2b5b077 100644 (file)
@@ -15,7 +15,6 @@ import com.sun.java.help.search.Indexer; /* jhall (Java Help) */
 
 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;
@@ -25,8 +24,25 @@ import java.util.ArrayList;
 /**
  * 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>();
 
@@ -35,7 +51,7 @@ public class BuildJavaHelp {
 
                        if (files[i].isDirectory()) {
                                listFile.addAll(buildFileList(files[i]));
-                       }else{
+                       } else {
                                listFile.add(files[i]);
                        }
                }
@@ -63,13 +79,13 @@ public class BuildJavaHelp {
                        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 {
@@ -81,13 +97,13 @@ public class BuildJavaHelp {
                                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);
@@ -96,14 +112,14 @@ public class BuildJavaHelp {
  
                                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;
        }
@@ -121,7 +137,7 @@ public class BuildJavaHelp {
                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);