[PATCH] Framework: Added StringUtils.indexOf(needle, haystack) method
Wald Commits
scm-commit at wald.intevation.org
Thu Aug 8 17:02:02 CEST 2013
# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1375974118 -7200
# Node ID 1f1f14c932ed09275acdf6526264207e53f98f99
# Parent 6eb9ce20ba8b97e9a2929ce3e590f72b36edcc45
Framework: Added StringUtils.indexOf(needle, haystack) method.
diff -r 6eb9ce20ba8b -r 1f1f14c932ed artifacts-common/src/main/java/org/dive4elements/artifacts/common/utils/StringUtils.java
--- 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 :
More information about the Dive4elements-commits
mailing list