commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Abrasha <...@git.apache.org>
Subject [GitHub] commons-lang pull request #290: Added string methods
Date Fri, 29 Sep 2017 08:24:48 GMT
Github user Abrasha commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/290#discussion_r141814183
  
    --- Diff: src/main/java/org/apache/commons/lang3/StringUtils.java ---
    @@ -9245,5 +9245,39 @@ public static String unwrap(final String str, final char wrapChar)
{
                 index += Character.charCount(result[i]);
             }
             return result;
    +    }    
    +    
    +    /**
    +     * <p>Finds index of all the occurences of given search key found in source
string.
    +     * </p>
    +     * @param source
    +     * @param searchKey
    +     * @return list of integer of indexes.
    +     */
    +    public static List<Integer> indexOfAll(final String source, final Character
searchKey) {
    +    	if(source == null || source.length() == 0 || searchKey == null ) {
    +    		return null;
    +    	}
    +    	List<Integer> indexList = new ArrayList<>();
    +		for(int i = 0 ; i < source.length() ; i++) {
    +			if(searchKey.equals(source.charAt(i))) {
    +				indexList.add(i);
    +			}
    +		}
    --- End diff --
    
    Could you fix the indentation please? Let it be properly aligned.


---

Mime
View raw message