Refactory: remove unused classes, imports, fields and methods.
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / corext / util / Strings.java
index 5012eb7..334e22d 100644 (file)
@@ -32,9 +32,9 @@ public class Strings {
        /**
         * tests if a char is lower case. Fix for 26529
         */
-       public static boolean isLowerCase(char ch) {
-               return Character.toLowerCase(ch) == ch;
-       }
+//     public static boolean isLowerCase(char ch) {
+//             return Character.toLowerCase(ch) == ch;
+//     }
 
        /**
         * Line delimiter chars are '\n' and '\r'.
@@ -43,20 +43,20 @@ public class Strings {
                return ch == '\n' || ch == '\r';
        }
 
-       public static String removeNewLine(String message) {
-               StringBuffer result = new StringBuffer();
-               int current = 0;
-               int index = message.indexOf('\n', 0);
-               while (index != -1) {
-                       result.append(message.substring(current, index));
-                       if (current < index && index != 0)
-                               result.append(' ');
-                       current = index + 1;
-                       index = message.indexOf('\n', current);
-               }
-               result.append(message.substring(current));
-               return result.toString();
-       }
+//     public static String removeNewLine(String message) {
+//             StringBuffer result = new StringBuffer();
+//             int current = 0;
+//             int index = message.indexOf('\n', 0);
+//             while (index != -1) {
+//                     result.append(message.substring(current, index));
+//                     if (current < index && index != 0)
+//                             result.append(' ');
+//                     current = index + 1;
+//                     index = message.indexOf('\n', current);
+//             }
+//             result.append(message.substring(current));
+//             return result.toString();
+//     }
 
        /**
         * Converts the given string into an array of lines. The lines don't contain
@@ -66,23 +66,23 @@ public class Strings {
         *      null</code>
         *         if the input string can't be converted in an array of lines.
         */
-       public static String[] convertIntoLines(String input) {
-               try {
-                       ILineTracker tracker = new DefaultLineTracker();
-                       tracker.set(input);
-                       int size = tracker.getNumberOfLines();
-                       String result[] = new String[size];
-                       for (int i = 0; i < size; i++) {
-                               IRegion region = tracker.getLineInformation(i);
-                               int offset = region.getOffset();
-                               result[i] = input
-                                               .substring(offset, offset + region.getLength());
-                       }
-                       return result;
-               } catch (BadLocationException e) {
-                       return null;
-               }
-       }
+//     public static String[] convertIntoLines(String input) {
+//             try {
+//                     ILineTracker tracker = new DefaultLineTracker();
+//                     tracker.set(input);
+//                     int size = tracker.getNumberOfLines();
+//                     String result[] = new String[size];
+//                     for (int i = 0; i < size; i++) {
+//                             IRegion region = tracker.getLineInformation(i);
+//                             int offset = region.getOffset();
+//                             result[i] = input
+//                                             .substring(offset, offset + region.getLength());
+//                     }
+//                     return result;
+//             } catch (BadLocationException e) {
+//                     return null;
+//             }
+//     }
 
        /**
         * Returns <code>true</code> if the given string only consists of white
@@ -127,24 +127,24 @@ public class Strings {
                        return line.substring(start);
        }
 
-       public static String trimTrailingTabsAndSpaces(String line) {
-               int size = line.length();
-               int end = size;
-               for (int i = size - 1; i >= 0; i--) {
-                       char c = line.charAt(i);
-                       if (isIndentChar(c)) {
-                               end = i;
-                       } else {
-                               break;
-                       }
-               }
-               if (end == size)
-                       return line;
-               else if (end == 0)
-                       return ""; //$NON-NLS-1$
-               else
-                       return line.substring(0, end);
-       }
+//     public static String trimTrailingTabsAndSpaces(String line) {
+//             int size = line.length();
+//             int end = size;
+//             for (int i = size - 1; i >= 0; i--) {
+//                     char c = line.charAt(i);
+//                     if (isIndentChar(c)) {
+//                             end = i;
+//                     } else {
+//                             break;
+//                     }
+//             }
+//             if (end == size)
+//                     return line;
+//             else if (end == 0)
+//                     return ""; //$NON-NLS-1$
+//             else
+//                     return line.substring(0, end);
+//     }
 
        /**
         * Returns the indent of the given string.
@@ -222,20 +222,20 @@ public class Strings {
         * Removes all leading indents from the given line. If the line doesn't
         * contain any indents the line itself is returned.
         */
-       public static String trimIndents(String s, int tabWidth) {
-               int indent = computeIndent(s, tabWidth);
-               if (indent == 0)
-                       return s;
-               return trimIndent(s, indent, tabWidth);
-       }
+//     public static String trimIndents(String s, int tabWidth) {
+//             int indent = computeIndent(s, tabWidth);
+//             if (indent == 0)
+//                     return s;
+//             return trimIndent(s, indent, tabWidth);
+//     }
 
        /**
         * Removes the common number of indents from all lines. If a line only
         * consists out of white space it is ignored.
         */
-       public static void trimIndentation(String[] lines, int tabWidth) {
-               trimIndentation(lines, tabWidth, true);
-       }
+//     public static void trimIndentation(String[] lines, int tabWidth) {
+//             trimIndentation(lines, tabWidth, true);
+//     }
 
        /**
         * Removes the common number of indents from all lines. If a line only
@@ -243,83 +243,83 @@ public class Strings {
         * considerFirstLine</code>
         * is false the first line will be ignored.
         */
-       public static void trimIndentation(String[] lines, int tabWidth,
-                       boolean considerFirstLine) {
-               String[] toDo = new String[lines.length];
-               // find indentation common to all lines
-               int minIndent = Integer.MAX_VALUE; // very large
-               for (int i = considerFirstLine ? 0 : 1; i < lines.length; i++) {
-                       String line = lines[i];
-                       if (containsOnlyWhitespaces(line))
-                               continue;
-                       toDo[i] = line;
-                       int indent = computeIndent(line, tabWidth);
-                       if (indent < minIndent) {
-                               minIndent = indent;
-                       }
-               }
+//     public static void trimIndentation(String[] lines, int tabWidth,
+//                     boolean considerFirstLine) {
+//             String[] toDo = new String[lines.length];
+//             // find indentation common to all lines
+//             int minIndent = Integer.MAX_VALUE; // very large
+//             for (int i = considerFirstLine ? 0 : 1; i < lines.length; i++) {
+//                     String line = lines[i];
+//                     if (containsOnlyWhitespaces(line))
+//                             continue;
+//                     toDo[i] = line;
+//                     int indent = computeIndent(line, tabWidth);
+//                     if (indent < minIndent) {
+//                             minIndent = indent;
+//                     }
+//             }
+//
+//             if (minIndent > 0) {
+//                     // remove this indent from all lines
+//                     for (int i = considerFirstLine ? 0 : 1; i < toDo.length; i++) {
+//                             String s = toDo[i];
+//                             if (s != null)
+//                                     lines[i] = trimIndent(s, minIndent, tabWidth);
+//                             else {
+//                                     String line = lines[i];
+//                                     int indent = computeIndent(line, tabWidth);
+//                                     if (indent > minIndent)
+//                                             lines[i] = trimIndent(line, minIndent, tabWidth);
+//                                     else
+//                                             lines[i] = trimLeadingTabsAndSpaces(line);
+//                             }
+//                     }
+//             }
+//     }
 
-               if (minIndent > 0) {
-                       // remove this indent from all lines
-                       for (int i = considerFirstLine ? 0 : 1; i < toDo.length; i++) {
-                               String s = toDo[i];
-                               if (s != null)
-                                       lines[i] = trimIndent(s, minIndent, tabWidth);
-                               else {
-                                       String line = lines[i];
-                                       int indent = computeIndent(line, tabWidth);
-                                       if (indent > minIndent)
-                                               lines[i] = trimIndent(line, minIndent, tabWidth);
-                                       else
-                                               lines[i] = trimLeadingTabsAndSpaces(line);
-                               }
-                       }
-               }
-       }
+//     public static String getIndentString(String line, int tabWidth) {
+//             int size = line.length();
+//             int end = 0;
+//             int blanks = 0;
+//             for (int i = 0; i < size; i++) {
+//                     char c = line.charAt(i);
+//                     if (c == '\t') {
+//                             end = i + 1;
+//                             blanks = 0;
+//                     } else if (isIndentChar(c)) {
+//                             blanks++;
+//                             if (blanks == tabWidth) {
+//                                     end = i + 1;
+//                                     blanks = 0;
+//                             }
+//                     } else {
+//                             break;
+//                     }
+//             }
+//             if (end == 0)
+//                     return ""; //$NON-NLS-1$
+//             else if (end == size)
+//                     return line;
+//             else
+//                     return line.substring(0, end);
+//     }
 
-       public static String getIndentString(String line, int tabWidth) {
-               int size = line.length();
-               int end = 0;
-               int blanks = 0;
-               for (int i = 0; i < size; i++) {
-                       char c = line.charAt(i);
-                       if (c == '\t') {
-                               end = i + 1;
-                               blanks = 0;
-                       } else if (isIndentChar(c)) {
-                               blanks++;
-                               if (blanks == tabWidth) {
-                                       end = i + 1;
-                                       blanks = 0;
-                               }
-                       } else {
-                               break;
-                       }
-               }
-               if (end == 0)
-                       return ""; //$NON-NLS-1$
-               else if (end == size)
-                       return line;
-               else
-                       return line.substring(0, end);
-       }
+//     public static String[] removeTrailingEmptyLines(String[] sourceLines) {
+//             int lastNonEmpty = findLastNonEmptyLineIndex(sourceLines);
+//             String[] result = new String[lastNonEmpty + 1];
+//             for (int i = 0; i < result.length; i++) {
+//                     result[i] = sourceLines[i];
+//             }
+//             return result;
+//     }
 
-       public static String[] removeTrailingEmptyLines(String[] sourceLines) {
-               int lastNonEmpty = findLastNonEmptyLineIndex(sourceLines);
-               String[] result = new String[lastNonEmpty + 1];
-               for (int i = 0; i < result.length; i++) {
-                       result[i] = sourceLines[i];
-               }
-               return result;
-       }
-
-       private static int findLastNonEmptyLineIndex(String[] sourceLines) {
-               for (int i = sourceLines.length - 1; i >= 0; i--) {
-                       if (!sourceLines[i].trim().equals(""))//$NON-NLS-1$
-                               return i;
-               }
-               return -1;
-       }
+//     private static int findLastNonEmptyLineIndex(String[] sourceLines) {
+//             for (int i = sourceLines.length - 1; i >= 0; i--) {
+//                     if (!sourceLines[i].trim().equals(""))//$NON-NLS-1$
+//                             return i;
+//             }
+//             return -1;
+//     }
 
        /**
         * Change the indent of, possible muti-line, code range. The current indent
@@ -365,15 +365,15 @@ public class Strings {
         * Concatenate the given strings into one strings using the passed line
         * delimiter as a delimiter. No delimiter is added to the last line.
         */
-       public static String concatenate(String[] lines, String delimiter) {
-               StringBuffer buffer = new StringBuffer();
-               for (int i = 0; i < lines.length; i++) {
-                       if (i > 0)
-                               buffer.append(delimiter);
-                       buffer.append(lines[i]);
-               }
-               return buffer.toString();
-       }
+//     public static String concatenate(String[] lines, String delimiter) {
+//             StringBuffer buffer = new StringBuffer();
+//             for (int i = 0; i < lines.length; i++) {
+//                     if (i > 0)
+//                             buffer.append(delimiter);
+//                     buffer.append(lines[i]);
+//             }
+//             return buffer.toString();
+//     }
 
        public static boolean equals(String s, char[] c) {
                if (s.length() != c.length)