A massive organize imports and formatting of the sources using default Eclipse code...
[phpeclipse.git] / net.sourceforge.phpeclipse.tests / src / net / sourceforge / phpdt / core / tests / util / Util.java
index 5c91332..5316029 100644 (file)
  *******************************************************************************/
 package net.sourceforge.phpdt.core.tests.util;
 
-import java.io.*;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintWriter;
 import java.net.ServerSocket;
-import java.util.Locale;
-import java.util.Map;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
 
-// import net.sourceforge.phpdt.core.tests.compiler.regression.Requestor;
-import net.sourceforge.phpdt.internal.compiler.Compiler;
-import net.sourceforge.phpdt.internal.compiler.IErrorHandlingPolicy;
-import net.sourceforge.phpdt.internal.compiler.IProblemFactory;
 import net.sourceforge.phpdt.internal.compiler.batch.CompilationUnit;
-// import net.sourceforge.phpdt.internal.compiler.batch.FileSystem;
-import net.sourceforge.phpdt.internal.compiler.env.INameEnvironment;
-import net.sourceforge.phpdt.internal.compiler.problem.DefaultProblemFactory;
 
 public class Util {
        public static String OUTPUT_DIRECTORY = "comptest";
@@ -34,7 +28,8 @@ public class Util {
                CompilationUnit[] result = new CompilationUnit[length];
                int index = 0;
                for (int i = 0; i < length; i++) {
-                       result[i] = new CompilationUnit(testFiles[index + 1].toCharArray(), testFiles[index], null);
+                       result[i] = new CompilationUnit(testFiles[index + 1].toCharArray(),
+                                       testFiles[index], null);
                        index += 2;
                }
                return result;
@@ -71,8 +66,8 @@ public class Util {
        }
 
        /**
-        * Copy the given source (a file or a directory that must exists) to the given
-        * destination (a directory that must exists).
+        * Copy the given source (a file or a directory that must exists) to the
+        * given destination (a directory that must exists).
         */
        public static void copy(String sourcePath, String destPath) {
                sourcePath = toNativePath(sourcePath);
@@ -136,7 +131,8 @@ public class Util {
                }
        }
 
-       // public static void createJar(String[] pathsAndContents, Map options, String
+       // public static void createJar(String[] pathsAndContents, Map options,
+       // String
        // jarPath) throws IOException {
        // String classesPath = getOutputDirectory() + File.separator + "classes";
        // File classesDir = new File(classesPath);
@@ -148,7 +144,7 @@ public class Util {
         * Generate a display string from the given String.
         * 
         * @param indent
-        *          number of tabs are added at the begining of each line.
+        *            number of tabs are added at the begining of each line.
         * 
         * Example of use:
         * [org.eclipse.jdt.core.tests.util.Util.displayString("abc\ndef\tghi")]
@@ -176,30 +172,30 @@ public class Util {
         * <li>
         * 
         * <pre>
-        *  input string = &quot;abc\ndef\tghi&quot;,
-        *  indent = 3
-        *  result = &quot;\&quot;\t\t\tabc\\n&quot; +
-        *                      &quot;\t\t\tdef\tghi\&quot;&quot;
+        *   input string = &quot;abc\ndef\tghi&quot;,
+        *   indent = 3
+        *   result = &quot;\&quot;\t\t\tabc\\n&quot; +
+        *                      &quot;\t\t\tdef\tghi\&quot;&quot;
         * </pre>
         * 
         * </li>
         * <li>
         * 
         * <pre>
-        *  input string = &quot;abc\ndef\tghi\n&quot;,
-        *  indent = 3
-        *  result = &quot;\&quot;\t\t\tabc\\n&quot; +
-        *                      &quot;\t\t\tdef\tghi\\n\&quot;&quot;
+        *   input string = &quot;abc\ndef\tghi\n&quot;,
+        *   indent = 3
+        *   result = &quot;\&quot;\t\t\tabc\\n&quot; +
+        *                      &quot;\t\t\tdef\tghi\\n\&quot;&quot;
         * </pre>
         * 
         * </li>
         * <li>
         * 
         * <pre>
-        *  input string = &quot;abc\r\ndef\tghi\r\n&quot;,
-        *  indent = 3
-        *  result = &quot;\&quot;\t\t\tabc\\r\\n&quot; +
-        *                      &quot;\t\t\tdef\tghi\\r\\n\&quot;&quot;
+        *   input string = &quot;abc\r\ndef\tghi\r\n&quot;,
+        *   indent = 3
+        *   result = &quot;\&quot;\t\t\tabc\\r\\n&quot; +
+        *                      &quot;\t\t\tdef\tghi\\r\\n\&quot;&quot;
         * </pre>
         * 
         * </li>
@@ -207,16 +203,17 @@ public class Util {
         * </p>
         * 
         * @param inputString
-        *          the given input string
+        *            the given input string
         * @param indent
-        *          number of tabs are added at the begining of each line.
+        *            number of tabs are added at the begining of each line.
         * 
         * @return the displayed string
         */
        public static String displayString(String inputString, int indent) {
                int length = inputString.length();
                StringBuffer buffer = new StringBuffer(length);
-               java.util.StringTokenizer tokenizer = new java.util.StringTokenizer(inputString, "\n\r", true);
+               java.util.StringTokenizer tokenizer = new java.util.StringTokenizer(
+                               inputString, "\n\r", true);
                for (int i = 0; i < indent; i++)
                        buffer.append("\t");
                buffer.append("\"");
@@ -302,7 +299,8 @@ public class Util {
         * [org.eclipse.jdt.core.tests.util.Util.fileContentToDisplayString("c:/temp/X.java",
         * 0)]
         */
-       public static String fileContentToDisplayString(String sourceFilePath, int indent, boolean independantLineDelimiter) {
+       public static String fileContentToDisplayString(String sourceFilePath,
+                       int indent, boolean independantLineDelimiter) {
                File sourceFile = new File(sourceFilePath);
                if (!sourceFile.exists()) {
                        System.out.println("File " + sourceFilePath + " does not exists.");
@@ -346,16 +344,18 @@ public class Util {
 
        /**
         * Reads the content of the given source file, converts it to a display
-        * string. If the destination file path is not null, writes the result to this
-        * file. Otherwise writes it to the console.
+        * string. If the destination file path is not null, writes the result to
+        * this file. Otherwise writes it to the console.
         * 
         * Example of use:
         * [org.eclipse.jdt.core.tests.util.Util.fileContentToDisplayString("c:/temp/X.java",
         * 0, null)]
         */
-       public static void fileContentToDisplayString(String sourceFilePath, int indent, String destinationFilePath,
+       public static void fileContentToDisplayString(String sourceFilePath,
+                       int indent, String destinationFilePath,
                        boolean independantLineDelimiter) {
-               String displayString = fileContentToDisplayString(sourceFilePath, indent, independantLineDelimiter);
+               String displayString = fileContentToDisplayString(sourceFilePath,
+                               indent, independantLineDelimiter);
                if (destinationFilePath == null) {
                        System.out.println(displayString);
                        return;
@@ -395,13 +395,16 @@ public class Util {
                } else {
                        final String vmName = System.getProperty("java.vm.name");
                        if ("J9".equals(vmName)) {
-                               return new String[] { toNativePath(jreDir + "/lib/jclMax/classes.zip") };
+                               return new String[] { toNativePath(jreDir
+                                               + "/lib/jclMax/classes.zip") };
                        } else {
                                File file = new File(jreDir + "/lib/rt.jar");
                                if (file.exists()) {
                                        return new String[] { toNativePath(jreDir + "/lib/rt.jar") };
                                } else {
-                                       return new String[] { toNativePath(jreDir + "/lib/core.jar"), toNativePath(jreDir + "/lib/security.jar"),
+                                       return new String[] {
+                                                       toNativePath(jreDir + "/lib/core.jar"),
+                                                       toNativePath(jreDir + "/lib/security.jar"),
                                                        toNativePath(jreDir + "/lib/graphics.jar") };
                                }
                        }
@@ -429,10 +432,11 @@ public class Util {
        }
 
        /**
-        * Search the user hard-drive for a possible output directory. Returns null if
-        * none could be found.
+        * Search the user hard-drive for a possible output directory. Returns null
+        * if none could be found.
         * 
-        * Example of use: [org.eclipse.jdt.core.tests.util.Util.getOutputDirectory()]
+        * Example of use:
+        * [org.eclipse.jdt.core.tests.util.Util.getOutputDirectory()]
         */
        public static String getOutputDirectory() {
                String container = System.getProperty("user.home");
@@ -470,8 +474,11 @@ public class Util {
         * File.getPath() and trimming any extra slash.
         */
        public static String toNativePath(String path) {
-               String nativePath = path.replace('\\', File.separatorChar).replace('/', File.separatorChar);
-               return nativePath.endsWith("/") || nativePath.endsWith("\\") ? nativePath.substring(0, nativePath.length() - 1) : nativePath;
+               String nativePath = path.replace('\\', File.separatorChar).replace('/',
+                               File.separatorChar);
+               return nativePath.endsWith("/") || nativePath.endsWith("\\") ? nativePath
+                               .substring(0, nativePath.length() - 1)
+                               : nativePath;
        }
 
        public static void writeToFile(String contents, String destinationFilePath) {