comparison artifacts-common/src/main/java/org/dive4elements/artifacts/common/utils/StringUtils.java @ 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 415df0fc4fa1
children 584591f8203c
comparison
equal deleted inserted replaced
497:6eb9ce20ba8b 498:1f1f14c932ed
134 System.arraycopy(a, 0, dst, 0, a.length); 134 System.arraycopy(a, 0, dst, 0, a.length);
135 System.arraycopy(b, 0, dst, a.length, b.length); 135 System.arraycopy(b, 0, dst, a.length, b.length);
136 return dst; 136 return dst;
137 } 137 }
138 138
139 public static final boolean contains(String needle, String [] haystack) { 139 public static final int indexOf(String needle, String [] haystack) {
140 for (String stray: haystack) { 140 for (int i = 0; i < haystack.length; ++i) {
141 if (needle.equals(stray)) { 141 if (needle.equals(haystack[i])) {
142 return true; 142 return i;
143 } 143 }
144 } 144 }
145 return false; 145 return -1;
146 }
147
148 public static final boolean contains(String needle, String [] haystack) {
149 return indexOf(needle, haystack) != -1;
146 } 150 }
147 } 151 }
148 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 152 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org