org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/RuntimeClasspathEntryListComparator.java
Parent Directory
|
Revision Log
Revision 1.5 - (view) (download)
| 1 : | darin | 1.1 | /******************************************************************************* |
| 2 : | darins | 1.5 | * Copyright (c) 2000, 2005 IBM Corporation and others. |
| 3 : | darins | 1.4 | * All rights reserved. This program and the accompanying materials |
| 4 : | * are made available under the terms of the Eclipse Public License v1.0 | ||
| 5 : | darin | 1.1 | * which accompanies this distribution, and is available at |
| 6 : | darins | 1.4 | * http://www.eclipse.org/legal/epl-v10.html |
| 7 : | darin | 1.1 | * |
| 8 : | * Contributors: | ||
| 9 : | * IBM Corporation - initial API and implementation | ||
| 10 : | droberts | 1.3 | *******************************************************************************/ |
| 11 : | package org.eclipse.jdt.internal.launching; | ||
| 12 : | |||
| 13 : | darin | 1.1 | |
| 14 : | import java.util.Comparator; | ||
| 15 : | import java.util.List; | ||
| 16 : | |||
| 17 : | /** | ||
| 18 : | * Compares lists of runtime classpath entry mementos | ||
| 19 : | */ | ||
| 20 : | public class RuntimeClasspathEntryListComparator implements Comparator { | ||
| 21 : | |||
| 22 : | /** | ||
| 23 : | * @see Comparator#compare(Object, Object) | ||
| 24 : | */ | ||
| 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 : | darin | 1.2 | if (!equalsIgnoreWhitespace(memento1, memento2)) { |
| 34 : | darin | 1.1 | return -1; |
| 35 : | } | ||
| 36 : | } | ||
| 37 : | return 0; | ||
| 38 : | } | ||
| 39 : | return -1; | ||
| 40 : | darin | 1.2 | } |
| 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 : | darin | 1.1 | } |
| 67 : | |||
| 68 : | } |
| help@eclipse.org | ViewVC Help |
| Powered by ViewVC 1.0.3 |
