code: public static int indexOfName(String nameList, String name) {
          int idx = nameList.indexOf(name);
          // Calculate matching index.
          while (idx != -1) {
              if (idx == 0 || nameList.charAt(idx - 1) == ' ') {
                  int last = idx + name.length();
                  int lastPos = nameList.length();
                  if ((last == lastPos) || ((last < lastPos) && (nameList.charAt(last) == ' '))) {
                      break;
                  }
              }
              idx = nameList.indexOf(name, idx + 1);
          }
          return idx;
      }
docs: Exact copy of com.google.gwt.dom.client.Element.indexOfName()
  <p> Returns the index of the first occurrence of name in a space-separated list of names,
  or -1 if not found. </p>
  
  @param nameList list of space delimited names
  @param name a non-empty string.  Should be already trimmed.