Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/StringComparator.java')
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/StringComparator.java34
1 files changed, 34 insertions, 0 deletions
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/StringComparator.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/StringComparator.java
new file mode 100644
index 00000000000..585d6832f0e
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/StringComparator.java
@@ -0,0 +1,34 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * Juan Cadavid (CEA LIST) juan.cadavid@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.utils;
+
+import java.util.Comparator;
+
+/**
+ *
+ * String comparator ignoring all non-words character
+ *
+ */
+public class StringComparator implements Comparator<String> {
+
+ /**
+ *
+ * @param o1
+ * @param o2
+ * @return
+ */
+ public int compare(String str1, String str2) {
+ str1 = str1.replaceAll(AxisUtils.REGEX, "");//$NON-NLS-1$ //we keep only words characters (letters + numbers) + whitespace
+ str2 = str2.replaceAll(AxisUtils.REGEX, ""); //$NON-NLS-1$
+ return str1.compareToIgnoreCase(str2);
+ };
+}

Back to the top