changeset 498:1f1f14c932ed 3.0.14

Framework: Added StringUtils.indexOf(needle, haystack) method.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 08 Aug 2013 17:01:58 +0200
parents 6eb9ce20ba8b
children baffc9b6f379
files artifacts-common/src/main/java/org/dive4elements/artifacts/common/utils/StringUtils.java
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts-common/src/main/java/org/dive4elements/artifacts/common/utils/StringUtils.java	Tue Jul 30 19:15:48 2013 +0200
+++ b/artifacts-common/src/main/java/org/dive4elements/artifacts/common/utils/StringUtils.java	Thu Aug 08 17:01:58 2013 +0200
@@ -136,13 +136,17 @@
         return dst;
     }
 
-    public static final boolean contains(String needle, String [] haystack) {
-        for (String stray: haystack) {
-            if (needle.equals(stray)) {
-                return true;
+    public static final int indexOf(String needle, String [] haystack) {
+        for (int i = 0; i < haystack.length; ++i) {
+            if (needle.equals(haystack[i])) {
+                return i;
             }
         }
-        return false;
+        return -1;
+    }
+
+    public static final boolean contains(String needle, String [] haystack) {
+        return indexOf(needle, haystack) != -1;
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org