Here you can find the source of indexOf(final String str, final String searchString)
Parameter | Description |
---|---|
str | a parameter |
searchString | a parameter |
private static Integer[] indexOf(final String str, final String searchString)
//package com.java2s; // ProjectForge is dual-licensed. import java.util.ArrayList; import java.util.List; public class Main { /**//from w w w.j a v a 2s . co m * Helper method for getId(String). * @param str * @param searchString * @return */ private static Integer[] indexOf(final String str, final String searchString) { if (str == null || str.indexOf(searchString) < 0) { return null; } final List<Integer> list = new ArrayList<Integer>(); int pos = -1; final int length = str.length(); for (int i = 0; i < 100; i++) { // Endless loop detection if (pos >= length - 1) { break; } pos = str.indexOf(searchString, pos + 1); boolean syntax = true; if (pos >= 0) { // Check that a comma or [ bracket is left to the id= for (int j = pos - 1; j >= 0; j--) { final char ch = str.charAt(j); if (ch == ',' || ch == '[') { break; } if (Character.isWhitespace(ch) == false) { syntax = false; break; } } if (syntax == true) { list.add(pos); } } else { break; } } final Integer[] result = new Integer[list.size()]; return list.toArray(result); } }