1 11 package org.eclipse.debug.internal.core.sourcelookup; 12 13 import java.util.Comparator ; 14 15 20 public class SourceLocatorMementoComparator implements Comparator { 21 24 public int compare(Object o1, Object o2) { 25 String m1 = (String )o1; 26 String m2 = (String )o2; 27 int i1 = 0, i2 = 0; 28 while (i1 < m1.length()) { 29 i1 = skipWhitespace(m1, i1); 30 i2 = skipWhitespace(m2, i2); 31 if (i1 < m1.length() && i2 < m2.length()) { 32 if (m1.charAt(i1) != m2.charAt(i2)) { 33 return -1; 34 } 35 i1++; 36 i2++; 37 } else { 38 if (i2 < m2.length()) { 39 return -1; 40 } 41 return 0; 42 } 43 } 44 return 0; 45 } 46 47 private int skipWhitespace(String string, int offset) { 48 while (offset < string.length() && Character.isWhitespace(string.charAt(offset))) { 49 offset++; 50 } 51 return offset; 52 } 53 } 54 | Popular Tags |