package net.sourceforge.phpdt.internal.core.util;
import java.io.BufferedInputStream;
-import java.io.DataInput;
-import java.io.EOFException;
+//import java.io.DataInput;
+//import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
-import java.io.OutputStream;
+//import java.io.OutputStream;
import java.io.PrintStream;
-import java.io.UTFDataFormatException;
+//import java.io.UTFDataFormatException;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
-import java.util.StringTokenizer;
+//import java.util.StringTokenizer;
import net.sourceforge.phpdt.core.IJavaElement;
import net.sourceforge.phpdt.core.IJavaModelStatusConstants;
import net.sourceforge.phpdt.core.JavaModelException;
import net.sourceforge.phpdt.core.Signature;
import net.sourceforge.phpdt.core.compiler.CharOperation;
-import net.sourceforge.phpdt.internal.compiler.ast.TypeReference;
+//import net.sourceforge.phpdt.internal.compiler.ast.TypeReference;
//incastrix
//import net.sourceforge.phpdt.internal.corext.Assert;
-import org.eclipse.core.runtime.Assert;
+//import org.eclipse.core.runtime.Assert;
//import net.sourceforge.phpdt.internal.core.PackageFragmentRoot;
import net.sourceforge.phpdt.internal.core.util.PHPFileUtil;
*
* @see #concat(String, String)
*/
- public static String concat(String s1, char c, String s2) {
- if (s1 == null)
- s1 = "null"; //$NON-NLS-1$
- if (s2 == null)
- s2 = "null"; //$NON-NLS-1$
- int l1 = s1.length();
- int l2 = s2.length();
- char[] buf = new char[l1 + 1 + l2];
- s1.getChars(0, l1, buf, 0);
- buf[l1] = c;
- s2.getChars(0, l2, buf, l1 + 1);
- return new String(buf);
- }
+// public static String concat(String s1, char c, String s2) {
+// if (s1 == null)
+// s1 = "null"; //$NON-NLS-1$
+// if (s2 == null)
+// s2 = "null"; //$NON-NLS-1$
+// int l1 = s1.length();
+// int l2 = s2.length();
+// char[] buf = new char[l1 + 1 + l2];
+// s1.getChars(0, l1, buf, 0);
+// buf[l1] = c;
+// s2.getChars(0, l2, buf, l1 + 1);
+// return new String(buf);
+// }
/**
* Concatenate two strings. Much faster than using +, which: - creates a
*
* @see #concat(String, String)
*/
- public static String concat(String s1, String s2, String s3) {
- if (s1 == null)
- s1 = "null"; //$NON-NLS-1$
- if (s2 == null)
- s2 = "null"; //$NON-NLS-1$
- if (s3 == null)
- s3 = "null"; //$NON-NLS-1$
- int l1 = s1.length();
- int l2 = s2.length();
- int l3 = s3.length();
- char[] buf = new char[l1 + l2 + l3];
- s1.getChars(0, l1, buf, 0);
- s2.getChars(0, l2, buf, l1);
- s3.getChars(0, l3, buf, l1 + l2);
- return new String(buf);
- }
+// public static String concat(String s1, String s2, String s3) {
+// if (s1 == null)
+// s1 = "null"; //$NON-NLS-1$
+// if (s2 == null)
+// s2 = "null"; //$NON-NLS-1$
+// if (s3 == null)
+// s3 = "null"; //$NON-NLS-1$
+// int l1 = s1.length();
+// int l2 = s2.length();
+// int l3 = s3.length();
+// char[] buf = new char[l1 + l2 + l3];
+// s1.getChars(0, l1, buf, 0);
+// s2.getChars(0, l2, buf, l1);
+// s3.getChars(0, l3, buf, l1 + l2);
+// return new String(buf);
+// }
/**
* Converts a type signature from the IBinaryType representation to the DC
* Returns true iff str.toLowerCase().endsWith(end.toLowerCase())
* implementation is not creating extra strings.
*/
- public final static boolean endsWithIgnoreCase(String str, String end) {
-
- int strLength = str == null ? 0 : str.length();
- int endLength = end == null ? 0 : end.length();
-
- // return false if the string is smaller than the end.
- if (endLength > strLength)
- return false;
-
- // return false if any character of the end are
- // not the same in lower case.
- for (int i = 1; i <= endLength; i++) {
- if (Character.toLowerCase(end.charAt(endLength - i)) != Character
- .toLowerCase(str.charAt(strLength - i)))
- return false;
- }
-
- return true;
- }
+// public final static boolean endsWithIgnoreCase(String str, String end) {
+//
+// int strLength = str == null ? 0 : str.length();
+// int endLength = end == null ? 0 : end.length();
+//
+// // return false if the string is smaller than the end.
+// if (endLength > strLength)
+// return false;
+//
+// // return false if any character of the end are
+// // not the same in lower case.
+// for (int i = 1; i <= endLength; i++) {
+// if (Character.toLowerCase(end.charAt(endLength - i)) != Character
+// .toLowerCase(str.charAt(strLength - i)))
+// return false;
+// }
+//
+// return true;
+// }
/**
* Compares two arrays using equals() on the elements. Either or both arrays
* null. If both are arrays, returns true iff they have the same length and
* all elements are equal.
*/
- public static boolean equalArraysOrNull(int[] a, int[] b) {
- if (a == b)
- return true;
- if (a == null || b == null)
- return false;
- int len = a.length;
- if (len != b.length)
- return false;
- for (int i = 0; i < len; ++i) {
- if (a[i] != b[i])
- return false;
- }
- return true;
- }
+// public static boolean equalArraysOrNull(int[] a, int[] b) {
+// if (a == b)
+// return true;
+// if (a == null || b == null)
+// return false;
+// int len = a.length;
+// if (len != b.length)
+// return false;
+// for (int i = 0; i < len; ++i) {
+// if (a[i] != b[i])
+// return false;
+// }
+// return true;
+// }
/**
* Compares two arrays using equals() on the elements. Either or both arrays
* elements compare true with equals. The original arrays are left
* untouched.
*/
- public static boolean equalArraysOrNullSortFirst(Comparable[] a,
- Comparable[] b) {
- if (a == b)
- return true;
- if (a == null || b == null)
- return false;
- int len = a.length;
- if (len != b.length)
- return false;
- if (len >= 2) { // only need to sort if more than two items
- a = sortCopy(a);
- b = sortCopy(b);
- }
- for (int i = 0; i < len; ++i) {
- if (!a[i].equals(b[i]))
- return false;
- }
- return true;
- }
+// public static boolean equalArraysOrNullSortFirst(Comparable[] a,
+// Comparable[] b) {
+// if (a == b)
+// return true;
+// if (a == null || b == null)
+// return false;
+// int len = a.length;
+// if (len != b.length)
+// return false;
+// if (len >= 2) { // only need to sort if more than two items
+// a = sortCopy(a);
+// b = sortCopy(b);
+// }
+// for (int i = 0; i < len; ++i) {
+// if (!a[i].equals(b[i]))
+// return false;
+// }
+// return true;
+// }
/**
* Compares two String arrays using equals() on the elements. The arrays are
* elements compare true with equals. The original arrays are left
* untouched.
*/
- public static boolean equalArraysOrNullSortFirst(String[] a, String[] b) {
- if (a == b)
- return true;
- if (a == null || b == null)
- return false;
- int len = a.length;
- if (len != b.length)
- return false;
- if (len >= 2) { // only need to sort if more than two items
- a = sortCopy(a);
- b = sortCopy(b);
- }
- for (int i = 0; i < len; ++i) {
- if (!a[i].equals(b[i]))
- return false;
- }
- return true;
- }
+// public static boolean equalArraysOrNullSortFirst(String[] a, String[] b) {
+// if (a == b)
+// return true;
+// if (a == null || b == null)
+// return false;
+// int len = a.length;
+// if (len != b.length)
+// return false;
+// if (len >= 2) { // only need to sort if more than two items
+// a = sortCopy(a);
+// b = sortCopy(b);
+// }
+// for (int i = 0; i < len; ++i) {
+// if (!a[i].equals(b[i]))
+// return false;
+// }
+// return true;
+// }
/**
* Compares two objects using equals(). Either or both array may be null.
* Returns true if both are null. Returns false if only one is null.
* Otherwise, return the result of comparing with equals().
*/
- public static boolean equalOrNull(Object a, Object b) {
- if (a == b) {
- return true;
- }
- if (a == null || b == null) {
- return false;
- }
- return a.equals(b);
- }
+// public static boolean equalOrNull(Object a, Object b) {
+// if (a == b) {
+// return true;
+// }
+// if (a == null || b == null) {
+// return false;
+// }
+// return a.equals(b);
+// }
/**
* Given a qualified name, extract the last component. If the input is not
* qualified, the same string is answered.
*/
- public static String extractLastName(String qualifiedName) {
- int i = qualifiedName.lastIndexOf('.');
- if (i == -1)
- return qualifiedName;
- return qualifiedName.substring(i + 1);
- }
+// public static String extractLastName(String qualifiedName) {
+// int i = qualifiedName.lastIndexOf('.');
+// if (i == -1)
+// return qualifiedName;
+// return qualifiedName.substring(i + 1);
+// }
/**
* Extracts the parameter types from a method signature.
*/
- public static String[] extractParameterTypes(char[] sig) {
- int count = getParameterCount(sig);
- String[] result = new String[count];
- if (count == 0)
- return result;
- int i = CharOperation.indexOf('(', sig) + 1;
- count = 0;
- int len = sig.length;
- int start = i;
- for (;;) {
- if (i == len)
- break;
- char c = sig[i];
- if (c == ')')
- break;
- if (c == '[') {
- ++i;
- } else if (c == 'L') {
- i = CharOperation.indexOf(';', sig, i + 1) + 1;
- Assert.isTrue(i != 0);
- result[count++] = convertTypeSignature(CharOperation.subarray(
- sig, start, i));
- start = i;
- } else {
- ++i;
- result[count++] = convertTypeSignature(CharOperation.subarray(
- sig, start, i));
- start = i;
- }
- }
- return result;
- }
+// public static String[] extractParameterTypes(char[] sig) {
+// int count = getParameterCount(sig);
+// String[] result = new String[count];
+// if (count == 0)
+// return result;
+// int i = CharOperation.indexOf('(', sig) + 1;
+// count = 0;
+// int len = sig.length;
+// int start = i;
+// for (;;) {
+// if (i == len)
+// break;
+// char c = sig[i];
+// if (c == ')')
+// break;
+// if (c == '[') {
+// ++i;
+// } else if (c == 'L') {
+// i = CharOperation.indexOf(';', sig, i + 1) + 1;
+// Assert.isTrue(i != 0);
+// result[count++] = convertTypeSignature(CharOperation.subarray(
+// sig, start, i));
+// start = i;
+// } else {
+// ++i;
+// result[count++] = convertTypeSignature(CharOperation.subarray(
+// sig, start, i));
+// start = i;
+// }
+// }
+// return result;
+// }
/**
* Extracts the return type from a method signature.
*/
- public static String extractReturnType(String sig) {
- int i = sig.lastIndexOf(')');
- Assert.isTrue(i != -1);
- return sig.substring(i + 1);
- }
+// public static String extractReturnType(String sig) {
+// int i = sig.lastIndexOf(')');
+// Assert.isTrue(i != -1);
+// return sig.substring(i + 1);
+// }
// private static IFile findFirstClassFile(IFolder folder) {
// try {
/**
* Returns the number of parameter types in a method signature.
*/
- public static int getParameterCount(char[] sig) {
- int i = CharOperation.indexOf('(', sig) + 1;
- Assert.isTrue(i != 0);
- int count = 0;
- int len = sig.length;
- for (;;) {
- if (i == len)
- break;
- char c = sig[i];
- if (c == ')')
- break;
- if (c == '[') {
- ++i;
- } else if (c == 'L') {
- ++count;
- i = CharOperation.indexOf(';', sig, i + 1) + 1;
- Assert.isTrue(i != 0);
- } else {
- ++count;
- ++i;
- }
- }
- return count;
- }
+// public static int getParameterCount(char[] sig) {
+// int i = CharOperation.indexOf('(', sig) + 1;
+// Assert.isTrue(i != 0);
+// int count = 0;
+// int len = sig.length;
+// for (;;) {
+// if (i == len)
+// break;
+// char c = sig[i];
+// if (c == ')')
+// break;
+// if (c == '[') {
+// ++i;
+// } else if (c == 'L') {
+// ++count;
+// i = CharOperation.indexOf(';', sig, i + 1) + 1;
+// Assert.isTrue(i != 0);
+// } else {
+// ++count;
+// ++i;
+// }
+// }
+// return count;
+// }
/**
* Put all the arguments in one String.
* Separate all the arguments of a String made by
* getProblemArgumentsForMarker
*/
- public static String[] getProblemArgumentsFromMarker(String argumentsString) {
- if (argumentsString == null)
- return null;
- int index = argumentsString.indexOf(':');
- if (index == -1)
- return null;
-
- int length = argumentsString.length();
- int numberOfArg;
- try {
- numberOfArg = Integer.parseInt(argumentsString.substring(0, index));
- } catch (NumberFormatException e) {
- return null;
- }
- argumentsString = argumentsString.substring(index + 1, length);
-
- String[] args = new String[length];
- int count = 0;
-
- StringTokenizer tokenizer = new StringTokenizer(argumentsString,
- ARGUMENTS_DELIMITER);
- while (tokenizer.hasMoreTokens()) {
- String argument = tokenizer.nextToken();
- if (argument.equals(EMPTY_ARGUMENT))
- argument = ""; //$NON-NLS-1$
- args[count++] = argument;
- }
-
- if (count != numberOfArg)
- return null;
-
- System.arraycopy(args, 0, args = new String[count], 0, count);
- return args;
- }
+// public static String[] getProblemArgumentsFromMarker(String argumentsString) {
+// if (argumentsString == null)
+// return null;
+// int index = argumentsString.indexOf(':');
+// if (index == -1)
+// return null;
+//
+// int length = argumentsString.length();
+// int numberOfArg;
+// try {
+// numberOfArg = Integer.parseInt(argumentsString.substring(0, index));
+// } catch (NumberFormatException e) {
+// return null;
+// }
+// argumentsString = argumentsString.substring(index + 1, length);
+//
+// String[] args = new String[length];
+// int count = 0;
+//
+// StringTokenizer tokenizer = new StringTokenizer(argumentsString,
+// ARGUMENTS_DELIMITER);
+// while (tokenizer.hasMoreTokens()) {
+// String argument = tokenizer.nextToken();
+// if (argument.equals(EMPTY_ARGUMENT))
+// argument = ""; //$NON-NLS-1$
+// args[count++] = argument;
+// }
+//
+// if (count != numberOfArg)
+// return null;
+//
+// System.arraycopy(args, 0, args = new String[count], 0, count);
+// return args;
+// }
/**
* Returns the given file's contents as a byte array.
* Returns the index of the first argument paths which is strictly nested
* inside the path to check
*/
- public static int indexOfNestedPath(IPath checkedPath, IPath[] paths,
- int pathCount) {
-
- for (int i = 0; i < pathCount; i++) {
- if (checkedPath.equals(paths[i]))
- continue;
- if (checkedPath.isPrefixOf(paths[i]))
- return i;
- }
- return -1;
- }
+// public static int indexOfNestedPath(IPath checkedPath, IPath[] paths,
+// int pathCount) {
+//
+// for (int i = 0; i < pathCount; i++) {
+// if (checkedPath.equals(paths[i]))
+// continue;
+// if (checkedPath.isPrefixOf(paths[i]))
+// return i;
+// }
+// return -1;
+// }
/*
* Returns whether the given java element is exluded from its root's
/**
* Returns the length of the common prefix between s1 and s2.
*/
- public static int prefixLength(char[] s1, char[] s2) {
- int len = 0;
- int max = Math.min(s1.length, s2.length);
- for (int i = 0; i < max && s1[i] == s2[i]; ++i)
- ++len;
- return len;
- }
+// public static int prefixLength(char[] s1, char[] s2) {
+// int len = 0;
+// int max = Math.min(s1.length, s2.length);
+// for (int i = 0; i < max && s1[i] == s2[i]; ++i)
+// ++len;
+// return len;
+// }
/**
* Returns the length of the common prefix between s1 and s2.
*/
- public static int prefixLength(String s1, String s2) {
- int len = 0;
- int max = Math.min(s1.length(), s2.length());
- for (int i = 0; i < max && s1.charAt(i) == s2.charAt(i); ++i)
- ++len;
- return len;
- }
+// public static int prefixLength(String s1, String s2) {
+// int len = 0;
+// int max = Math.min(s1.length(), s2.length());
+// for (int i = 0; i < max && s1.charAt(i) == s2.charAt(i); ++i)
+// ++len;
+// return len;
+// }
- private static void quickSort(char[][] list, int left, int right) {
- int original_left = left;
- int original_right = right;
- char[] mid = list[(left + right) / 2];
- do {
- while (compare(list[left], mid) < 0) {
- left++;
- }
- while (compare(mid, list[right]) < 0) {
- right--;
- }
- if (left <= right) {
- char[] tmp = list[left];
- list[left] = list[right];
- list[right] = tmp;
- left++;
- right--;
- }
- } while (left <= right);
- if (original_left < right) {
- quickSort(list, original_left, right);
- }
- if (left < original_right) {
- quickSort(list, left, original_right);
- }
- }
+// private static void quickSort(char[][] list, int left, int right) {
+// int original_left = left;
+// int original_right = right;
+// char[] mid = list[(left + right) / 2];
+// do {
+// while (compare(list[left], mid) < 0) {
+// left++;
+// }
+// while (compare(mid, list[right]) < 0) {
+// right--;
+// }
+// if (left <= right) {
+// char[] tmp = list[left];
+// list[left] = list[right];
+// list[right] = tmp;
+// left++;
+// right--;
+// }
+// } while (left <= right);
+// if (original_left < right) {
+// quickSort(list, original_left, right);
+// }
+// if (left < original_right) {
+// quickSort(list, left, original_right);
+// }
+// }
/**
* Sort the comparable objects in the given collection.
}
}
- private static void quickSort(int[] list, int left, int right) {
- int original_left = left;
- int original_right = right;
- int mid = list[(left + right) / 2];
- do {
- while (list[left] < mid) {
- left++;
- }
- while (mid < list[right]) {
- right--;
- }
- if (left <= right) {
- int tmp = list[left];
- list[left] = list[right];
- list[right] = tmp;
- left++;
- right--;
- }
- } while (left <= right);
- if (original_left < right) {
- quickSort(list, original_left, right);
- }
- if (left < original_right) {
- quickSort(list, left, original_right);
- }
- }
+// private static void quickSort(int[] list, int left, int right) {
+// int original_left = left;
+// int original_right = right;
+// int mid = list[(left + right) / 2];
+// do {
+// while (list[left] < mid) {
+// left++;
+// }
+// while (mid < list[right]) {
+// right--;
+// }
+// if (left <= right) {
+// int tmp = list[left];
+// list[left] = list[right];
+// list[right] = tmp;
+// left++;
+// right--;
+// }
+// } while (left <= right);
+// if (original_left < right) {
+// quickSort(list, original_left, right);
+// }
+// if (left < original_right) {
+// quickSort(list, left, original_right);
+// }
+// }
/**
* Sort the objects in the given collection using the given comparer.
/**
* Sort the strings in the given collection in reverse alphabetical order.
*/
- private static void quickSortReverse(String[] sortedCollection, int left,
- int right) {
- int original_left = left;
- int original_right = right;
- String mid = sortedCollection[(left + right) / 2];
- do {
- while (sortedCollection[left].compareTo(mid) > 0) {
- left++;
- }
- while (mid.compareTo(sortedCollection[right]) > 0) {
- right--;
- }
- if (left <= right) {
- String tmp = sortedCollection[left];
- sortedCollection[left] = sortedCollection[right];
- sortedCollection[right] = tmp;
- left++;
- right--;
- }
- } while (left <= right);
- if (original_left < right) {
- quickSortReverse(sortedCollection, original_left, right);
- }
- if (left < original_right) {
- quickSortReverse(sortedCollection, left, original_right);
- }
- }
+// private static void quickSortReverse(String[] sortedCollection, int left,
+// int right) {
+// int original_left = left;
+// int original_right = right;
+// String mid = sortedCollection[(left + right) / 2];
+// do {
+// while (sortedCollection[left].compareTo(mid) > 0) {
+// left++;
+// }
+// while (mid.compareTo(sortedCollection[right]) > 0) {
+// right--;
+// }
+// if (left <= right) {
+// String tmp = sortedCollection[left];
+// sortedCollection[left] = sortedCollection[right];
+// sortedCollection[right] = tmp;
+// left++;
+// right--;
+// }
+// } while (left <= right);
+// if (original_left < right) {
+// quickSortReverse(sortedCollection, original_left, right);
+// }
+// if (left < original_right) {
+// quickSortReverse(sortedCollection, left, original_right);
+// }
+// }
/**
* Reads in a string from the specified data input stream. The string has
* Unicode string.
* @see java.io.DataInputStream#readUnsignedShort()
*/
- public final static char[] readUTF(DataInput in) throws IOException {
- int utflen = in.readUnsignedShort();
- char str[] = new char[utflen];
- int count = 0;
- int strlen = 0;
- while (count < utflen) {
- int c = in.readUnsignedByte();
- int char2, char3;
- switch (c >> 4) {
- case 0:
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- // 0xxxxxxx
- count++;
- str[strlen++] = (char) c;
- break;
- case 12:
- case 13:
- // 110x xxxx 10xx xxxx
- count += 2;
- if (count > utflen)
- throw new UTFDataFormatException();
- char2 = in.readUnsignedByte();
- if ((char2 & 0xC0) != 0x80)
- throw new UTFDataFormatException();
- str[strlen++] = (char) (((c & 0x1F) << 6) | (char2 & 0x3F));
- break;
- case 14:
- // 1110 xxxx 10xx xxxx 10xx xxxx
- count += 3;
- if (count > utflen)
- throw new UTFDataFormatException();
- char2 = in.readUnsignedByte();
- char3 = in.readUnsignedByte();
- if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80))
- throw new UTFDataFormatException();
- str[strlen++] = (char) (((c & 0x0F) << 12)
- | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0));
- break;
- default:
- // 10xx xxxx, 1111 xxxx
- throw new UTFDataFormatException();
- }
- }
- if (strlen < utflen) {
- System.arraycopy(str, 0, str = new char[strlen], 0, strlen);
- }
- return str;
- }
+// public final static char[] readUTF(DataInput in) throws IOException {
+// int utflen = in.readUnsignedShort();
+// char str[] = new char[utflen];
+// int count = 0;
+// int strlen = 0;
+// while (count < utflen) {
+// int c = in.readUnsignedByte();
+// int char2, char3;
+// switch (c >> 4) {
+// case 0:
+// case 1:
+// case 2:
+// case 3:
+// case 4:
+// case 5:
+// case 6:
+// case 7:
+// // 0xxxxxxx
+// count++;
+// str[strlen++] = (char) c;
+// break;
+// case 12:
+// case 13:
+// // 110x xxxx 10xx xxxx
+// count += 2;
+// if (count > utflen)
+// throw new UTFDataFormatException();
+// char2 = in.readUnsignedByte();
+// if ((char2 & 0xC0) != 0x80)
+// throw new UTFDataFormatException();
+// str[strlen++] = (char) (((c & 0x1F) << 6) | (char2 & 0x3F));
+// break;
+// case 14:
+// // 1110 xxxx 10xx xxxx 10xx xxxx
+// count += 3;
+// if (count > utflen)
+// throw new UTFDataFormatException();
+// char2 = in.readUnsignedByte();
+// char3 = in.readUnsignedByte();
+// if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80))
+// throw new UTFDataFormatException();
+// str[strlen++] = (char) (((c & 0x0F) << 12)
+// | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0));
+// break;
+// default:
+// // 10xx xxxx, 1111 xxxx
+// throw new UTFDataFormatException();
+// }
+// }
+// if (strlen < utflen) {
+// System.arraycopy(str, 0, str = new char[strlen], 0, strlen);
+// }
+// return str;
+// }
/**
* Creates a NLS catalog for the given locale.
}
}
- public static void sort(char[][] list) {
- if (list.length > 1)
- quickSort(list, 0, list.length - 1);
- }
+// public static void sort(char[][] list) {
+// if (list.length > 1)
+// quickSort(list, 0, list.length - 1);
+// }
/**
* Sorts an array of Comparable objects in place.
quickSort(objects, 0, objects.length - 1);
}
- public static void sort(int[] list) {
- if (list.length > 1)
- quickSort(list, 0, list.length - 1);
- }
+// public static void sort(int[] list) {
+// if (list.length > 1)
+// quickSort(list, 0, list.length - 1);
+// }
/**
* Sorts an array of objects in place. The given comparer compares pairs of
* Sorts an array of Comparable objects, returning a new array with the
* sorted items. The original array is left untouched.
*/
- public static Comparable[] sortCopy(Comparable[] objects) {
- int len = objects.length;
- Comparable[] copy = new Comparable[len];
- System.arraycopy(objects, 0, copy, 0, len);
- sort(copy);
- return copy;
- }
+// public static Comparable[] sortCopy(Comparable[] objects) {
+// int len = objects.length;
+// Comparable[] copy = new Comparable[len];
+// System.arraycopy(objects, 0, copy, 0, len);
+// sort(copy);
+// return copy;
+// }
/**
* Sorts an array of Strings, returning a new array with the sorted items.
* The original array is left untouched.
*/
- public static Object[] sortCopy(Object[] objects, Comparer comparer) {
- int len = objects.length;
- Object[] copy = new Object[len];
- System.arraycopy(objects, 0, copy, 0, len);
- sort(copy, comparer);
- return copy;
- }
+// public static Object[] sortCopy(Object[] objects, Comparer comparer) {
+// int len = objects.length;
+// Object[] copy = new Object[len];
+// System.arraycopy(objects, 0, copy, 0, len);
+// sort(copy, comparer);
+// return copy;
+// }
/**
* Sorts an array of Strings, returning a new array with the sorted items.
* The original array is left untouched.
*/
- public static String[] sortCopy(String[] objects) {
- int len = objects.length;
- String[] copy = new String[len];
- System.arraycopy(objects, 0, copy, 0, len);
- sort(copy);
- return copy;
- }
+// public static String[] sortCopy(String[] objects) {
+// int len = objects.length;
+// String[] copy = new String[len];
+// System.arraycopy(objects, 0, copy, 0, len);
+// sort(copy);
+// return copy;
+// }
/**
* Sorts an array of strings in place using quicksort in reverse
* alphabetical order.
*/
- public static void sortReverseOrder(String[] strings) {
- if (strings.length > 1)
- quickSortReverse(strings, 0, strings.length - 1);
- }
+// public static void sortReverseOrder(String[] strings) {
+// if (strings.length > 1)
+// quickSortReverse(strings, 0, strings.length - 1);
+// }
/**
* Converts a String[] to char[][].
*/
- public static char[][] toCharArrays(String[] a) {
- int len = a.length;
- char[][] result = new char[len][];
- for (int i = 0; i < len; ++i) {
- result[i] = toChars(a[i]);
- }
- return result;
- }
+// public static char[][] toCharArrays(String[] a) {
+// int len = a.length;
+// char[][] result = new char[len][];
+// for (int i = 0; i < len; ++i) {
+// result[i] = toChars(a[i]);
+// }
+// return result;
+// }
/**
* Converts a String to char[].
*/
- public static char[] toChars(String s) {
- int len = s.length();
- char[] chars = new char[len];
- s.getChars(0, len, chars, 0);
- return chars;
- }
+// public static char[] toChars(String s) {
+// int len = s.length();
+// char[] chars = new char[len];
+// s.getChars(0, len, chars, 0);
+// return chars;
+// }
/**
* Converts a String to char[][], where segments are separate by '.'.
* Converts a char[][] and a char[] to String, where segments are separated
* by '.'.
*/
- public static String toString(char[][] c, char[] d) {
- if (c == null)
- return new String(d);
- StringBuffer sb = new StringBuffer();
- for (int i = 0, max = c.length; i < max; ++i) {
- sb.append(c[i]);
- sb.append('.');
- }
- sb.append(d);
- return sb.toString();
- }
+// public static String toString(char[][] c, char[] d) {
+// if (c == null)
+// return new String(d);
+// StringBuffer sb = new StringBuffer();
+// for (int i = 0, max = c.length; i < max; ++i) {
+// sb.append(c[i]);
+// sb.append('.');
+// }
+// sb.append(d);
+// return sb.toString();
+// }
/*
* Returns the unresolved type parameter signatures of the given method e.g.
* Returns the unresolved type signature of the given type reference, e.g.
* "QString;", "[int", "[[Qjava.util.Vector;"
*/
- public static String typeSignature(TypeReference type) {
- char[][] compoundName = type.getTypeName();
- char[] typeName = CharOperation.concatWith(compoundName, '.');
- String signature = Signature
- .createTypeSignature(typeName, false/* don't resolve */);
- int dimensions = type.dimensions();
- if (dimensions > 0) {
- signature = Signature.createArraySignature(signature, dimensions);
- }
- return signature;
- }
+// public static String typeSignature(TypeReference type) {
+// char[][] compoundName = type.getTypeName();
+// char[] typeName = CharOperation.concatWith(compoundName, '.');
+// String signature = Signature
+// .createTypeSignature(typeName, false/* don't resolve */);
+// int dimensions = type.dimensions();
+// if (dimensions > 0) {
+// signature = Signature.createArraySignature(signature, dimensions);
+// }
+// return signature;
+// }
/**
* Asserts that the given method signature is valid.
*/
- public static void validateMethodSignature(String sig) {
- Assert.isTrue(isValidMethodSignature(sig));
- }
+// public static void validateMethodSignature(String sig) {
+// Assert.isTrue(isValidMethodSignature(sig));
+// }
/**
* Asserts that the given type signature is valid.
*/
- public static void validateTypeSignature(String sig, boolean allowVoid) {
- Assert.isTrue(isValidTypeSignature(sig, allowVoid));
- }
+// public static void validateTypeSignature(String sig, boolean allowVoid) {
+// Assert.isTrue(isValidTypeSignature(sig, allowVoid));
+// }
public static void verbose(String log) {
verbose(log, System.out);
* if an I/O error occurs.
* @since JDK1.0
*/
- public static int writeUTF(OutputStream out, char[] str) throws IOException {
- int strlen = str.length;
- int utflen = 0;
- for (int i = 0; i < strlen; i++) {
- int c = str[i];
- if ((c >= 0x0001) && (c <= 0x007F)) {
- utflen++;
- } else if (c > 0x07FF) {
- utflen += 3;
- } else {
- utflen += 2;
- }
- }
- if (utflen > 65535)
- throw new UTFDataFormatException();
- out.write((utflen >>> 8) & 0xFF);
- out.write((utflen >>> 0) & 0xFF);
- if (strlen == utflen) {
- for (int i = 0; i < strlen; i++)
- out.write(str[i]);
- } else {
- for (int i = 0; i < strlen; i++) {
- int c = str[i];
- if ((c >= 0x0001) && (c <= 0x007F)) {
- out.write(c);
- } else if (c > 0x07FF) {
- out.write(0xE0 | ((c >> 12) & 0x0F));
- out.write(0x80 | ((c >> 6) & 0x3F));
- out.write(0x80 | ((c >> 0) & 0x3F));
- } else {
- out.write(0xC0 | ((c >> 6) & 0x1F));
- out.write(0x80 | ((c >> 0) & 0x3F));
- }
- }
- }
- return utflen + 2; // the number of bytes written to the stream
- }
+// public static int writeUTF(OutputStream out, char[] str) throws IOException {
+// int strlen = str.length;
+// int utflen = 0;
+// for (int i = 0; i < strlen; i++) {
+// int c = str[i];
+// if ((c >= 0x0001) && (c <= 0x007F)) {
+// utflen++;
+// } else if (c > 0x07FF) {
+// utflen += 3;
+// } else {
+// utflen += 2;
+// }
+// }
+// if (utflen > 65535)
+// throw new UTFDataFormatException();
+// out.write((utflen >>> 8) & 0xFF);
+// out.write((utflen >>> 0) & 0xFF);
+// if (strlen == utflen) {
+// for (int i = 0; i < strlen; i++)
+// out.write(str[i]);
+// } else {
+// for (int i = 0; i < strlen; i++) {
+// int c = str[i];
+// if ((c >= 0x0001) && (c <= 0x007F)) {
+// out.write(c);
+// } else if (c > 0x07FF) {
+// out.write(0xE0 | ((c >> 12) & 0x0F));
+// out.write(0x80 | ((c >> 6) & 0x3F));
+// out.write(0x80 | ((c >> 0) & 0x3F));
+// } else {
+// out.write(0xC0 | ((c >> 6) & 0x1F));
+// out.write(0x80 | ((c >> 0) & 0x3F));
+// }
+// }
+// }
+// return utflen + 2; // the number of bytes written to the stream
+// }
}
\ No newline at end of file