*******************************************************************************/
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";
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;
}
/**
- * 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);
}
}
- // 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);
* 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")]
* <li>
*
* <pre>
- * input string = "abc\ndef\tghi",
- * indent = 3
- * result = "\"\t\t\tabc\\n" +
- * "\t\t\tdef\tghi\""
+ * input string = "abc\ndef\tghi",
+ * indent = 3
+ * result = "\"\t\t\tabc\\n" +
+ * "\t\t\tdef\tghi\""
* </pre>
*
* </li>
* <li>
*
* <pre>
- * input string = "abc\ndef\tghi\n",
- * indent = 3
- * result = "\"\t\t\tabc\\n" +
- * "\t\t\tdef\tghi\\n\""
+ * input string = "abc\ndef\tghi\n",
+ * indent = 3
+ * result = "\"\t\t\tabc\\n" +
+ * "\t\t\tdef\tghi\\n\""
* </pre>
*
* </li>
* <li>
*
* <pre>
- * input string = "abc\r\ndef\tghi\r\n",
- * indent = 3
- * result = "\"\t\t\tabc\\r\\n" +
- * "\t\t\tdef\tghi\\r\\n\""
+ * input string = "abc\r\ndef\tghi\r\n",
+ * indent = 3
+ * result = "\"\t\t\tabc\\r\\n" +
+ * "\t\t\tdef\tghi\\r\\n\""
* </pre>
*
* </li>
* </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("\"");
* [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.");
/**
* 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;
} 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") };
}
}
}
/**
- * 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");
* 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) {