1 11 package org.eclipse.jdt.internal.launching; 12 13 14 import java.util.Comparator ; 15 import java.util.List ; 16 17 20 public class RuntimeClasspathEntryListComparator implements Comparator { 21 22 25 public int compare(Object o1, Object o2) { 26 List list1 = (List )o1; 27 List list2 = (List )o2; 28 29 if (list1.size() == list2.size()) { 30 for (int i = 0; i < list1.size(); i++) { 31 String memento1 = (String )list1.get(i); 32 String memento2 = (String )list2.get(i); 33 if (!equalsIgnoreWhitespace(memento1, memento2)) { 34 return -1; 35 } 36 } 37 return 0; 38 } 39 return -1; 40 } 41 42 protected boolean equalsIgnoreWhitespace(String one, String two) { 43 int i1 = 0; 44 int i2 = 0; 45 int l1 = one.length(); 46 int l2 = two.length(); 47 char ch1 = ' '; 48 char ch2 = ' '; 49 while (i1 < l1 && i2 < l2) { 50 while (i1 < l1 && Character.isWhitespace(ch1 = one.charAt(i1))) { 51 i1++; 52 } 53 while (i2 < l2 && Character.isWhitespace(ch2 = two.charAt(i2))) { 54 i2++; 55 } 56 if (i1 == l1 && i2 == l2) { 57 return true; 58 } 59 if (ch1 != ch2) { 60 return false; 61 } 62 i1++; 63 i2++; 64 } 65 return true; 66 } 67 68 } 69 | Popular Tags |