diff options
Diffstat (limited to 'org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/IgnoreWhiteSpaceComparator.java')
-rw-r--r-- | org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/IgnoreWhiteSpaceComparator.java | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/IgnoreWhiteSpaceComparator.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/IgnoreWhiteSpaceComparator.java index ab3f41e18..84aef55ad 100644 --- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/IgnoreWhiteSpaceComparator.java +++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/IgnoreWhiteSpaceComparator.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -12,25 +12,27 @@ package org.eclipse.ui.externaltools.internal.launchConfigurations; import java.util.Comparator; -public class IgnoreWhiteSpaceComparator implements Comparator { +public class IgnoreWhiteSpaceComparator implements Comparator<String> { - /* (non-Javadoc) - * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) - */ - public int compare(Object o1, Object o2) { - String one= (String)o1; - String two= (String)o2; + @Override + public int compare(String o1, String o2) { + if (o1 == null || o2 == null) { + if (o1 == o2) { + return 0; + } + return -1; + } int i1 = 0; int i2 = 0; - int l1 = one.length(); - int l2 = two.length(); + int l1 = o1.length(); + int l2 = o2.length(); char ch1 = ' '; char ch2 = ' '; while (i1 < l1 && i2 < l2) { - while (i1 < l1 && Character.isWhitespace(ch1 = one.charAt(i1))) { + while (i1 < l1 && Character.isWhitespace(ch1 = o1.charAt(i1))) { i1++; } - while (i2 < l2 && Character.isWhitespace(ch2 = two.charAt(i2))) { + while (i2 < l2 && Character.isWhitespace(ch2 = o2.charAt(i2))) { i2++; } if (i1 == l1 && i2 == l2) { @@ -38,7 +40,7 @@ public class IgnoreWhiteSpaceComparator implements Comparator { } if (ch1 != ch2) { return -1; - } + } i1++; i2++; } |