code: public int countIn(CharSequence sequence, CountMethod countMethod, SpanCondition spanCondition) {
          int count = 0;
          int start = 0;
          SpanCondition skipSpan = spanCondition == SpanCondition.NOT_CONTAINED ? SpanCondition.SIMPLE
                  : SpanCondition.NOT_CONTAINED;
          final int length = sequence.length();
          OutputInt spanCount = null;
          while (start != length) {
              int endOfSpan = unicodeSet.span(sequence, start, skipSpan);
              if (endOfSpan == length) {
                  break;
              }
              if (countMethod == CountMethod.WHOLE_SPAN) {
                  start = unicodeSet.span(sequence, endOfSpan, spanCondition);
                  count += 1;
              } else {
                  if (spanCount == null) {
                      spanCount = new OutputInt();
                  }
                  start = unicodeSet.spanAndCount(sequence, endOfSpan, spanCondition, spanCount);
                  count += spanCount.value;
              }
          }
          return count;
      }
docs: Returns the number of matching characters found in a character sequence.
  The code alternates spans; see the class doc for {@link UnicodeSetSpanner} for a note about boundary conditions.
  @param sequence
  the sequence to count characters in
  @param countMethod
  whether to treat an entire span as a match, or individual elements as matches
  @param spanCondition
  the spanCondition to use. SIMPLE or CONTAINED means only count the elements in the span;
  NOT_CONTAINED is the reverse.
  <br><b>WARNING: </b> when a UnicodeSet contains strings, there may be unexpected behavior in edge cases.
  @return the count. Zero if there are none.