code: protected int countToken(String token, String target) {
          int tokenIndex = 0;
          int count = 0;
          while (tokenIndex != -1) {
              tokenIndex = target.indexOf(token, tokenIndex);
              if (tokenIndex > -1) {
                  tokenIndex++;
                  count++;
              }
          }
          return count;
      }
docs: Returns the number of times the token appears in the target.
  @param token Token value to be counted.
  @param target Target value to count tokens in.
  @return the number of tokens.