Moving the indexOf(String, String, int) method above the ordinalIndexOf methods to put it with its overloaded peers. LANG-590
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@907385 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java b/src/main/java/org/apache/commons/lang3/StringUtils.java
index 896a02a..9b278d5 100644
--- a/src/main/java/org/apache/commons/lang3/StringUtils.java
+++ b/src/main/java/org/apache/commons/lang3/StringUtils.java
@@ -814,6 +814,44 @@
}
/**
+ * <p>Finds the first index within a String, handling <code>null</code>.
+ * This method uses {@link String#indexOf(String, int)}.</p>
+ *
+ * <p>A <code>null</code> String will return <code>-1</code>.
+ * A negative start position is treated as zero.
+ * An empty ("") search String always matches.
+ * A start position greater than the string length only matches
+ * an empty search String.</p>
+ *
+ * <pre>
+ * StringUtils.indexOf(null, *, *) = -1
+ * StringUtils.indexOf(*, null, *) = -1
+ * StringUtils.indexOf("", "", 0) = 0
+ * StringUtils.indexOf("aabaabaa", "a", 0) = 0
+ * StringUtils.indexOf("aabaabaa", "b", 0) = 2
+ * StringUtils.indexOf("aabaabaa", "ab", 0) = 1
+ * StringUtils.indexOf("aabaabaa", "b", 3) = 5
+ * StringUtils.indexOf("aabaabaa", "b", 9) = -1
+ * StringUtils.indexOf("aabaabaa", "b", -1) = 2
+ * StringUtils.indexOf("aabaabaa", "", 2) = 2
+ * StringUtils.indexOf("abc", "", 9) = 3
+ * </pre>
+ *
+ * @param str the String to check, may be null
+ * @param searchStr the String to find, may be null
+ * @param startPos the start position, negative treated as zero
+ * @return the first index of the search String,
+ * -1 if no match or <code>null</code> string input
+ * @since 2.0
+ */
+ public static int indexOf(String str, String searchStr, int startPos) {
+ if (str == null || searchStr == null) {
+ return -1;
+ }
+ return str.indexOf(searchStr, startPos);
+ }
+
+ /**
* <p>Finds the n-th index within a String, handling <code>null</code>.
* This method uses {@link String#indexOf(String)}.</p>
*
@@ -875,44 +913,6 @@
}
/**
- * <p>Finds the first index within a String, handling <code>null</code>.
- * This method uses {@link String#indexOf(String, int)}.</p>
- *
- * <p>A <code>null</code> String will return <code>-1</code>.
- * A negative start position is treated as zero.
- * An empty ("") search String always matches.
- * A start position greater than the string length only matches
- * an empty search String.</p>
- *
- * <pre>
- * StringUtils.indexOf(null, *, *) = -1
- * StringUtils.indexOf(*, null, *) = -1
- * StringUtils.indexOf("", "", 0) = 0
- * StringUtils.indexOf("aabaabaa", "a", 0) = 0
- * StringUtils.indexOf("aabaabaa", "b", 0) = 2
- * StringUtils.indexOf("aabaabaa", "ab", 0) = 1
- * StringUtils.indexOf("aabaabaa", "b", 3) = 5
- * StringUtils.indexOf("aabaabaa", "b", 9) = -1
- * StringUtils.indexOf("aabaabaa", "b", -1) = 2
- * StringUtils.indexOf("aabaabaa", "", 2) = 2
- * StringUtils.indexOf("abc", "", 9) = 3
- * </pre>
- *
- * @param str the String to check, may be null
- * @param searchStr the String to find, may be null
- * @param startPos the start position, negative treated as zero
- * @return the first index of the search String,
- * -1 if no match or <code>null</code> string input
- * @since 2.0
- */
- public static int indexOf(String str, String searchStr, int startPos) {
- if (str == null || searchStr == null) {
- return -1;
- }
- return str.indexOf(searchStr, startPos);
- }
-
- /**
* <p>Case in-sensitive find of the first index within a String.</p>
*
* <p>A <code>null</code> String will return <code>-1</code>.